summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2009-08-12 16:40:09 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-08-12 16:50:41 -0700
commitb90bb97a5b8686ba050835724c6b299a0cfb0305 (patch)
tree81d76426bb76ba03565a4b45ed537ed84834dd85
parentf65c809fb7c269c2bf450274f424feab85ea95cb (diff)
downloadxscope-b90bb97a5b8686ba050835724c6b299a0cfb0305.tar.gz
Add GenericEvent support
Allows extensions to register their own decoders for GenericEvents, though none do, since XInput isn't decoded yet Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r--extensions.c28
-rw-r--r--extensions.h2
-rw-r--r--print11.c17
-rw-r--r--proto.h1
-rw-r--r--server.c25
-rw-r--r--table11.c3
-rw-r--r--x11.h5
7 files changed, 80 insertions, 1 deletions
diff --git a/extensions.c b/extensions.c
index bacc47e..b374b67 100644
--- a/extensions.c
+++ b/extensions.c
@@ -85,6 +85,9 @@ DefineExtNameValue(int type, unsigned char value, const char *extname)
case ERROR:
typename = "-Error";
break;
+ case EXTENSION:
+ typename = "";
+ break;
default:
panic("Impossible argument to DefineExtNameValue");
}
@@ -142,6 +145,8 @@ ProcessQueryExtensionReply(long seq, const unsigned char *buf)
ext_by_request[qe->request - EXTENSION_MIN_REQ] = qe;
+ DefineExtNameValue(EXTENSION, qe->request, qe->name);
+
for (i = 0; decodable_extensions[i].name != NULL ; i++) {
if (strcmp(qe->name, decodable_extensions[i].name) == 0) {
decodable_extensions[i].init_func(buf);
@@ -171,6 +176,7 @@ static extension_decode_req_ptr ExtensionRequestDecoder[NUM_EXTENSIONS];
static extension_decode_reply_ptr ExtensionReplyDecoder[NUM_EXTENSIONS];
static extension_decode_error_ptr ExtensionErrorDecoder[NUM_EXTENSIONS];
static extension_decode_event_ptr ExtensionEventDecoder[NUM_EXT_EVENTS];
+static extension_decode_event_ptr GenericEventDecoder[NUM_EXTENSIONS];
void
InitializeExtensionDecoder (int Request, extension_decode_req_ptr reqd,
@@ -216,6 +222,21 @@ InitializeExtensionEventDecoder(int Event, extension_decode_event_ptr evd)
ExtensionEventDecoder[Event - EXTENSION_MIN_EV] = evd;
}
+
+void
+InitializeGenericEventDecoder(int Request, extension_decode_event_ptr evd)
+{
+ if ((Request > EXTENSION_MAX_REQ) || (Request < EXTENSION_MIN_REQ)) {
+ char errmsg[128];
+
+ snprintf(errmsg, sizeof(errmsg), "Failed to register decoder"
+ " for invalid generic extension event code %d.", Request);
+ warn(errmsg);
+ return;
+ }
+ GenericEventDecoder[Request - EXTENSION_MIN_REQ] = evd;
+}
+
void
ExtensionRequest (FD fd, const unsigned char *buf, short Request)
{
@@ -273,10 +294,17 @@ ExtensionEvent (FD fd, const unsigned char *buf, short Event)
if ((Event <= EXTENSION_MAX_EV) && (Event >= EXTENSION_MIN_EV)) {
decode_event = ExtensionEventDecoder[Event - EXTENSION_MIN_EV];
+ } else if (Event == Event_Type_Generic) {
+ int Request = IByte (&buf[1]);
+ if ((Request <= EXTENSION_MAX_REQ) && (Request >= EXTENSION_MIN_REQ)) {
+ decode_event = GenericEventDecoder[Request - EXTENSION_MIN_REQ];
+ }
}
if (decode_event != NULL) {
decode_event(fd, buf);
+ } else if (Event == Event_Type_Generic) {
+ UnknownGenericEvent(buf);
} else {
UnknownEvent(buf);
}
diff --git a/extensions.h b/extensions.h
index d93e013..8529b65 100644
--- a/extensions.h
+++ b/extensions.h
@@ -75,5 +75,7 @@ extern void InitializeExtensionErrorDecoder(int Error,
extension_decode_error_ptr errd);
extern void InitializeExtensionEventDecoder(int Event,
extension_decode_event_ptr evd);
+extern void InitializeGenericEventDecoder (int Request,
+ extension_decode_event_ptr evd);
#endif /* XSCOPE_EXTENSIONS_H */
diff --git a/print11.c b/print11.c
index e29ac23..7e0cc72 100644
--- a/print11.c
+++ b/print11.c
@@ -954,6 +954,23 @@ MappingNotifyEvent (
}
void
+UnknownGenericEvent (
+ const unsigned char *buf)
+{
+ long n;
+
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GenericEvent */;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, EXTENSION, "extension");
+ printfield (buf, 2, 2, CARD16, "sequence number");
+ printfield (buf, 4, 4, DVALUE4(n), "event length");
+ PrintField(buf, 2, 8, CARD16, "event type");
+ n = ILong (&buf[4]) + 5;
+ (void) PrintList (&buf[12], n, CARD32, "data");
+}
+
+void
UnknownEvent (
const unsigned char *buf)
{
diff --git a/proto.h b/proto.h
index 9f10586..d7dfaec 100644
--- a/proto.h
+++ b/proto.h
@@ -78,6 +78,7 @@ extern void SelectionNotifyEvent (const unsigned char *buf);
extern void ColormapNotifyEvent (const unsigned char *buf);
extern void ClientMessageEvent (const unsigned char *buf);
extern void MappingNotifyEvent (const unsigned char *buf);
+extern void UnknownGenericEvent (const unsigned char *buf);
extern void UnknownEvent (const unsigned char *buf);
extern void ExtendedRequest (int fd, const unsigned char *buf);
diff --git a/server.c b/server.c
index d04c335..629ade2 100644
--- a/server.c
+++ b/server.c
@@ -683,20 +683,43 @@ ErrorPacket (
return(n);
}
+/* FinishEvent/EventPacket: since GenericEvents may be longer than 32 bytes
+ now, mirror the FinishReply/ReplyPacket model for getting the required
+ data length to handle them. */
static long
-EventPacket (
+FinishEvent (
FD fd,
const unsigned char *buf,
long n)
{
CS[fd].ByteProcessing = ServerPacket;
CS[fd].NumberofBytesNeeded = 32;
+ enterprocedure("FinishEvent");
if (ScopeEnabled)
DecodeEvent(fd, buf, n);
return(n);
}
+static long
+EventPacket (
+ FD fd,
+ const unsigned char *buf,
+ long n)
+{
+ short Event = IByte (&buf[0]);
+ long eventlength = 0;
+
+ CS[fd].ByteProcessing = FinishEvent;
+ CS[fd].NumberofBytesNeeded = 32;
+ if (Event == Event_Type_Generic) {
+ eventlength = ILong(&buf[4]);
+ CS[fd].NumberofBytesNeeded += (4 * eventlength);
+ }
+ debug(8,(stderr, "need %ld bytes to finish reply\n", (4 * eventlength)));
+ return(0);
+}
+
static long
ReplyPacket (
diff --git a/table11.c b/table11.c
index 56fe988..f701e87 100644
--- a/table11.c
+++ b/table11.c
@@ -604,6 +604,7 @@ InitEnumeratedTypes (void)
DefineEValue(p, 32L, "ColormapNotify");
DefineEValue(p, 33L, "ClientMessage");
DefineEValue(p, 34L, "MappingNotify");
+ DefineEValue(p, 35L, "GenericEvent");
p = DefineType(BITGRAVITY, ENUMERATED, "BITGRAVITY", (PrintProcType) PrintENUMERATED);
@@ -876,6 +877,8 @@ InitEnumeratedTypes (void)
DefineEValue(p, 3L, "PseudoColor");
DefineEValue(p, 4L, "TrueColor");
DefineEValue(p, 5L, "DirectColor");
+
+ p = DefineType(EXTENSION, ENUMERATED, "EXTENSION", (PrintProcType) PrintENUMERATED);
}
/* ************************************************************ */
diff --git a/x11.h b/x11.h
index db5abe7..2ed9569 100644
--- a/x11.h
+++ b/x11.h
@@ -258,6 +258,8 @@
#define BIGREQREQUEST 157
#define BIGREQREPLY 158
+#define EXTENSION 159
+
#define MaxTypes 256
extern char ScopeEnabled;
@@ -589,4 +591,7 @@ extern const char REQUESTHEADER[], EVENTHEADER[], ERRORHEADER[], REPLYHEADER[];
} \
} while (0)
+/* Constant defined in Generic Event Protocol 1.0 for event type */
+#define Event_Type_Generic 35
+
#endif /* XSCOPE_X11_H */