Xi: add DevicePresenceNotify
Add support for DevicePresenceNotify events.
This commit is contained in:
parent
3a23e49901
commit
c7577f9b88
|
@ -51,6 +51,7 @@ extern Mask DeviceMappingNotifyMask;
|
||||||
extern Mask DeviceOwnerGrabButtonMask;
|
extern Mask DeviceOwnerGrabButtonMask;
|
||||||
extern Mask DeviceButtonGrabMask;
|
extern Mask DeviceButtonGrabMask;
|
||||||
extern Mask DeviceButtonMotionMask;
|
extern Mask DeviceButtonMotionMask;
|
||||||
|
extern Mask DevicePresenceNotifyMask;
|
||||||
extern Mask PropagateMask[];
|
extern Mask PropagateMask[];
|
||||||
|
|
||||||
extern int DeviceValuator;
|
extern int DeviceValuator;
|
||||||
|
@ -68,12 +69,8 @@ extern int DeviceKeyStateNotify;
|
||||||
extern int DeviceButtonStateNotify;
|
extern int DeviceButtonStateNotify;
|
||||||
extern int DeviceMappingNotify;
|
extern int DeviceMappingNotify;
|
||||||
extern int ChangeDeviceNotify;
|
extern int ChangeDeviceNotify;
|
||||||
|
extern int DevicePresenceNotify;
|
||||||
|
|
||||||
extern int RT_INPUTCLIENT;
|
extern int RT_INPUTCLIENT;
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* FIXME: in dix */
|
|
||||||
extern InputInfo inputInfo;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* EXGLOBALS_H */
|
#endif /* EXGLOBALS_H */
|
||||||
|
|
37
Xi/extinit.c
37
Xi/extinit.c
|
@ -166,6 +166,7 @@ Mask DeviceMappingNotifyMask;
|
||||||
Mask DeviceOwnerGrabButtonMask;
|
Mask DeviceOwnerGrabButtonMask;
|
||||||
Mask DeviceButtonGrabMask;
|
Mask DeviceButtonGrabMask;
|
||||||
Mask DeviceButtonMotionMask;
|
Mask DeviceButtonMotionMask;
|
||||||
|
Mask DevicePresenceNotifyMask;
|
||||||
|
|
||||||
int DeviceValuator;
|
int DeviceValuator;
|
||||||
int DeviceKeyPress;
|
int DeviceKeyPress;
|
||||||
|
@ -182,6 +183,7 @@ int DeviceKeyStateNotify;
|
||||||
int DeviceButtonStateNotify;
|
int DeviceButtonStateNotify;
|
||||||
int DeviceMappingNotify;
|
int DeviceMappingNotify;
|
||||||
int ChangeDeviceNotify;
|
int ChangeDeviceNotify;
|
||||||
|
int DevicePresenceNotify;
|
||||||
|
|
||||||
int RT_INPUTCLIENT;
|
int RT_INPUTCLIENT;
|
||||||
|
|
||||||
|
@ -202,8 +204,8 @@ Mask PropagateMask[MAX_DEVICES];
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static XExtensionVersion thisversion = { XI_Present,
|
static XExtensionVersion thisversion = { XI_Present,
|
||||||
XI_Add_XChangeDeviceControl_Major,
|
XI_Add_DevicePresenceNotify_Major,
|
||||||
XI_Add_XChangeDeviceControl_Minor
|
XI_Add_DevicePresenceNotify_Minor
|
||||||
};
|
};
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -648,6 +650,16 @@ SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to)
|
||||||
swapl(&to->time, n);
|
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.
|
* This function sets up extension event types and masks.
|
||||||
|
@ -674,6 +686,7 @@ FixExtensionEvents(ExtensionEntry * extEntry)
|
||||||
ChangeDeviceNotify = DeviceMappingNotify + 1;
|
ChangeDeviceNotify = DeviceMappingNotify + 1;
|
||||||
DeviceKeyStateNotify = ChangeDeviceNotify + 1;
|
DeviceKeyStateNotify = ChangeDeviceNotify + 1;
|
||||||
DeviceButtonStateNotify = DeviceKeyStateNotify + 1;
|
DeviceButtonStateNotify = DeviceKeyStateNotify + 1;
|
||||||
|
DevicePresenceNotify = DeviceButtonStateNotify + 1;
|
||||||
|
|
||||||
event_base[KeyClass] = DeviceKeyPress;
|
event_base[KeyClass] = DeviceKeyPress;
|
||||||
event_base[ButtonClass] = DeviceButtonPress;
|
event_base[ButtonClass] = DeviceButtonPress;
|
||||||
|
@ -746,6 +759,9 @@ FixExtensionEvents(ExtensionEntry * extEntry)
|
||||||
|
|
||||||
DeviceOwnerGrabButtonMask = GetNextExtEventMask();
|
DeviceOwnerGrabButtonMask = GetNextExtEventMask();
|
||||||
SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);
|
SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);
|
||||||
|
|
||||||
|
DevicePresenceNotifyMask = GetNextExtEventMask();
|
||||||
|
SetEventInfo(DevicePresenceNotifyMask, _devicePresence);
|
||||||
SetEventInfo(0, _noExtensionEvent);
|
SetEventInfo(0, _noExtensionEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,6 +802,7 @@ RestoreExtensionEvents(void)
|
||||||
ChangeDeviceNotify = 12;
|
ChangeDeviceNotify = 12;
|
||||||
DeviceKeyStateNotify = 13;
|
DeviceKeyStateNotify = 13;
|
||||||
DeviceButtonStateNotify = 13;
|
DeviceButtonStateNotify = 13;
|
||||||
|
DevicePresenceNotify = 14;
|
||||||
|
|
||||||
BadDevice = 0;
|
BadDevice = 0;
|
||||||
BadEvent = 1;
|
BadEvent = 1;
|
||||||
|
@ -823,6 +840,7 @@ IResetProc(ExtensionEntry * unused)
|
||||||
EventSwapVector[DeviceButtonStateNotify] = NotImplemented;
|
EventSwapVector[DeviceButtonStateNotify] = NotImplemented;
|
||||||
EventSwapVector[DeviceMappingNotify] = NotImplemented;
|
EventSwapVector[DeviceMappingNotify] = NotImplemented;
|
||||||
EventSwapVector[ChangeDeviceNotify] = NotImplemented;
|
EventSwapVector[ChangeDeviceNotify] = NotImplemented;
|
||||||
|
EventSwapVector[DevicePresenceNotify] = NotImplemented;
|
||||||
RestoreExtensionEvents();
|
RestoreExtensionEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,9 +875,7 @@ MakeDeviceTypeAtoms(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
*
|
|
||||||
* Return a DeviceIntPtr corresponding to a specified device id.
|
* 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;
|
DeviceIntPtr dev;
|
||||||
|
|
||||||
for (dev = inputInfo.devices; dev; dev = dev->next) {
|
for (dev = inputInfo.devices; dev; dev = dev->next) {
|
||||||
if (dev->id == id) {
|
if (dev->id == id)
|
||||||
if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id)
|
return dev;
|
||||||
return (NULL);
|
|
||||||
return (dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (dev = inputInfo.off_devices; dev; dev = dev->next) {
|
||||||
|
if (dev->id == id)
|
||||||
|
return dev;
|
||||||
}
|
}
|
||||||
return (NULL);
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
@ -74,6 +74,53 @@ SOFTWARE.
|
||||||
extern Mask ExtExclusiveMasks[];
|
extern Mask ExtExclusiveMasks[];
|
||||||
extern Mask ExtValidMasks[];
|
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.
|
* Handle requests from clients with a different byte order.
|
||||||
|
@ -131,6 +178,13 @@ ProcXSelectExtensionEvent(register ClientPtr client)
|
||||||
return Success;
|
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],
|
if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1],
|
||||||
stuff->count, tmp, NULL,
|
stuff->count, tmp, NULL,
|
||||||
X_SelectExtensionEvent)) != Success)
|
X_SelectExtensionEvent)) != Success)
|
||||||
|
|
Loading…
Reference in New Issue