Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
8a5c1d3d
Commit
8a5c1d3d
authored
Jan 07, 2020
by
Ulrich Sibiller
Committed by
Mike Gabriel
May 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Atoms.c: some code cleanup
add else clauses, improve debugging, add comments
parent
2594ca99
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
Atoms.c
nx-X11/programs/Xserver/hw/nxagent/Atoms.c
+31
-15
No files found.
nx-X11/programs/Xserver/hw/nxagent/Atoms.c
View file @
8a5c1d3d
...
...
@@ -610,17 +610,14 @@ static AtomMap* nxagentFindAtomByName(char *string, unsigned int length)
* really asking to X-server and caching them.
* FIXME: I don't really know if is better to allocate
* an automatic variable like ret_value and write it, instead of make all
* these return!, perhaps this way the code is a little bit eas
y
er to read.
* these return!, perhaps this way the code is a little bit eas
i
er to read.
* I think this and the 2 .*Find.* are the only functions to look for performances.
*/
XlibAtom
nxagentMakeAtom
(
char
*
string
,
unsigned
int
length
,
Bool
Makeit
)
{
AtomMap
*
current
;
/*
* Surely MakeAtom is faster than
* our nxagentFindAtomByName.
* Surely MakeAtom is faster than our nxagentFindAtomByName.
*/
Atom
local
=
MakeAtom
(
string
,
length
,
Makeit
);
...
...
@@ -635,6 +632,8 @@ XlibAtom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit)
return
local
;
}
AtomMap
*
current
;
if
((
current
=
nxagentFindAtomByLocalValue
(
local
)))
{
/*
...
...
@@ -643,8 +642,7 @@ XlibAtom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit)
return
current
->
remote
;
}
if
((
current
=
nxagentFindAtomByName
(
string
,
length
)))
else
if
((
current
=
nxagentFindAtomByName
(
string
,
length
)))
{
/*
* Found cached by name.
...
...
@@ -656,27 +654,30 @@ XlibAtom nxagentMakeAtom(char *string, unsigned int length, Bool Makeit)
return
current
->
remote
;
}
else
{
/*
* We really have to ask the Xserver for it.
*/
{
/* FIXME: why is Makeit inverted here? */
XlibAtom
remote
=
XInternAtom
(
nxagentDisplay
,
string
,
!
Makeit
);
if
(
remote
==
None
)
{
#ifdef WARNING
fprintf
(
stderr
,
"nxagentMakeAtom: WARNING XInternAtom
failed.
\n
"
);
fprintf
(
stderr
,
"nxagentMakeAtom: WARNING XInternAtom
(.., %s, ..) failed.
\n
"
,
string
);
#endif
return
None
;
}
else
{
nxagentWriteAtom
(
local
,
remote
,
string
,
True
);
return
remote
;
}
}
}
XlibAtom
nxagentLocalToRemoteAtom
(
Atom
local
)
...
...
@@ -693,6 +694,7 @@ XlibAtom nxagentLocalToRemoteAtom(Atom local)
return
None
;
}
/* no mapping required for built-in atoms */
if
(
local
<=
XA_LAST_PREDEFINED
)
{
#ifdef DEBUG
...
...
@@ -705,14 +707,20 @@ XlibAtom nxagentLocalToRemoteAtom(Atom local)
if
(
current
)
{
#ifdef TEST
#ifdef DEBUG
if
(
current
->
string
)
fprintf
(
stderr
,
"%s: local [%d] -> remote [%d (%s)]
\n
"
,
__func__
,
local
,
current
->
remote
,
current
->
string
);
else
fprintf
(
stderr
,
"%s: local [%d] -> remote [%d]
\n
"
,
__func__
,
local
,
current
->
remote
);
#endif
return
current
->
remote
;
}
else
{
const
char
*
string
=
NameForAtom
(
local
);
/* FIXME: why False? */
XlibAtom
remote
=
XInternAtom
(
nxagentDisplay
,
string
,
False
);
if
(
remote
==
None
)
...
...
@@ -727,10 +735,11 @@ XlibAtom nxagentLocalToRemoteAtom(Atom local)
nxagentWriteAtom
(
local
,
remote
,
string
,
True
);
#ifdef TEST
fprintf
(
stderr
,
"%s: local [%d] -> remote [%d (%s)]
\n
"
,
__func__
,
local
,
remote
,
string
);
fprintf
(
stderr
,
"%s: local [%d (%s)] -> remote [%d]
\n
"
,
__func__
,
local
,
string
,
remote
);
#endif
return
remote
;
}
}
Atom
nxagentRemoteToLocalAtom
(
XlibAtom
remote
)
...
...
@@ -743,6 +752,7 @@ Atom nxagentRemoteToLocalAtom(XlibAtom remote)
return
None
;
}
/* no mapping required for built-in atoms */
if
(
remote
<=
XA_LAST_PREDEFINED
)
{
#ifdef DEBUG
...
...
@@ -774,11 +784,16 @@ Atom nxagentRemoteToLocalAtom(XlibAtom remote)
}
#ifdef DEBUG
if
(
current
->
string
)
fprintf
(
stderr
,
"%s: remote [%d] -> local [%d (%s)]
\n
"
,
__func__
,
remote
,
current
->
local
,
current
->
string
);
else
fprintf
(
stderr
,
"%s: remote [%d] -> local [%d]
\n
"
,
__func__
,
remote
,
current
->
local
);
#endif
return
current
->
local
;
}
else
{
char
*
string
=
XGetAtomName
(
nxagentDisplay
,
remote
);
if
(
string
)
...
...
@@ -809,6 +824,7 @@ Atom nxagentRemoteToLocalAtom(XlibAtom remote)
#endif
return
None
;
}
}
#ifdef DEBUG
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment