diff options
author | Daniel Stone <daniel@fooishbar.org> | 2006-10-29 03:43:34 +0300 |
---|---|---|
committer | Daniel Stone <daniels@endtroducing.fooishbar.org> | 2006-10-29 03:43:34 +0300 |
commit | 96e32805d12fc36f0fa0926dbfb0dd8a5cadb739 (patch) | |
tree | 0a1a92660a406ac0631298d861a6da8258eb1ee0 /Xi | |
parent | 68f595ca6c7883e030947b7f95c50e92aa733f2b (diff) |
Xi: disallow changing core keyboard and pointer
Just short-circuit the change core keyboard/pointer requests.
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/chgkbd.c | 102 | ||||
-rw-r--r-- | Xi/chgkbd.h | 5 | ||||
-rw-r--r-- | Xi/chgptr.c | 91 | ||||
-rw-r--r-- | Xi/chgptr.h | 5 | ||||
-rw-r--r-- | Xi/extinit.c | 6 | ||||
-rw-r--r-- | Xi/stubs.c | 80 |
6 files changed, 4 insertions, 285 deletions
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/chgptr.c b/Xi/chgptr.c index b79909216..22c8a5f5e 100644 --- a/Xi/chgptr.c +++ b/Xi/chgptr.c @@ -101,97 +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; -} - -/*********************************************************************** - * - * 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/extinit.c b/Xi/extinit.c index c35a96416..454883762 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -465,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) diff --git a/Xi/stubs.c b/Xi/stubs.c index 28ecd8bd2..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. |