aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2020-10-13 00:22:22 +0200
committerUlrich Sibiller <uli42@gmx.de>2021-06-20 20:12:50 +0200
commit27ecb8959669207aaab2c8d5fae12e51b4708f57 (patch)
tree097bcd496b2d1b4b705ae2e6a6d010f2e2f6d236 /nx-X11/programs/Xserver/hw/nxagent/Atoms.c
parenta31353bdd2023cec7453b94438b98fac7e5fae6a (diff)
downloadnx-libs-27ecb8959669207aaab2c8d5fae12e51b4708f57.tar.gz
nx-libs-27ecb8959669207aaab2c8d5fae12e51b4708f57.tar.bz2
nx-libs-27ecb8959669207aaab2c8d5fae12e51b4708f57.zip
Atoms.c: add helper to easily print Atom names in debugging
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Atoms.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Atoms.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
index 2ddf87e55..d9ee678fa 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Atoms.c
@@ -750,6 +750,54 @@ XlibAtom nxagentLocalToRemoteAtom(Atom local)
}
}
+/*
+ * This is mainly used to simplify debug prints. It returns
+ * the string for a remote atom or NULL if atom is unknown/invalid
+ *
+ * The string must NOT be freed by the caller.
+ */
+const char *nxagentRemoteAtomToString(XlibAtom remote)
+{
+ if (remote == None || remote == BAD_RESOURCE)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "%s: remote [%d] is None or BAD_RESOURCE\n", __func__, remote);
+ #endif
+ return NULL;
+ }
+
+ /* no mapping required for built-in atoms */
+ if (remote <= XA_LAST_PREDEFINED)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "%s: remote [%d] is <= XA_LAST_PREDEFINED [%d]\n", __func__, remote, XA_LAST_PREDEFINED);
+ #endif
+
+ /* simply use the builtin string that is the same on every X server */
+ return NameForAtom(remote);
+ }
+
+ AtomMap *current = nxagentFindAtomByRemoteValue(remote);
+ if (current)
+ {
+ return current->string;
+ }
+ else
+ {
+ /* fill up the cache */
+ Atom local = nxagentRemoteToLocalAtom(remote);
+ if (local != None)
+ {
+ current = nxagentFindAtomByRemoteValue(remote);
+ if (current)
+ {
+ return current->string;
+ }
+ }
+ }
+ return NULL;
+}
+
Atom nxagentRemoteToLocalAtom(XlibAtom remote)
{
if (remote == None || remote == BAD_RESOURCE)