diff options
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/Makefile.am | 2 | ||||
-rw-r--r-- | Xi/chgdctl.c | 146 | ||||
-rw-r--r-- | Xi/chgkbd.c | 102 | ||||
-rw-r--r-- | Xi/chgkbd.h | 5 | ||||
-rw-r--r-- | Xi/chgprop.c | 9 | ||||
-rw-r--r-- | Xi/chgptr.c | 132 | ||||
-rw-r--r-- | Xi/chgptr.h | 5 | ||||
-rw-r--r-- | Xi/exevents.c | 75 | ||||
-rw-r--r-- | Xi/exglobals.h | 7 | ||||
-rw-r--r-- | Xi/extinit.c | 46 | ||||
-rw-r--r-- | Xi/getdctl.c | 128 | ||||
-rw-r--r-- | Xi/getdctl.h | 18 | ||||
-rw-r--r-- | Xi/getprop.c | 9 | ||||
-rw-r--r-- | Xi/getselev.c | 8 | ||||
-rw-r--r-- | Xi/listdev.c | 15 | ||||
-rw-r--r-- | Xi/selectev.c | 62 | ||||
-rw-r--r-- | Xi/stubs.c | 99 | ||||
-rw-r--r-- | Xi/ungrdevb.c | 7 | ||||
-rw-r--r-- | Xi/ungrdevk.c | 7 |
19 files changed, 474 insertions, 408 deletions
diff --git a/Xi/Makefile.am b/Xi/Makefile.am index 8eac59bb6..fbe438543 100644 --- a/Xi/Makefile.am +++ b/Xi/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = libXi.la -AM_CFLAGS = $(DIX_CFLAGS) @SERVER_DEFINES@ @LOADER_DEFINES@ +AM_CFLAGS = $(DIX_CFLAGS) libXi_la_SOURCES = \ allowev.c \ diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c index d507513a9..badd93822 100644 --- a/Xi/chgdctl.c +++ b/Xi/chgdctl.c @@ -66,6 +66,7 @@ SOFTWARE. #include "extnsionst.h" #include "extinit.h" /* LookupDeviceIntRec */ #include "exglobals.h" +#include "exevents.h" #include "chgdctl.h" @@ -98,12 +99,17 @@ int ProcXChangeDeviceControl(ClientPtr client) { unsigned len; - int i, status; + int i, status, ret = BadValue; DeviceIntPtr dev; xDeviceResolutionCtl *r; xChangeDeviceControlReply rep; AxisInfoPtr a; CARD32 *resolution; + xDeviceAbsCalibCtl *calib; + xDeviceAbsAreaCtl *area; + xDeviceCoreCtl *c; + xDeviceEnableCtl *e; + devicePresenceNotify dpn; REQUEST(xChangeDeviceControlReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq); @@ -111,9 +117,8 @@ ProcXChangeDeviceControl(ClientPtr client) len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2); dev = LookupDeviceIntRec(stuff->deviceid); if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadDevice); - return Success; + ret = BadDevice; + goto out; } rep.repType = X_Reply; @@ -126,25 +131,22 @@ ProcXChangeDeviceControl(ClientPtr client) r = (xDeviceResolutionCtl *) & stuff[1]; if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) || (len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, - 0, BadLength); - return Success; + ret = BadLength; + goto out; } if (!dev->valuator) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadMatch); - return Success; + ret = BadMatch; + goto out; } if ((dev->grab) && !SameClient(dev->grab, client)) { rep.status = AlreadyGrabbed; - WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); - return Success; + ret = Success; + goto out; } resolution = (CARD32 *) (r + 1); if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadValue); - return Success; + ret = BadValue; + goto out; } status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r); if (status == Success) { @@ -158,21 +160,119 @@ ProcXChangeDeviceControl(ClientPtr client) } for (i = 0; i < r->num_valuators; i++) (a++)->resolution = *resolution++; + + ret = Success; } else if (status == DeviceBusy) { rep.status = DeviceBusy; - WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); - return Success; + ret = Success; } else { - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, - BadMatch); - return Success; + ret = BadMatch; } break; + case DEVICE_ABS_CALIB: + calib = (xDeviceAbsCalibCtl *)&stuff[1]; + + if (calib->button_threshold < 0 || calib->button_threshold > 255) { + ret = BadValue; + goto out; + } + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) calib); + + if (status == Success) { + dev->absolute->min_x = calib->min_x; + dev->absolute->max_x = calib->max_x; + dev->absolute->min_y = calib->min_y; + dev->absolute->max_y = calib->max_y; + dev->absolute->flip_x = calib->flip_x; + dev->absolute->flip_y = calib->flip_y; + dev->absolute->rotation = calib->rotation; + dev->absolute->button_threshold = calib->button_threshold; + ret = Success; + } else if (status == DeviceBusy || status == BadValue) { + rep.status = status; + ret = Success; + } else { + ret = BadMatch; + } + + break; + case DEVICE_ABS_AREA: + area = (xDeviceAbsAreaCtl *)&stuff[1]; + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) area); + + if (status == Success) { + dev->absolute->offset_x = area->offset_x; + dev->absolute->offset_y = area->offset_y; + dev->absolute->width = area->width; + dev->absolute->height = area->height; + dev->absolute->screen = area->screen; + dev->absolute->following = area->following; + ret = Success; + } else if (status == DeviceBusy || status == BadValue) { + rep.status = status; + ret = Success; + } else { + ret = Success; + } + + break; + case DEVICE_CORE: + c = (xDeviceCoreCtl *)&stuff[1]; + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) c); + + if (status == Success) { + dev->coreEvents = c->status; + ret = Success; + } else if (status == DeviceBusy) { + rep.status = DeviceBusy; + ret = Success; + } else { + ret = BadMatch; + } + + break; + case DEVICE_ENABLE: + e = (xDeviceEnableCtl *)&stuff[1]; + + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e); + + if (status == Success) { + if (e->enable) + EnableDevice(dev); + else + DisableDevice(dev); + ret = Success; + } else if (status == DeviceBusy) { + rep.status = DeviceBusy; + ret = Success; + } else { + ret = BadMatch; + } + + break; default: - SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue); - return Success; + ret = BadValue; } - WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); + +out: + if (ret == Success) { + dpn.type = DevicePresenceNotify; + dpn.time = currentTime.milliseconds; + dpn.devchange = 1; + dpn.deviceid = dev->id; + dpn.control = stuff->control; + SendEventToAllWindows(dev, DevicePresenceNotifyMask, + (xEvent *) &dpn, 1); + + WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); + } + else { + SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, ret); + } + return Success; } diff --git a/Xi/chgkbd.c b/Xi/chgkbd.c index 289bd85af..8134b4060 100644 --- a/Xi/chgkbd.c +++ b/Xi/chgkbd.c @@ -64,7 +64,6 @@ SOFTWARE. #include "XIstubs.h" #include "globals.h" #include "extnsionst.h" -#include "extinit.h" /* LookupDeviceIntRec */ #include "exevents.h" #include "exglobals.h" @@ -99,107 +98,10 @@ SProcXChangeKeyboardDevice(register ClientPtr client) int ProcXChangeKeyboardDevice(register ClientPtr client) { - int i; - DeviceIntPtr xkbd = inputInfo.keyboard; - DeviceIntPtr dev; - FocusClassPtr xf = xkbd->focus; - FocusClassPtr df; - KeyClassPtr k; - xChangeKeyboardDeviceReply rep; - changeDeviceNotify ev; - REQUEST(xChangeKeyboardDeviceReq); REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq); - rep.repType = X_Reply; - rep.RepType = X_ChangeKeyboardDevice; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, - BadDevice); - return Success; - } - - k = dev->key; - if (k == NULL) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, - BadMatch); - return Success; - } - - if (((dev->grab) && !SameClient(dev->grab, client)) || - ((xkbd->grab) && !SameClient(xkbd->grab, client))) - rep.status = AlreadyGrabbed; - else if ((dev->sync.frozen && - dev->sync.other && !SameClient(dev->sync.other, client)) || - (xkbd->sync.frozen && - xkbd->sync.other && !SameClient(xkbd->sync.other, client))) - rep.status = GrabFrozen; - else { - if (ChangeKeyboardDevice(xkbd, dev) != Success) { - SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, - BadDevice); - return Success; - } - if (!dev->focus) - InitFocusClassDeviceStruct(dev); - if (!dev->kbdfeed) - InitKbdFeedbackClassDeviceStruct(dev, (BellProcPtr) NoopDDA, - (KbdCtrlProcPtr) NoopDDA); - df = dev->focus; - df->win = xf->win; - df->revert = xf->revert; - df->time = xf->time; - df->traceGood = xf->traceGood; - if (df->traceSize != xf->traceSize) { - Must_have_memory = TRUE; /* XXX */ - df->trace = (WindowPtr *) xrealloc(df->trace, - xf->traceSize * - sizeof(WindowPtr)); - Must_have_memory = FALSE; /* XXX */ - } - df->traceSize = xf->traceSize; - for (i = 0; i < df->traceSize; i++) - df->trace[i] = xf->trace[i]; - RegisterOtherDevice(xkbd); - RegisterKeyboardDevice(dev); - - ev.type = ChangeDeviceNotify; - ev.deviceid = stuff->deviceid; - ev.time = currentTime.milliseconds; - ev.request = NewKeyboard; - - SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1); - SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode, - k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + - 1, client); - - rep.status = 0; - } - - WriteReplyToClient(client, sizeof(xChangeKeyboardDeviceReply), &rep); + SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0, + BadDevice); return Success; } - -/*********************************************************************** - * - * This procedure writes the reply for the XChangeKeyboardDevice - * function, if the client and server have a different byte ordering. - * - */ - -void -SRepXChangeKeyboardDevice(ClientPtr client, int size, - xChangeKeyboardDeviceReply * rep) -{ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - WriteToClient(client, size, (char *)rep); -} diff --git a/Xi/chgkbd.h b/Xi/chgkbd.h index 7a883b7f0..5f9922336 100644 --- a/Xi/chgkbd.h +++ b/Xi/chgkbd.h @@ -36,9 +36,4 @@ int SProcXChangeKeyboardDevice(ClientPtr /* client */ int ProcXChangeKeyboardDevice(ClientPtr /* client */ ); -void SRepXChangeKeyboardDevice(ClientPtr /* client */ , - int /* size */ , - xChangeKeyboardDeviceReply * /* rep */ - ); - #endif /* CHGKBD_H */ diff --git a/Xi/chgprop.c b/Xi/chgprop.c index 52c38838d..bab4597b8 100644 --- a/Xi/chgprop.c +++ b/Xi/chgprop.c @@ -106,7 +106,7 @@ SProcXChangeDeviceDontPropagateList(register ClientPtr client) int ProcXChangeDeviceDontPropagateList(register ClientPtr client) { - int i; + int i, rc; WindowPtr pWin; struct tmask tmp[EMASKSIZE]; OtherInputMasks *others; @@ -121,11 +121,10 @@ ProcXChangeDeviceDontPropagateList(register ClientPtr client) return Success; } - pWin = (WindowPtr) LookupWindow(stuff->window, client); - if (!pWin) { - client->errorValue = stuff->window; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) { SendErrorToClient(client, IReqCode, X_ChangeDeviceDontPropagateList, 0, - BadWindow); + rc); return Success; } diff --git a/Xi/chgptr.c b/Xi/chgptr.c index f6f4b8bff..22c8a5f5e 100644 --- a/Xi/chgptr.c +++ b/Xi/chgptr.c @@ -101,138 +101,10 @@ SProcXChangePointerDevice(register ClientPtr client) int ProcXChangePointerDevice(register ClientPtr client) { - DeviceIntPtr xptr = inputInfo.pointer; - DeviceIntPtr dev; - ValuatorClassPtr v; - xChangePointerDeviceReply rep; - changeDeviceNotify ev; - REQUEST(xChangePointerDeviceReq); REQUEST_SIZE_MATCH(xChangePointerDeviceReq); - rep.repType = X_Reply; - rep.RepType = X_ChangePointerDevice; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, - BadDevice); - return Success; - } - - v = dev->valuator; - if (v == NULL || v->numAxes < 2 || - stuff->xaxis >= v->numAxes || stuff->yaxis >= v->numAxes) { - rep.status = -1; - SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch); - return Success; - } - - if (((dev->grab) && !SameClient(dev->grab, client)) || - ((xptr->grab) && !SameClient(xptr->grab, client))) - rep.status = AlreadyGrabbed; - else if ((dev->sync.frozen && - dev->sync.other && !SameClient(dev->sync.other, client)) || - (xptr->sync.frozen && - xptr->sync.other && !SameClient(xptr->sync.other, client))) - rep.status = GrabFrozen; - else { - if (ChangePointerDevice(xptr, dev, stuff->xaxis, stuff->yaxis) != - Success) { - SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, - BadDevice); - return Success; - } - if (dev->focus) - DeleteFocusClassDeviceStruct(dev); - if (!dev->button) - InitButtonClassDeviceStruct(dev, 0, NULL); - if (!dev->ptrfeed) - InitPtrFeedbackClassDeviceStruct(dev, (PtrCtrlProcPtr) NoopDDA); - RegisterOtherDevice(xptr); - RegisterPointerDevice(dev); - - ev.type = ChangeDeviceNotify; - ev.deviceid = stuff->deviceid; - ev.time = currentTime.milliseconds; - ev.request = NewPointer; - - SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1); - SendMappingNotify(MappingPointer, 0, 0, client); - - rep.status = 0; - } - - WriteReplyToClient(client, sizeof(xChangePointerDeviceReply), &rep); + SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, + BadDevice); return Success; } - -void -DeleteFocusClassDeviceStruct(DeviceIntPtr dev) -{ - xfree(dev->focus->trace); - xfree(dev->focus); - dev->focus = NULL; -} - -/*********************************************************************** - * - * Send an event to interested clients in all windows on all screens. - * - */ - -void -SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) -{ - int i; - WindowPtr pWin, p1; - - for (i = 0; i < screenInfo.numScreens; i++) { - pWin = WindowTable[i]; - (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id); - p1 = pWin->firstChild; - FindInterestedChildren(dev, p1, mask, ev, count); - } -} - -/*********************************************************************** - * - * Walk through the window tree, finding all clients that want to know - * about the ChangeDeviceNotify Event. - * - */ - -void -FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, - xEvent * ev, int count) -{ - WindowPtr p2; - - while (p1) { - p2 = p1->firstChild; - (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id); - FindInterestedChildren(dev, p2, mask, ev, count); - p1 = p1->nextSib; - } -} - -/*********************************************************************** - * - * This procedure writes the reply for the XChangePointerDevice - * function, if the client and server have a different byte ordering. - * - */ - -void -SRepXChangePointerDevice(ClientPtr client, int size, - xChangePointerDeviceReply * rep) -{ - register char n; - - swaps(&rep->sequenceNumber, n); - swapl(&rep->length, n); - WriteToClient(client, size, (char *)rep); -} diff --git a/Xi/chgptr.h b/Xi/chgptr.h index aeda822aa..fb3b5cc39 100644 --- a/Xi/chgptr.h +++ b/Xi/chgptr.h @@ -53,9 +53,4 @@ void FindInterestedChildren( /* FIXME: could be static? */ int /* count */ ); -void SRepXChangePointerDevice(ClientPtr /* client */ , - int /* size */ , - xChangePointerDeviceReply * /* rep */ - ); - #endif /* CHGPTR_H */ diff --git a/Xi/exevents.c b/Xi/exevents.c index 2932ab2d2..b7645f443 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -71,8 +71,7 @@ SOFTWARE. #include "exglobals.h" #include "dixevents.h" /* DeliverFocusedEvent */ #include "dixgrabs.h" /* CreateGrab() */ - -#include "chgptr.h" +#include "scrnintstr.h" #define WID(w) ((w) ? ((w)->drawable.id) : 0) #define AllModifiersMask ( \ @@ -302,7 +301,12 @@ _X_EXPORT void InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval, int resolution, int min_res, int max_res) { - register AxisInfoPtr ax = dev->valuator->axes + axnum; + register AxisInfoPtr ax; + + if (!dev || !dev->valuator) + return; + + ax = dev->valuator->axes + axnum; ax->min_value = minval; ax->max_value = maxval; @@ -501,6 +505,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, WindowPtr pWin, confineTo; CursorPtr cursor; GrabPtr grab; + int rc; if ((this_device_mode != GrabModeSync) && (this_device_mode != GrabModeAsync)) { @@ -520,15 +525,15 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, client->errorValue = ownerEvents; return BadValue; } - pWin = LookupWindow(grabWindow, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess); + if (rc != Success) + return rc; if (rconfineTo == None) confineTo = NullWindow; else { - confineTo = LookupWindow(rconfineTo, client); - if (!confineTo) - return BadWindow; + rc = dixLookupWindow(&confineTo, rconfineTo, client, DixUnknownAccess); + if (rc != Success) + return rc; } if (rcursor == None) cursor = NullCursor; @@ -558,6 +563,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, WindowPtr pWin; GrabPtr grab; KeyClassPtr k = dev->key; + int rc; if (k == NULL) return BadMatch; @@ -584,9 +590,9 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, client->errorValue = ownerEvents; return BadValue; } - pWin = LookupWindow(grabWindow, client); - if (!pWin) - return BadWindow; + rc = dixLookupWindow(&pWin, grabWindow, client, DixUnknownAccess); + if (rc != Success) + return rc; grab = CreateGrab(client->index, dev, pWin, mask, ownerEvents, this_device_mode, other_devices_mode, @@ -806,7 +812,7 @@ SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, } else effectiveFocus = pWin = inputFocus; } else - pWin = LookupWindow(dest, client); + dixLookupWindow(&pWin, dest, client, DixUnknownAccess); if (!pWin) return BadWindow; if ((propagate != xFalse) && (propagate != xTrue)) { @@ -898,7 +904,7 @@ SetModifierMapping(ClientPtr client, DeviceIntPtr dev, int len, int rlen, return MappingBusy; } else { for (i = 0; i < inputMapLen; i++) { - if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr) dev)) { + if (inputMap[i] && !LegalModifier(inputMap[i], dev)) { return MappingFailed; } } @@ -1209,3 +1215,44 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents) else return FALSE; } + +/*********************************************************************** + * + * Walk through the window tree, finding all clients that want to know + * about the Event. + * + */ + +void +FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, + xEvent * ev, int count) +{ + WindowPtr p2; + + while (p1) { + p2 = p1->firstChild; + (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id); + FindInterestedChildren(dev, p2, mask, ev, count); + p1 = p1->nextSib; + } +} + +/*********************************************************************** + * + * Send an event to interested clients in all windows on all screens. + * + */ + +void +SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) +{ + int i; + WindowPtr pWin, p1; + + for (i = 0; i < screenInfo.numScreens; i++) { + pWin = WindowTable[i]; + (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id); + p1 = pWin->firstChild; + FindInterestedChildren(dev, p1, mask, ev, count); + } +} 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..454883762 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 }; /********************************************************************** @@ -463,12 +465,6 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) else if (rep->RepType == X_GetDeviceMotionEvents) SRepXGetDeviceMotionEvents(client, len, (xGetDeviceMotionEventsReply *) rep); - else if (rep->RepType == X_ChangeKeyboardDevice) - SRepXChangeKeyboardDevice(client, len, - (xChangeKeyboardDeviceReply *) rep); - else if (rep->RepType == X_ChangePointerDevice) - SRepXChangePointerDevice(client, len, - (xChangePointerDeviceReply *) rep); else if (rep->RepType == X_GrabDevice) SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep); else if (rep->RepType == X_GetDeviceFocus) @@ -648,6 +644,17 @@ 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); + swaps(&to->control, n); +} + /************************************************************************ * * This function sets up extension event types and masks. @@ -674,6 +681,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 +754,9 @@ FixExtensionEvents(ExtensionEntry * extEntry) DeviceOwnerGrabButtonMask = GetNextExtEventMask(); SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton); + + DevicePresenceNotifyMask = GetNextExtEventMask(); + SetEventInfo(DevicePresenceNotifyMask, _devicePresence); SetEventInfo(0, _noExtensionEvent); } @@ -786,6 +797,7 @@ RestoreExtensionEvents(void) ChangeDeviceNotify = 12; DeviceKeyStateNotify = 13; DeviceButtonStateNotify = 13; + DevicePresenceNotify = 14; BadDevice = 0; BadEvent = 1; @@ -823,6 +835,7 @@ IResetProc(ExtensionEntry * unused) EventSwapVector[DeviceButtonStateNotify] = NotImplemented; EventSwapVector[DeviceMappingNotify] = NotImplemented; EventSwapVector[ChangeDeviceNotify] = NotImplemented; + EventSwapVector[DevicePresenceNotify] = NotImplemented; RestoreExtensionEvents(); } @@ -857,9 +870,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 +880,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/getdctl.c b/Xi/getdctl.c index c2b69fd71..d738ef83b 100644 --- a/Xi/getdctl.c +++ b/Xi/getdctl.c @@ -124,6 +124,30 @@ ProcXGetDeviceControl(ClientPtr client) total_length = sizeof(xDeviceResolutionState) + (3 * sizeof(int) * dev->valuator->numAxes); break; + case DEVICE_ABS_CALIB: + if (!dev->absolute) { + SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, + BadMatch); + return Success; + } + + total_length = sizeof(xDeviceAbsCalibCtl); + break; + case DEVICE_ABS_AREA: + if (!dev->absolute) { + SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, + BadMatch); + return Success; + } + + total_length = sizeof(xDeviceAbsAreaCtl); + break; + case DEVICE_CORE: + total_length = sizeof(xDeviceCoreCtl); + break; + case DEVICE_ENABLE: + total_length = sizeof(xDeviceEnableCtl); + break; default: SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue); return Success; @@ -140,6 +164,18 @@ ProcXGetDeviceControl(ClientPtr client) case DEVICE_RESOLUTION: CopySwapDeviceResolution(client, dev->valuator, buf, total_length); break; + case DEVICE_ABS_CALIB: + CopySwapDeviceAbsCalib(client, dev->absolute, buf); + break; + case DEVICE_ABS_AREA: + CopySwapDeviceAbsArea(client, dev->absolute, buf); + break; + case DEVICE_CORE: + CopySwapDeviceCore(client, dev, buf); + break; + case DEVICE_ENABLE: + CopySwapDeviceEnable(client, dev, buf); + break; default: break; } @@ -189,6 +225,98 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, } } +void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts, + char *buf) +{ + register char n; + xDeviceAbsCalibState *calib = (xDeviceAbsCalibState *) buf; + + calib->control = DEVICE_ABS_CALIB; + calib->length = sizeof(calib); + calib->min_x = dts->min_x; + calib->max_x = dts->max_x; + calib->min_y = dts->min_y; + calib->max_y = dts->max_y; + calib->flip_x = dts->flip_x; + calib->flip_y = dts->flip_y; + calib->rotation = dts->rotation; + calib->button_threshold = dts->button_threshold; + + if (client->swapped) { + swaps(&calib->control, n); + swaps(&calib->length, n); + swapl(&calib->min_x, n); + swapl(&calib->max_x, n); + swapl(&calib->min_y, n); + swapl(&calib->max_y, n); + swapl(&calib->flip_x, n); + swapl(&calib->flip_y, n); + swapl(&calib->rotation, n); + swapl(&calib->button_threshold, n); + } +} + +void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts, + char *buf) +{ + register char n; + xDeviceAbsAreaState *area = (xDeviceAbsAreaState *) buf; + + area->control = DEVICE_ABS_AREA; + area->length = sizeof(area); + area->offset_x = dts->offset_x; + area->offset_y = dts->offset_y; + area->width = dts->width; + area->height = dts->height; + area->screen = dts->screen; + area->following = dts->following; + + if (client->swapped) { + swaps(&area->control, n); + swaps(&area->length, n); + swapl(&area->offset_x, n); + swapl(&area->offset_y, n); + swapl(&area->width, n); + swapl(&area->height, n); + swapl(&area->screen, n); + swapl(&area->following, n); + } +} + +void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) +{ + register char n; + xDeviceCoreState *c = (xDeviceCoreState *) buf; + + c->control = DEVICE_CORE; + c->length = sizeof(c); + c->status = dev->coreEvents; + c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer); + + if (client->swapped) { + swaps(&c->control, n); + swaps(&c->length, n); + swaps(&c->status, n); + } +} + +void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf) +{ + register char n; + xDeviceEnableState *e = (xDeviceEnableState *) buf; + + e->control = DEVICE_ENABLE; + e->length = sizeof(e); + e->enable = dev->enabled; + + if (client->swapped) { + swaps(&e->control, n); + swaps(&e->length, n); + swaps(&e->enable, n); + } +} + + /*********************************************************************** * * This procedure writes the reply for the xGetDeviceControl function, diff --git a/Xi/getdctl.h b/Xi/getdctl.h index c7cfb19d2..36868d8be 100644 --- a/Xi/getdctl.h +++ b/Xi/getdctl.h @@ -42,6 +42,24 @@ void CopySwapDeviceResolution(ClientPtr /* client */ , int /* length */ ); +void CopySwapDeviceAbsCalib (ClientPtr client, + AbsoluteClassPtr dts, + char *buf); + +void CopySwapDeviceAbsArea (ClientPtr client, + AbsoluteClassPtr dts, + char *buf); + +void CopySwapDeviceCore(ClientPtr /* client */ , + DeviceIntPtr /* dev */ , + char * /* buf */ + ); + +void CopySwapDeviceEnable(ClientPtr /* client */ , + DeviceIntPtr /* dev */ , + char * /* buf */ + ); + void SRepXGetDeviceControl(ClientPtr /* client */ , int /* size */ , xGetDeviceControlReply * /* rep */ diff --git a/Xi/getprop.c b/Xi/getprop.c index 530841032..058c59514 100644 --- a/Xi/getprop.c +++ b/Xi/getprop.c @@ -100,7 +100,7 @@ int ProcXGetDeviceDontPropagateList(register ClientPtr client) { CARD16 count = 0; - int i; + int i, rc; XEventClass *buf = NULL, *tbuf; WindowPtr pWin; xGetDeviceDontPropagateListReply rep; @@ -115,11 +115,10 @@ ProcXGetDeviceDontPropagateList(register ClientPtr client) rep.length = 0; rep.count = 0; - pWin = (WindowPtr) LookupWindow(stuff->window, client); - if (!pWin) { - client->errorValue = stuff->window; + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) { SendErrorToClient(client, IReqCode, X_GetDeviceDontPropagateList, 0, - BadWindow); + rc); return Success; } diff --git a/Xi/getselev.c b/Xi/getselev.c index a84c33d23..533c66cd7 100644 --- a/Xi/getselev.c +++ b/Xi/getselev.c @@ -98,8 +98,7 @@ SProcXGetSelectedExtensionEvents(register ClientPtr client) int ProcXGetSelectedExtensionEvents(register ClientPtr client) { - int i; - int total_length = 0; + int i, rc, total_length = 0; xGetSelectedExtensionEventsReply rep; WindowPtr pWin; XEventClass *buf = NULL; @@ -118,9 +117,10 @@ ProcXGetSelectedExtensionEvents(register ClientPtr client) rep.this_client_count = 0; rep.all_clients_count = 0; - if (!(pWin = LookupWindow(stuff->window, client))) { + rc = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (rc != Success) { SendErrorToClient(client, IReqCode, X_GetSelectedExtensionEvents, 0, - BadWindow); + rc); return Success; } diff --git a/Xi/listdev.c b/Xi/listdev.c index 13e5ca729..02d55ad4c 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -96,7 +96,7 @@ int ProcXListInputDevices(register ClientPtr client) { xListInputDevicesReply rep; - int numdevs; + int numdevs = 0; int namesize = 1; /* need 1 extra byte for strcpy */ int size = 0; int total_length; @@ -115,12 +115,15 @@ ProcXListInputDevices(register ClientPtr client) rep.sequenceNumber = client->sequence; AddOtherInputDevices(); - numdevs = inputInfo.numDevices; - for (d = inputInfo.devices; d; d = d->next) + for (d = inputInfo.devices; d; d = d->next) { SizeDeviceInfo(d, &namesize, &size); - for (d = inputInfo.off_devices; d; d = d->next) + numdevs++; + } + for (d = inputInfo.off_devices; d; d = d->next) { SizeDeviceInfo(d, &namesize, &size); + numdevs++; + } total_length = numdevs * sizeof(xDeviceInfo) + size + namesize; devbuf = (char *)xalloc(total_length); @@ -241,6 +244,10 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes, dev->use = IsXKeyboard; else if (d == inputInfo.pointer) dev->use = IsXPointer; + else if (d->key && d->kbdfeed) + dev->use = IsXExtensionKeyboard; + else if (d->valuator && d->button) + dev->use = IsXExtensionPointer; else dev->use = IsXExtensionDevice; if (client->swapped) { diff --git a/Xi/selectev.c b/Xi/selectev.c index 3483804b1..8c893ca1e 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. @@ -123,14 +170,19 @@ ProcXSelectExtensionEvent(register ClientPtr client) return Success; } - pWin = (WindowPtr) LookupWindow(stuff->window, client); - if (!pWin) { - client->errorValue = stuff->window; - SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, - BadWindow); + ret = dixLookupWindow(&pWin, stuff->window, client, DixUnknownAccess); + if (ret != Success) { + SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0, ret); return Success; } + if (HandleDevicePresenceMask(client, pWin, (XEventClass *) & stuff[1], + &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) diff --git a/Xi/stubs.c b/Xi/stubs.c index 6b9e682b9..e2ed1ceff 100644 --- a/Xi/stubs.c +++ b/Xi/stubs.c @@ -68,86 +68,6 @@ SOFTWARE. /*********************************************************************** * - * Caller: ProcXChangeKeyboardDevice - * - * This procedure does the implementation-dependent portion of the work - * needed to change the keyboard device. - * - * The X keyboard device has a FocusRec. If the device that has been - * made into the new X keyboard did not have a FocusRec, - * ProcXChangeKeyboardDevice will allocate one for it. - * - * If you do not want clients to be able to focus the old X keyboard - * device, call DeleteFocusClassDeviceStruct to free the FocusRec. - * - * If you support input devices with keys that you do not want to be - * used as the X keyboard, you need to check for them here and return - * a BadDevice error. - * - * The default implementation is to do nothing (assume you do want - * clients to be able to focus the old X keyboard). The commented-out - * sample code shows what you might do if you don't want the default. - * - */ - -int -ChangeKeyboardDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev) -{ - /*********************************************************************** - DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c * - **********************************************************************/ - return BadMatch; -} - -/*********************************************************************** - * - * Caller: ProcXChangePointerDevice - * - * This procedure does the implementation-dependent portion of the work - * needed to change the pointer device. - * - * The X pointer device does not have a FocusRec. If the device that - * has been made into the new X pointer had a FocusRec, - * ProcXChangePointerDevice will free it. - * - * If you want clients to be able to focus the old pointer device that - * has now become accessible through the input extension, you need to - * add a FocusRec to it here. - * - * The XChangePointerDevice protocol request also allows the client - * to choose which axes of the new pointer device are used to move - * the X cursor in the X- and Y- directions. If the axes are different - * than the default ones, you need to keep track of that here. - * - * If you support input devices with valuators that you do not want to be - * used as the X pointer, you need to check for them here and return a - * BadDevice error. - * - * The default implementation is to do nothing (assume you don't want - * clients to be able to focus the old X pointer). The commented-out - * sample code shows what you might do if you don't want the default. - * - */ - -int -ChangePointerDevice(DeviceIntPtr old_dev, - DeviceIntPtr new_dev, unsigned char x, unsigned char y) -{ - /*********************************************************************** - InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr* - - x_axis = x; * keep track of new x-axis* - y_axis = y; * keep track of new y-axis* - if (x_axis != 0 || y_axis != 1) - axes_changed = TRUE; * remember axes have changed* - else - axes_changed = FALSE; - *************************************************************************/ - return BadMatch; -} - -/*********************************************************************** - * * Caller: ProcXCloseDevice * * Take care of implementation-dependent details of closing a device. @@ -287,7 +207,26 @@ ChangeDeviceControl(register ClientPtr client, DeviceIntPtr dev, switch (control->control) { case DEVICE_RESOLUTION: return (BadMatch); + case DEVICE_ABS_CALIB: + case DEVICE_ABS_AREA: + return (BadMatch); + case DEVICE_CORE: + return (BadMatch); default: return (BadMatch); } } + + +/**************************************************************************** + * + * Caller: configAddDevice (and others) + * + * Add a new device with the specified options. + * + */ +int +NewInputDeviceRequest(InputOption *options) +{ + return BadValue; +} diff --git a/Xi/ungrdevb.c b/Xi/ungrdevb.c index 64bb213f5..8db9307ce 100644 --- a/Xi/ungrdevb.c +++ b/Xi/ungrdevb.c @@ -105,6 +105,7 @@ ProcXUngrabDeviceButton(ClientPtr client) DeviceIntPtr mdev; WindowPtr pWin; GrabRec temporaryGrab; + int rc; REQUEST(xUngrabDeviceButtonReq); REQUEST_SIZE_MATCH(xUngrabDeviceButtonReq); @@ -134,9 +135,9 @@ ProcXUngrabDeviceButton(ClientPtr client) } else mdev = (DeviceIntPtr) LookupKeyboardDevice(); - pWin = LookupWindow(stuff->grabWindow, client); - if (!pWin) { - SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, BadWindow); + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess); + if (rc != Success) { + SendErrorToClient(client, IReqCode, X_UngrabDeviceButton, 0, rc); return Success; } diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c index 0a6b3b619..ebb83bce7 100644 --- a/Xi/ungrdevk.c +++ b/Xi/ungrdevk.c @@ -105,6 +105,7 @@ ProcXUngrabDeviceKey(ClientPtr client) DeviceIntPtr mdev; WindowPtr pWin; GrabRec temporaryGrab; + int rc; REQUEST(xUngrabDeviceKeyReq); REQUEST_SIZE_MATCH(xUngrabDeviceKeyReq); @@ -133,9 +134,9 @@ ProcXUngrabDeviceKey(ClientPtr client) } else mdev = (DeviceIntPtr) LookupKeyboardDevice(); - pWin = LookupWindow(stuff->grabWindow, client); - if (!pWin) { - SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, BadWindow); + rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess); + if (rc != Success) { + SendErrorToClient(client, IReqCode, X_UngrabDeviceKey, 0, rc); return Success; } if (((stuff->key > dev->key->curKeySyms.maxKeyCode) || |