summaryrefslogtreecommitdiff
path: root/Xi/extinit.c
diff options
context:
space:
mode:
Diffstat (limited to 'Xi/extinit.c')
-rw-r--r--Xi/extinit.c306
1 files changed, 296 insertions, 10 deletions
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 2ffdafbc1..6aa1ece29 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -63,6 +63,8 @@ SOFTWARE.
#include "extnsionst.h" /* extension entry */
#include <X11/extensions/XI.h>
#include <X11/extensions/XIproto.h>
+#include <X11/extensions/geproto.h>
+#include "geext.h" /* extension interfaces for ge */
#include "dixevents.h"
#include "exevents.h"
@@ -73,35 +75,46 @@ SOFTWARE.
/* modules local to Xi */
#include "allowev.h"
+#include "chaccess.h"
+#include "chdevcur.h"
#include "chgdctl.h"
+#include "chdevhier.h"
#include "chgfctl.h"
#include "chgkbd.h"
#include "chgprop.h"
#include "chgptr.h"
#include "closedev.h"
+#include "extgrbdev.h"
#include "devbell.h"
+#include "fakedevdata.h"
#include "getbmap.h"
#include "getbmap.h"
+#include "getcptr.h"
#include "getdctl.h"
#include "getfctl.h"
#include "getfocus.h"
#include "getkmap.h"
#include "getmmap.h"
+#include "getpairp.h"
#include "getprop.h"
#include "getselev.h"
#include "getvers.h"
#include "getvers.h"
+#include "grabacc.h"
#include "grabdev.h"
#include "grabdevb.h"
#include "grabdevk.h"
#include "gtmotion.h"
#include "listdev.h"
#include "opendev.h"
+#include "qryacces.c"
+#include "querydp.h"
#include "queryst.h"
#include "selectev.h"
#include "sendexev.h"
#include "chgkmap.h"
#include "setbmap.h"
+#include "setcptr.h"
#include "setdval.h"
#include "setfocus.h"
#include "setmmap.h"
@@ -109,12 +122,26 @@ SOFTWARE.
#include "ungrdev.h"
#include "ungrdevb.h"
#include "ungrdevk.h"
+#include "warpdevp.h"
+#include "xiselev.h"
+
static Mask lastExtEventMask = 1;
int ExtEventIndex;
Mask ExtValidMasks[EMASKSIZE];
Mask ExtExclusiveMasks[EMASKSIZE];
+
+/**
+ * Filters for various generic events.
+ * Evtype is index, mask is value at index.
+ */
+static Mask xi_filters[4] = {
+ XI_DeviceHierarchyChangedMask,
+ XI_DeviceClassesChangedMask,
+ XI_RawDeviceEventMask,
+};
+
static struct dev_type
{
Atom type;
@@ -166,6 +193,8 @@ Mask DeviceOwnerGrabButtonMask;
Mask DeviceButtonGrabMask;
Mask DeviceButtonMotionMask;
Mask DevicePresenceNotifyMask;
+Mask DeviceEnterWindowMask;
+Mask DeviceLeaveWindowMask;
int DeviceValuator;
int DeviceKeyPress;
@@ -183,6 +212,8 @@ int DeviceButtonStateNotify;
int DeviceMappingNotify;
int ChangeDeviceNotify;
int DevicePresenceNotify;
+int DeviceEnterNotify;
+int DeviceLeaveNotify;
int RT_INPUTCLIENT;
@@ -203,10 +234,11 @@ Mask PropagateMask[MAX_DEVICES];
*/
static XExtensionVersion thisversion = { XI_Present,
- XI_Add_DevicePresenceNotify_Major,
- XI_Add_DevicePresenceNotify_Minor
+ XI_2_Major,
+ XI_2_Minor
};
+
/*************************************************************************
*
* ProcIDispatch - main dispatch routine for requests to this extension.
@@ -288,13 +320,41 @@ ProcIDispatch(ClientPtr client)
return (ProcXGetDeviceControl(client));
else if (stuff->data == X_ChangeDeviceControl)
return (ProcXChangeDeviceControl(client));
-
+ else if (stuff->data == X_QueryDevicePointer)
+ return (ProcXQueryDevicePointer(client));
+ else if (stuff->data == X_WarpDevicePointer)
+ return (ProcXWarpDevicePointer(client));
+ else if (stuff->data == X_ChangeDeviceCursor)
+ return (ProcXChangeDeviceCursor(client));
+ else if (stuff->data == X_ChangeDeviceHierarchy)
+ return (ProcXChangeDeviceHierarchy(client));
+ else if (stuff->data == X_XiSelectEvent)
+ return (ProcXiSelectEvent(client));
+ else if (stuff->data == X_GrabAccessControl)
+ return (ProcXGrabAccessControl(client));
+ else if (stuff->data == X_ChangeWindowAccess)
+ return (ProcXChangeWindowAccess(client));
+ else if (stuff->data == X_QueryWindowAccess)
+ return ProcXQueryWindowAccess(client);
+ else if (stuff->data == X_SetClientPointer)
+ return ProcXSetClientPointer(client);
+ else if (stuff->data == X_GetClientPointer)
+ return ProcXGetClientPointer(client);
+ else if (stuff->data == X_GetPairedPointer)
+ return ProcXGetPairedPointer(client);
+ else if (stuff->data == X_FakeDeviceData)
+ return ProcXFakeDeviceData(client);
+ else if (stuff->data == X_ExtendedGrabDevice)
+ return ProcXExtendedGrabDevice(client);
+ else {
+ SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
+ }
return (BadRequest);
}
/*******************************************************************************
*
- * SProcXDispatch
+ * SProcXDispatch
*
* Main swapped dispatch routine for requests to this extension.
* This routine is used if server and client do not have the same byte ordering.
@@ -375,7 +435,35 @@ SProcIDispatch(ClientPtr client)
return (SProcXGetDeviceControl(client));
else if (stuff->data == X_ChangeDeviceControl)
return (SProcXChangeDeviceControl(client));
-
+ else if (stuff->data == X_QueryDevicePointer)
+ return (SProcXQueryDevicePointer(client));
+ else if (stuff->data == X_WarpDevicePointer)
+ return (SProcXWarpDevicePointer(client));
+ else if (stuff->data == X_ChangeDeviceCursor)
+ return (SProcXChangeDeviceCursor(client));
+ else if (stuff->data == X_ChangeDeviceHierarchy)
+ return (SProcXChangeDeviceHierarchy(client));
+ else if (stuff->data == X_XiSelectEvent)
+ return (SProcXiSelectEvent(client));
+ else if (stuff->data == X_GrabAccessControl)
+ return (SProcXGrabAccessControl(client));
+ else if (stuff->data == X_ChangeWindowAccess)
+ return (SProcXChangeWindowAccess(client));
+ else if (stuff->data == X_QueryWindowAccess)
+ return SProcXQueryWindowAccess(client);
+ else if (stuff->data == X_SetClientPointer)
+ return SProcXSetClientPointer(client);
+ else if (stuff->data == X_GetClientPointer)
+ return SProcXGetClientPointer(client);
+ else if (stuff->data == X_GetPairedPointer)
+ return SProcXGetPairedPointer(client);
+ else if (stuff->data == X_FakeDeviceData)
+ return SProcXFakeDeviceData(client);
+ else if (stuff->data == X_ExtendedGrabDevice)
+ return SProcXExtendedGrabDevice(client);
+ else {
+ SendErrorToClient(client, IReqCode, stuff->data, 0, BadRequest);
+ }
return (BadRequest);
}
@@ -445,6 +533,21 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep)
else if (rep->RepType == X_ChangeDeviceControl)
SRepXChangeDeviceControl(client, len,
(xChangeDeviceControlReply *) rep);
+ else if (rep->RepType == X_QueryDevicePointer)
+ SRepXQueryDevicePointer(client, len,
+ (xQueryDevicePointerReply *) rep);
+ else if (rep->RepType == X_GrabAccessControl)
+ SRepXGrabAccessControl(client, len,
+ (xGrabAccessControlReply*) rep);
+ else if (rep->RepType == X_QueryWindowAccess)
+ SRepXQueryWindowAccess(client, len,
+ (xQueryWindowAccessReply*) rep);
+ else if (rep->RepType == X_GetClientPointer)
+ SRepXGetClientPointer(client, len, (xGetClientPointerReply*) rep);
+ else if (rep->RepType == X_GetPairedPointer)
+ SRepXGetPairedPointer(client, len, (xGetPairedPointerReply*) rep);
+ else if (rep->RepType == X_ExtendedGrabDevice)
+ SRepXExtendedGrabDevice(client, len, (xExtendedGrabDeviceReply*) rep);
else {
FatalError("XINPUT confused sending swapped reply");
}
@@ -550,6 +653,97 @@ SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to
swaps(&to->control, n);
}
+static void
+SDeviceEnterNotifyEvent (deviceEnterNotify *from, deviceEnterNotify *to)
+{
+ char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ swapl(&to->time, n);
+}
+
+static void
+SDeviceLeaveNotifyEvent (deviceLeaveNotify *from, deviceLeaveNotify *to)
+{
+ char n;
+
+ *to = *from;
+ swaps(&to->sequenceNumber,n);
+ swapl(&to->time, n);
+ swapl(&to->root, n);
+ swapl(&to->event, n);
+ swapl(&to->child, n);
+ swaps(&to->rootX, n);
+ swaps(&to->rootY, n);
+ swaps(&to->eventX, n);
+ swaps(&to->eventY, n);
+}
+
+static void
+SRawDeviceEvent(rawDeviceEvent* from, rawDeviceEvent *to)
+{
+ char n;
+ int i;
+ CARD32* valptr;
+
+
+ *to = *from;
+ swaps(&to->sequenceNumber, n);
+ swapl(&to->length, n);
+ swapl(&to->evtype, n);
+ valptr = &to->valuator0;
+ for (i = 0; i < from->num_valuators; i++, valptr++)
+ swapl(valptr, n);
+}
+
+static void
+SDeviceClassesChangedEvent(deviceClassesChangedEvent* from,
+ deviceClassesChangedEvent* to)
+{
+ char n;
+ int i, j;
+ xAnyClassPtr any;
+
+ *to = *from;
+ memcpy(&to[1], &from[1], from->length * 4);
+
+ swaps(&to->sequenceNumber, n);
+ swapl(&to->length, n);
+ swapl(&to->time, n);
+
+ /* now swap the actual classes */
+ any = (xAnyClassPtr)&to[1];
+ for (i = 0; i < to->num_classes; i++)
+ {
+ switch(any->class)
+ {
+ case KeyClass:
+ swaps(&((xKeyInfoPtr)any)->num_keys, n);
+ break;
+ case ButtonClass:
+ swaps(&((xButtonInfoPtr)any)->num_buttons, n);
+ break;
+ case ValuatorClass:
+ {
+ xValuatorInfoPtr v = (xValuatorInfoPtr)any;
+ xAxisInfoPtr a = (xAxisInfoPtr)&v[1];
+
+ swapl(&v->motion_buffer_size, n);
+ for (j = 0; j < v->num_axes; j++)
+ {
+ swapl(&a->min_value, n);
+ swapl(&a->max_value, n);
+ swapl(&a->resolution, n);
+ a++;
+ }
+ }
+ break;
+ }
+ any = (xAnyClassPtr)((char*)any + any->length);
+ }
+}
+
/**************************************************************************
*
* Allow the specified event to have its propagation suppressed.
@@ -596,7 +790,7 @@ GetNextExtEventMask(void)
*
* Since extension event types will never be less than 64, we can use
* 0-63 in the EventInfo array as the "type" to be used to look up this
- * mask. This means that the corresponding macros such as
+ * mask. This means that the corresponding macros such as
* DevicePointerMotionHint must have access to the same constants.
*
*/
@@ -634,13 +828,16 @@ SetExclusiveAccess(Mask mask)
static void
SetMaskForExtEvent(Mask mask, int event)
{
+ int i;
EventInfo[ExtEventIndex].mask = mask;
EventInfo[ExtEventIndex++].type = event;
if ((event < LASTEvent) || (event >= 128))
FatalError("MaskForExtensionEvent: bogus event number");
- SetMaskForEvent(mask, event);
+
+ for (i = 0; i < MAX_DEVICES; i++)
+ SetMaskForEvent(i, mask, event);
}
/************************************************************************
@@ -670,6 +867,8 @@ FixExtensionEvents(ExtensionEntry * extEntry)
DeviceKeyStateNotify = ChangeDeviceNotify + 1;
DeviceButtonStateNotify = DeviceKeyStateNotify + 1;
DevicePresenceNotify = DeviceButtonStateNotify + 1;
+ DeviceEnterNotify = DevicePresenceNotify + 1;
+ DeviceLeaveNotify = DeviceEnterNotify + 1;
event_base[KeyClass] = DeviceKeyPress;
event_base[ButtonClass] = DeviceButtonPress;
@@ -721,8 +920,20 @@ FixExtensionEvents(ExtensionEntry * extEntry)
SetEventInfo(GetNextExtEventMask(), _deviceButton3Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton4Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton5Motion);
+
+ /* If DeviceButtonMotionMask is != ButtonMotionMask, event delivery
+ * breaks down. The device needs the dev->button->motionMask. If DBMM is
+ * the same as BMM, we can ensure that both core and device events can be
+ * delivered, without the need for extra structures in the DeviceIntRec.
+ */
DeviceButtonMotionMask = GetNextExtEventMask();
SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion);
+ if (DeviceButtonMotionMask != ButtonMotionMask)
+ {
+ /* This should never happen, but if it does, hide under the
+ * bed and cry for help. */
+ ErrorF("[Xi] DeviceButtonMotionMask != ButtonMotionMask. Trouble!\n");
+ }
DeviceFocusChangeMask = GetNextExtEventMask();
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn);
@@ -745,12 +956,21 @@ FixExtensionEvents(ExtensionEntry * extEntry)
DevicePresenceNotifyMask = GetNextExtEventMask();
SetEventInfo(DevicePresenceNotifyMask, _devicePresence);
+
+ DeviceEnterWindowMask = GetNextExtEventMask();
+ SetMaskForExtEvent(DeviceEnterWindowMask, DeviceEnterNotify);
+ AllowPropagateSuppress(DeviceEnterWindowMask);
+
+ DeviceLeaveWindowMask = GetNextExtEventMask();
+ SetMaskForExtEvent(DeviceLeaveWindowMask, DeviceLeaveNotify);
+ AllowPropagateSuppress(DeviceLeaveWindowMask);
+
SetEventInfo(0, _noExtensionEvent);
}
/************************************************************************
*
- * This function restores extension event types and masks to their
+ * This function restores extension event types and masks to their
* initial state.
*
*/
@@ -758,13 +978,16 @@ FixExtensionEvents(ExtensionEntry * extEntry)
static void
RestoreExtensionEvents(void)
{
- int i;
+ int i, j;
IReqCode = 0;
for (i = 0; i < ExtEventIndex - 1; i++) {
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
- SetMaskForEvent(0, EventInfo[i].type);
+ {
+ for (j = 0; j < MAX_DEVICES; j++)
+ SetMaskForEvent(j, 0, EventInfo[i].type);
+ }
EventInfo[i].mask = 0;
EventInfo[i].type = 0;
}
@@ -786,6 +1009,8 @@ RestoreExtensionEvents(void)
DeviceKeyStateNotify = 13;
DeviceButtonStateNotify = 13;
DevicePresenceNotify = 14;
+ DeviceEnterNotify = 15;
+ DeviceLeaveNotify = 16;
BadDevice = 0;
BadEvent = 1;
@@ -824,9 +1049,27 @@ IResetProc(ExtensionEntry * unused)
EventSwapVector[DeviceMappingNotify] = NotImplemented;
EventSwapVector[ChangeDeviceNotify] = NotImplemented;
EventSwapVector[DevicePresenceNotify] = NotImplemented;
+ EventSwapVector[DeviceEnterNotify] = NotImplemented;
+ EventSwapVector[DeviceLeaveNotify] = NotImplemented;
RestoreExtensionEvents();
}
+/*****************************************************************
+ *
+ * Returns TRUE if the device has some sort of pointer type.
+ *
+ */
+
+_X_EXPORT Bool
+DeviceIsPointerType(DeviceIntPtr dev)
+{
+ if (dev_type[1].type == dev->type)
+ return TRUE;
+
+ return FALSE;
+}
+
+
/***********************************************************************
*
* Assign an id and type to an input device.
@@ -909,11 +1152,48 @@ SEventIDispatch(xEvent * from, xEvent * to)
DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify);
else if (type == DevicePresenceNotify)
DO_SWAP(SDevicePresenceNotifyEvent, devicePresenceNotify);
+ else if (type == DeviceEnterNotify)
+ DO_SWAP(SDeviceEnterNotifyEvent, deviceEnterNotify);
+ else if (type == DeviceLeaveNotify)
+ DO_SWAP(SDeviceLeaveNotifyEvent, deviceLeaveNotify);
else {
FatalError("XInputExtension: Impossible event!\n");
}
}
+/****************************************************************
+ *
+ * EventSwap for generic events coming from the GE extension.
+ */
+
+static void
+XIGEEventSwap(xGenericEvent* from, xGenericEvent* to)
+{
+ int n;
+
+ swaps(&from->sequenceNumber, n);
+ switch(from->evtype)
+ {
+ case XI_RawDeviceEvent:
+ SRawDeviceEvent((rawDeviceEvent*)from, (rawDeviceEvent*)to);
+ break;
+ case XI_DeviceClassesChangedNotify:
+ SDeviceClassesChangedEvent((deviceClassesChangedEvent*)from,
+ (deviceClassesChangedEvent*)to);
+ break;
+ }
+}
+
+/**
+ * EventFill to fill various fields for events before they are delivered to
+ * the client.
+ */
+static void
+XIGEEventFill(xGenericEvent* ev, DeviceIntPtr pDev,
+ WindowPtr pWin, GrabPtr grab)
+{
+}
+
/**********************************************************************
*
* IExtensionInit - initialize the input extension.
@@ -956,6 +1236,12 @@ XInputExtensionInit(void)
EventSwapVector[DeviceMappingNotify] = SEventIDispatch;
EventSwapVector[ChangeDeviceNotify] = SEventIDispatch;
EventSwapVector[DevicePresenceNotify] = SEventIDispatch;
+ EventSwapVector[DeviceEnterNotify] = SEventIDispatch;
+ EventSwapVector[DeviceLeaveNotify] = SEventIDispatch;
+
+ /* init GE events */
+ GERegisterExtension(IReqCode, XIGEEventSwap, XIGEEventFill);
+ SetGenericFilter(IReqCode, xi_filters);
} else {
FatalError("IExtensionInit: AddExtensions failed\n");
}