diff options
author | Kristian Høgsberg <krh@redhat.com> | 2006-07-19 17:27:58 -0400 |
---|---|---|
committer | Daniel Stone <daniels@endtroducing.fooishbar.org> | 2006-07-21 15:19:52 -0400 |
commit | c7577f9b88aac84d59404f29d994ee7af583d33b (patch) | |
tree | a9c4548a231500b954794ffc0ac220e1f73dbe88 /Xi | |
parent | 3a23e499017d5823157806029263edac53c663fd (diff) |
Xi: add DevicePresenceNotify
Add support for DevicePresenceNotify events.
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exglobals.h | 7 | ||||
-rw-r--r-- | Xi/extinit.c | 39 | ||||
-rw-r--r-- | Xi/selectev.c | 54 |
3 files changed, 85 insertions, 15 deletions
diff --git a/Xi/exglobals.h b/Xi/exglobals.h index c64b84875..3afd1bb9e 100644 --- a/Xi/exglobals.h +++ b/Xi/exglobals.h @@ -51,6 +51,7 @@ extern Mask DeviceMappingNotifyMask; extern Mask DeviceOwnerGrabButtonMask; extern Mask DeviceButtonGrabMask; extern Mask DeviceButtonMotionMask; +extern Mask DevicePresenceNotifyMask; extern Mask PropagateMask[]; extern int DeviceValuator; @@ -68,12 +69,8 @@ extern int DeviceKeyStateNotify; extern int DeviceButtonStateNotify; extern int DeviceMappingNotify; extern int ChangeDeviceNotify; +extern int DevicePresenceNotify; extern int RT_INPUTCLIENT; -#if 0 -/* FIXME: in dix */ -extern InputInfo inputInfo; -#endif - #endif /* EXGLOBALS_H */ diff --git a/Xi/extinit.c b/Xi/extinit.c index f3aabe3a7..c1ba462fb 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -166,6 +166,7 @@ Mask DeviceMappingNotifyMask; Mask DeviceOwnerGrabButtonMask; Mask DeviceButtonGrabMask; Mask DeviceButtonMotionMask; +Mask DevicePresenceNotifyMask; int DeviceValuator; int DeviceKeyPress; @@ -182,6 +183,7 @@ int DeviceKeyStateNotify; int DeviceButtonStateNotify; int DeviceMappingNotify; int ChangeDeviceNotify; +int DevicePresenceNotify; int RT_INPUTCLIENT; @@ -202,8 +204,8 @@ Mask PropagateMask[MAX_DEVICES]; */ static XExtensionVersion thisversion = { XI_Present, - XI_Add_XChangeDeviceControl_Major, - XI_Add_XChangeDeviceControl_Minor + XI_Add_DevicePresenceNotify_Major, + XI_Add_DevicePresenceNotify_Minor }; /********************************************************************** @@ -648,6 +650,16 @@ SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) swapl(&to->time, n); } +void +SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to) +{ + register char n; + + *to = *from; + swaps(&to->sequenceNumber,n); + swapl(&to->time, n); +} + /************************************************************************ * * This function sets up extension event types and masks. @@ -674,6 +686,7 @@ FixExtensionEvents(ExtensionEntry * extEntry) ChangeDeviceNotify = DeviceMappingNotify + 1; DeviceKeyStateNotify = ChangeDeviceNotify + 1; DeviceButtonStateNotify = DeviceKeyStateNotify + 1; + DevicePresenceNotify = DeviceButtonStateNotify + 1; event_base[KeyClass] = DeviceKeyPress; event_base[ButtonClass] = DeviceButtonPress; @@ -746,6 +759,9 @@ FixExtensionEvents(ExtensionEntry * extEntry) DeviceOwnerGrabButtonMask = GetNextExtEventMask(); SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton); + + DevicePresenceNotifyMask = GetNextExtEventMask(); + SetEventInfo(DevicePresenceNotifyMask, _devicePresence); SetEventInfo(0, _noExtensionEvent); } @@ -786,6 +802,7 @@ RestoreExtensionEvents(void) ChangeDeviceNotify = 12; DeviceKeyStateNotify = 13; DeviceButtonStateNotify = 13; + DevicePresenceNotify = 14; BadDevice = 0; BadEvent = 1; @@ -823,6 +840,7 @@ IResetProc(ExtensionEntry * unused) EventSwapVector[DeviceButtonStateNotify] = NotImplemented; EventSwapVector[DeviceMappingNotify] = NotImplemented; EventSwapVector[ChangeDeviceNotify] = NotImplemented; + EventSwapVector[DevicePresenceNotify] = NotImplemented; RestoreExtensionEvents(); } @@ -857,9 +875,7 @@ MakeDeviceTypeAtoms(void) } /************************************************************************** - * * Return a DeviceIntPtr corresponding to a specified device id. - * This will not return the pointer or keyboard, or devices that are not on. * */ @@ -869,13 +885,16 @@ LookupDeviceIntRec(CARD8 id) DeviceIntPtr dev; for (dev = inputInfo.devices; dev; dev = dev->next) { - if (dev->id == id) { - if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id) - return (NULL); - return (dev); - } + if (dev->id == id) + return dev; } - return (NULL); + + for (dev = inputInfo.off_devices; dev; dev = dev->next) { + if (dev->id == id) + return dev; + } + + return NULL; } /************************************************************************** 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) |