summaryrefslogtreecommitdiff
path: root/Xi/selectev.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2006-07-19 17:27:58 -0400
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-07-21 15:19:52 -0400
commitc7577f9b88aac84d59404f29d994ee7af583d33b (patch)
treea9c4548a231500b954794ffc0ac220e1f73dbe88 /Xi/selectev.c
parent3a23e499017d5823157806029263edac53c663fd (diff)
Xi: add DevicePresenceNotify
Add support for DevicePresenceNotify events.
Diffstat (limited to 'Xi/selectev.c')
-rw-r--r--Xi/selectev.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/Xi/selectev.c b/Xi/selectev.c
index 3483804b1..1f6713ad4 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -74,6 +74,53 @@ SOFTWARE.
extern Mask ExtExclusiveMasks[];
extern Mask ExtValidMasks[];
+static int
+HandleDevicePresenceMask(ClientPtr client, WindowPtr win,
+ XEventClass *cls, CARD16 *count)
+{
+ int i, j;
+ Mask mask;
+
+ /* We use the device ID 256 to select events that aren't bound to
+ * any device. For now we only handle the device presence event,
+ * but this could be extended to other events that aren't bound to
+ * a device.
+ *
+ * In order not to break in CreateMaskFromList() we remove the
+ * entries with device ID 256 from the XEventClass array.
+ */
+
+ mask = 0;
+ for (i = 0, j = 0; i < *count; i++) {
+ if (cls[i] >> 8 != 256) {
+ cls[j] = cls[i];
+ j++;
+ continue;
+ }
+
+ switch (cls[i] & 0xff) {
+ case _devicePresence:
+ mask |= DevicePresenceNotifyMask;
+ break;
+ }
+ }
+
+ *count = j;
+
+ if (mask == 0)
+ return Success;
+
+ /* We always only use mksidx = 0 for events not bound to
+ * devices */
+
+ if (AddExtensionClient (win, client, mask, 0) != Success)
+ return BadAlloc;
+
+ RecalculateDeviceDeliverableEvents(win);
+
+ return Success;
+}
+
/***********************************************************************
*
* Handle requests from clients with a different byte order.
@@ -131,6 +178,13 @@ ProcXSelectExtensionEvent(register ClientPtr client)
return Success;
}
+ if (HandleDevicePresenceMask(client, pWin, (XEventClass *) & stuff[i],
+ &stuff->count) != Success) {
+ SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
+ BadAlloc);
+ return Success;
+ }
+
if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1],
stuff->count, tmp, NULL,
X_SelectExtensionEvent)) != Success)