[PATCH:xscope] Print correct event names for events sent via SendEvent requests

Alan Coopersmith alan.coopersmith at oracle.com
Sun Dec 1 11:44:19 PST 2013


The high bit of an X11 event id is set to 0 for events generated by the
server, 1 for events sent from another client via SendEvent requests.

Previously xscope printed:
                         ..............EVENT: **INVALID** (150)

Now it prints:
                         ..............EVENT: ConfigureNotify
                                      source: SendEvent

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 prtype.c  |   22 ++++++++++++++++++++++
 table11.c |    2 +-
 x11.h     |    1 +
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/prtype.c b/prtype.c
index 5889b52..96523f9 100644
--- a/prtype.c
+++ b/prtype.c
@@ -613,6 +613,28 @@ PrintEVENTFORM(const unsigned char *buf)
     return 32;
 }
 
+int
+PrintEVENT(const unsigned char *buf)
+{
+    uint8_t n = IByte(buf);
+    long e = (long) (n & 0x7f);
+    struct ValueListEntry *p;
+
+    p = TD[EVENT].ValueList;
+    while (p != NULL && p->Value != e)
+        p = p->Next;
+
+    if (p != NULL)
+        fprintf(stdout, "%s", p->Name);
+    else
+        fprintf(stdout, "**INVALID** (%d)", n);
+
+    if (n & 0x80)
+        fprintf(stdout, "\n%s%20s: %s", Leader, "source", "SendEvent");
+
+    return 1;
+}
+
 /* ************************************************************ */
 
 int
diff --git a/table11.c b/table11.c
index e141ae1..8d0acca 100644
--- a/table11.c
+++ b/table11.c
@@ -601,7 +601,7 @@ InitEnumeratedTypes(void)
     DefineEValue(p, 16L, "Length");
     DefineEValue(p, 17L, "Implementation");
 
-    p = DefineType(EVENT, ENUMERATED, "EVENT", (PrintProcType) PrintENUMERATED);
+    p = DefineType(EVENT, BUILTIN, "EVENT", (PrintProcType) PrintEVENT);
     DefineEValue(p, 2L, "KeyPress");
     DefineEValue(p, 3L, "KeyRelease");
     DefineEValue(p, 4L, "ButtonPress");
diff --git a/x11.h b/x11.h
index 3004362..59e33e6 100644
--- a/x11.h
+++ b/x11.h
@@ -371,6 +371,7 @@ extern int PrintKEYCODEA(const unsigned char *buf);
 extern int PrintBUTTON(const unsigned char *buf);
 extern int PrintBUTTONA(const unsigned char *buf);
 extern int PrintEVENTFORM(const unsigned char *buf);
+extern int PrintEVENT(const unsigned char *buf);
 extern int PrintENUMERATED(const unsigned char *buf, short length,
                            struct ValueListEntry *ValueList);
 extern int PrintSET(const unsigned char *buf, short length,
-- 
1.7.9.2



More information about the xorg-devel mailing list