Xi: add DevicePresenceNotify

Add support for DevicePresenceNotify events.
This commit is contained in:
Kristian Høgsberg 2006-07-19 17:27:58 -04:00 committed by Daniel Stone
parent 3a23e49901
commit c7577f9b88
3 changed files with 85 additions and 15 deletions

View File

@ -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 */

View File

@ -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;
}
/**************************************************************************

View File

@ -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)