diff options
author | Adam Jackson <ajax@benzedrine.nwnk.net> | 2007-03-18 17:39:08 -0400 |
---|---|---|
committer | Adam Jackson <ajax@benzedrine.nwnk.net> | 2007-03-25 21:18:39 -0400 |
commit | e88fa75c9b468b88bb7b87b1da235c6eb2fe8164 (patch) | |
tree | ec72adcd230712e9be571c230e88813c45da0c48 /Xi | |
parent | 4b5802ddbd45271be3cadeae0a83a6742df2515b (diff) |
Static cleanup on Xi/
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/chgfctl.c | 261 | ||||
-rw-r--r-- | Xi/chgfctl.h | 42 | ||||
-rw-r--r-- | Xi/chgptr.h | 8 | ||||
-rw-r--r-- | Xi/closedev.c | 92 | ||||
-rw-r--r-- | Xi/closedev.h | 10 | ||||
-rw-r--r-- | Xi/exevents.c | 58 | ||||
-rw-r--r-- | Xi/exglobals.h | 1 | ||||
-rw-r--r-- | Xi/extinit.c | 380 | ||||
-rw-r--r-- | Xi/getdctl.c | 213 | ||||
-rw-r--r-- | Xi/getdctl.h | 24 | ||||
-rw-r--r-- | Xi/getfctl.c | 198 | ||||
-rw-r--r-- | Xi/getfctl.h | 30 | ||||
-rw-r--r-- | Xi/listdev.c | 224 | ||||
-rw-r--r-- | Xi/listdev.h | 38 |
14 files changed, 713 insertions, 866 deletions
diff --git a/Xi/chgfctl.c b/Xi/chgfctl.c index d0acc593b..82616c694 100644 --- a/Xi/chgfctl.c +++ b/Xi/chgfctl.c @@ -89,137 +89,13 @@ SProcXChangeFeedbackControl(register ClientPtr client) return (ProcXChangeFeedbackControl(client)); } -/*********************************************************************** - * - * Change the control attributes. - * - */ - -int -ProcXChangeFeedbackControl(ClientPtr client) -{ - unsigned len; - DeviceIntPtr dev; - KbdFeedbackPtr k; - PtrFeedbackPtr p; - IntegerFeedbackPtr i; - StringFeedbackPtr s; - BellFeedbackPtr b; - LedFeedbackPtr l; - - REQUEST(xChangeFeedbackControlReq); - REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); - - len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2); - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, - BadDevice); - return Success; - } - - switch (stuff->feedbackid) { - case KbdFeedbackClass: - if (len != (sizeof(xKbdFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (k = dev->kbdfeed; k; k = k->next) - if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) { - ChangeKbdFeedback(client, dev, stuff->mask, k, - (xKbdFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case PtrFeedbackClass: - if (len != (sizeof(xPtrFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (p = dev->ptrfeed; p; p = p->next) - if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) { - ChangePtrFeedback(client, dev, stuff->mask, p, - (xPtrFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case StringFeedbackClass: - { - register char n; - xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]); - - if (client->swapped) { - swaps(&f->num_keysyms, n); - } - if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (s = dev->stringfeed; s; s = s->next) - if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) { - ChangeStringFeedback(client, dev, stuff->mask, s, - (xStringFeedbackCtl *) & stuff[1]); - return Success; - } - break; - } - case IntegerFeedbackClass: - if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (i = dev->intfeed; i; i = i->next) - if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) { - ChangeIntegerFeedback(client, dev, stuff->mask, i, - (xIntegerFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case LedFeedbackClass: - if (len != (sizeof(xLedFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (l = dev->leds; l; l = l->next) - if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) { - ChangeLedFeedback(client, dev, stuff->mask, l, - (xLedFeedbackCtl *) & stuff[1]); - return Success; - } - break; - case BellFeedbackClass: - if (len != (sizeof(xBellFeedbackCtl) >> 2)) { - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, - 0, BadLength); - return Success; - } - for (b = dev->bell; b; b = b->next) - if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) { - ChangeBellFeedback(client, dev, stuff->mask, b, - (xBellFeedbackCtl *) & stuff[1]); - return Success; - } - break; - default: - break; - } - - SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch); - return Success; -} - /****************************************************************************** * * This procedure changes KbdFeedbackClass data. * */ -int +static int ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, KbdFeedbackPtr k, xKbdFeedbackCtl * f) { @@ -351,7 +227,7 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, * */ -int +static int ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, PtrFeedbackPtr p, xPtrFeedbackCtl * f) { @@ -422,7 +298,7 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, * */ -int +static int ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, IntegerFeedbackPtr i, xIntegerFeedbackCtl * f) @@ -445,7 +321,7 @@ ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev, * */ -int +static int ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, StringFeedbackPtr s, xStringFeedbackCtl * f) @@ -495,7 +371,7 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, * */ -int +static int ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, BellFeedbackPtr b, xBellFeedbackCtl * f) @@ -560,7 +436,7 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, * */ -int +static int ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, LedFeedbackPtr l, xLedFeedbackCtl * f) { @@ -585,3 +461,128 @@ ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, return Success; } + +/*********************************************************************** + * + * Change the control attributes. + * + */ + +int +ProcXChangeFeedbackControl(ClientPtr client) +{ + unsigned len; + DeviceIntPtr dev; + KbdFeedbackPtr k; + PtrFeedbackPtr p; + IntegerFeedbackPtr i; + StringFeedbackPtr s; + BellFeedbackPtr b; + LedFeedbackPtr l; + + REQUEST(xChangeFeedbackControlReq); + REQUEST_AT_LEAST_SIZE(xChangeFeedbackControlReq); + + len = stuff->length - (sizeof(xChangeFeedbackControlReq) >> 2); + dev = LookupDeviceIntRec(stuff->deviceid); + if (dev == NULL) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, + BadDevice); + return Success; + } + + switch (stuff->feedbackid) { + case KbdFeedbackClass: + if (len != (sizeof(xKbdFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (k = dev->kbdfeed; k; k = k->next) + if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) { + ChangeKbdFeedback(client, dev, stuff->mask, k, + (xKbdFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case PtrFeedbackClass: + if (len != (sizeof(xPtrFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (p = dev->ptrfeed; p; p = p->next) + if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) { + ChangePtrFeedback(client, dev, stuff->mask, p, + (xPtrFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case StringFeedbackClass: + { + register char n; + xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]); + + if (client->swapped) { + swaps(&f->num_keysyms, n); + } + if (len != ((sizeof(xStringFeedbackCtl) >> 2) + f->num_keysyms)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (s = dev->stringfeed; s; s = s->next) + if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) { + ChangeStringFeedback(client, dev, stuff->mask, s, + (xStringFeedbackCtl *) & stuff[1]); + return Success; + } + break; + } + case IntegerFeedbackClass: + if (len != (sizeof(xIntegerFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (i = dev->intfeed; i; i = i->next) + if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) { + ChangeIntegerFeedback(client, dev, stuff->mask, i, + (xIntegerFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case LedFeedbackClass: + if (len != (sizeof(xLedFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (l = dev->leds; l; l = l->next) + if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) { + ChangeLedFeedback(client, dev, stuff->mask, l, + (xLedFeedbackCtl *) & stuff[1]); + return Success; + } + break; + case BellFeedbackClass: + if (len != (sizeof(xBellFeedbackCtl) >> 2)) { + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, + 0, BadLength); + return Success; + } + for (b = dev->bell; b; b = b->next) + if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) { + ChangeBellFeedback(client, dev, stuff->mask, b, + (xBellFeedbackCtl *) & stuff[1]); + return Success; + } + break; + default: + break; + } + + SendErrorToClient(client, IReqCode, X_ChangeFeedbackControl, 0, BadMatch); + return Success; +} + diff --git a/Xi/chgfctl.h b/Xi/chgfctl.h index 81e1153ec..cfa9fc6b0 100644 --- a/Xi/chgfctl.h +++ b/Xi/chgfctl.h @@ -36,46 +36,4 @@ int SProcXChangeFeedbackControl(ClientPtr /* client */ int ProcXChangeFeedbackControl(ClientPtr /* client */ ); -int ChangeKbdFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - KbdFeedbackPtr /* k */ , - xKbdFeedbackCtl * /* f */ - ); - -int ChangePtrFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - PtrFeedbackPtr /* p */ , - xPtrFeedbackCtl * /* f */ - ); - -int ChangeIntegerFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - IntegerFeedbackPtr /* i */ , - xIntegerFeedbackCtl * /* f */ - ); - -int ChangeStringFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - StringFeedbackPtr /* s */ , - xStringFeedbackCtl * /* f */ - ); - -int ChangeBellFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - BellFeedbackPtr /* b */ , - xBellFeedbackCtl * /* f */ - ); - -int ChangeLedFeedback(ClientPtr /* client */ , - DeviceIntPtr /* dev */ , - unsigned long /* mask */ , - LedFeedbackPtr /* l */ , - xLedFeedbackCtl * /* f */ - ); - #endif /* CHGFCTL_H */ diff --git a/Xi/chgptr.h b/Xi/chgptr.h index fb3b5cc39..2d8ab66e5 100644 --- a/Xi/chgptr.h +++ b/Xi/chgptr.h @@ -45,12 +45,4 @@ void SendEventToAllWindows(DeviceIntPtr /* dev */ , int /* count */ ); -void FindInterestedChildren( /* FIXME: could be static? */ - DeviceIntPtr /* dev */ , - WindowPtr /* p1 */ , - Mask /* mask */ , - xEvent * /* ev */ , - int /* count */ - ); - #endif /* CHGPTR_H */ diff --git a/Xi/closedev.c b/Xi/closedev.c index cc83e6a5b..3d47b5fca 100644 --- a/Xi/closedev.c +++ b/Xi/closedev.c @@ -89,42 +89,29 @@ SProcXCloseDevice(register ClientPtr client) /*********************************************************************** * - * This procedure closes an input device. + * Clear out event selections and passive grabs from a window for the + * specified device. * */ -int -ProcXCloseDevice(register ClientPtr client) +static void +DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) { - int i; - WindowPtr pWin, p1; - DeviceIntPtr d; - - REQUEST(xCloseDeviceReq); - REQUEST_SIZE_MATCH(xCloseDeviceReq); - - d = LookupDeviceIntRec(stuff->deviceid); - if (d == NULL) { - SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice); - return Success; - } - - if (d->grab && SameClient(d->grab, client)) - (*d->DeactivateGrab) (d); /* release active grab */ + InputClientsPtr others; + OtherInputMasks *pOthers; + GrabPtr grab, next; - /* Remove event selections from all windows for events from this device - * and selected by this client. - * Delete passive grabs from all windows for this device. */ + if ((pOthers = wOtherInputMasks(pWin)) != 0) + for (others = pOthers->inputClients; others; others = others->next) + if (SameClient(others, client)) + others->mask[dev->id] = NoEventMask; - for (i = 0; i < screenInfo.numScreens; i++) { - pWin = WindowTable[i]; - DeleteDeviceEvents(d, pWin, client); - p1 = pWin->firstChild; - DeleteEventsFromChildren(d, p1, client); + for (grab = wPassiveGrabs(pWin); grab; grab = next) { + next = grab->next; + if ((grab->device == dev) && + (client->clientAsMask == CLIENT_BITS(grab->resource))) + FreeResource(grab->resource, RT_NONE); } - - CloseInputDevice(d, client); - return Success; } /*********************************************************************** @@ -134,7 +121,7 @@ ProcXCloseDevice(register ClientPtr client) * */ -void +static void DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) { WindowPtr p2; @@ -149,27 +136,40 @@ DeleteEventsFromChildren(DeviceIntPtr dev, WindowPtr p1, ClientPtr client) /*********************************************************************** * - * Clear out event selections and passive grabs from a window for the - * specified device. + * This procedure closes an input device. * */ -void -DeleteDeviceEvents(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) +int +ProcXCloseDevice(register ClientPtr client) { - InputClientsPtr others; - OtherInputMasks *pOthers; - GrabPtr grab, next; + int i; + WindowPtr pWin, p1; + DeviceIntPtr d; - if ((pOthers = wOtherInputMasks(pWin)) != 0) - for (others = pOthers->inputClients; others; others = others->next) - if (SameClient(others, client)) - others->mask[dev->id] = NoEventMask; + REQUEST(xCloseDeviceReq); + REQUEST_SIZE_MATCH(xCloseDeviceReq); - for (grab = wPassiveGrabs(pWin); grab; grab = next) { - next = grab->next; - if ((grab->device == dev) && - (client->clientAsMask == CLIENT_BITS(grab->resource))) - FreeResource(grab->resource, RT_NONE); + d = LookupDeviceIntRec(stuff->deviceid); + if (d == NULL) { + SendErrorToClient(client, IReqCode, X_CloseDevice, 0, BadDevice); + return Success; + } + + if (d->grab && SameClient(d->grab, client)) + (*d->DeactivateGrab) (d); /* release active grab */ + + /* Remove event selections from all windows for events from this device + * and selected by this client. + * Delete passive grabs from all windows for this device. */ + + for (i = 0; i < screenInfo.numScreens; i++) { + pWin = WindowTable[i]; + DeleteDeviceEvents(d, pWin, client); + p1 = pWin->firstChild; + DeleteEventsFromChildren(d, p1, client); } + + CloseInputDevice(d, client); + return Success; } diff --git a/Xi/closedev.h b/Xi/closedev.h index 6853d5002..400aaa60b 100644 --- a/Xi/closedev.h +++ b/Xi/closedev.h @@ -36,14 +36,4 @@ int SProcXCloseDevice(ClientPtr /* client */ int ProcXCloseDevice(ClientPtr /* client */ ); -void DeleteEventsFromChildren(DeviceIntPtr /* dev */ , - WindowPtr /* p1 */ , - ClientPtr /* client */ - ); - -void DeleteDeviceEvents(DeviceIntPtr /* dev */ , - WindowPtr /* pWin */ , - ClientPtr /* client */ - ); - #endif /* CLOSEDEV_H */ diff --git a/Xi/exevents.c b/Xi/exevents.c index b7645f443..164fce31e 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -994,33 +994,7 @@ ChangeKeyMapping(ClientPtr client, return client->noClientException; } -void -DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) -{ - int i; - DeviceIntPtr dev; - InputClientsPtr ic; - struct _OtherInputMasks *inputMasks; - - for (dev = inputInfo.devices; dev; dev = dev->next) { - if (dev == inputInfo.pointer || dev == inputInfo.keyboard) - continue; - DeleteDeviceFromAnyExtEvents(pWin, dev); - } - - for (dev = inputInfo.off_devices; dev; dev = dev->next) - DeleteDeviceFromAnyExtEvents(pWin, dev); - - if (freeResources) - while ((inputMasks = wOtherInputMasks(pWin)) != 0) { - ic = inputMasks->inputClients; - for (i = 0; i < EMASKSIZE; i++) - inputMasks->dontPropagateMask[i] = 0; - FreeResource(ic->resource, RT_NONE); - } -} - -void +static void DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) { WindowPtr parent; @@ -1085,6 +1059,32 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) dev->valuator->motionHintWindow = NullWindow; } +void +DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) +{ + int i; + DeviceIntPtr dev; + InputClientsPtr ic; + struct _OtherInputMasks *inputMasks; + + for (dev = inputInfo.devices; dev; dev = dev->next) { + if (dev == inputInfo.pointer || dev == inputInfo.keyboard) + continue; + DeleteDeviceFromAnyExtEvents(pWin, dev); + } + + for (dev = inputInfo.off_devices; dev; dev = dev->next) + DeleteDeviceFromAnyExtEvents(pWin, dev); + + if (freeResources) + while ((inputMasks = wOtherInputMasks(pWin)) != 0) { + ic = inputMasks->inputClients; + for (i = 0; i < EMASKSIZE; i++) + inputMasks->dontPropagateMask[i] = 0; + FreeResource(ic->resource, RT_NONE); + } +} + int MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask) { @@ -1138,7 +1138,7 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type, } } -Mask +static Mask DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) { register InputClientsPtr other; @@ -1223,7 +1223,7 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents) * */ -void +static void FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, xEvent * ev, int count) { diff --git a/Xi/exglobals.h b/Xi/exglobals.h index 61ebca8c4..50bb33fdc 100644 --- a/Xi/exglobals.h +++ b/Xi/exglobals.h @@ -45,7 +45,6 @@ extern Mask DevicePointerMotionMask; extern Mask DevicePointerMotionHintMask; extern Mask DeviceFocusChangeMask; extern Mask DeviceStateNotifyMask; -extern Mask ChangeDeviceNotifyMask; extern Mask DeviceMappingNotifyMask; extern Mask DeviceOwnerGrabButtonMask; extern Mask DeviceButtonGrabMask; diff --git a/Xi/extinit.c b/Xi/extinit.c index d14e133ba..fed54ab37 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -161,7 +161,7 @@ Mask DevicePointerMotionMask; Mask DevicePointerMotionHintMask; Mask DeviceFocusChangeMask; Mask DeviceStateNotifyMask; -Mask ChangeDeviceNotifyMask; +static Mask ChangeDeviceNotifyMask; Mask DeviceMappingNotifyMask; Mask DeviceOwnerGrabButtonMask; Mask DeviceButtonGrabMask; @@ -208,51 +208,6 @@ static XExtensionVersion thisversion = { XI_Present, XI_Add_DevicePresenceNotify_Minor }; -/********************************************************************** - * - * IExtensionInit - initialize the input extension. - * - * Called from InitExtensions in main() or from QueryExtension() if the - * extension is dynamically loaded. - * - * This extension has several events and errors. - * - */ - -void -XInputExtensionInit(void) -{ - ExtensionEntry *extEntry; - - extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, - SProcIDispatch, IResetProc, StandardMinorOpcode); - if (extEntry) { - IReqCode = extEntry->base; - AllExtensionVersions[IReqCode - 128] = thisversion; - MakeDeviceTypeAtoms(); - RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone); - FixExtensionEvents(extEntry); - ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; - EventSwapVector[DeviceValuator] = SEventIDispatch; - EventSwapVector[DeviceKeyPress] = SEventIDispatch; - EventSwapVector[DeviceKeyRelease] = SEventIDispatch; - EventSwapVector[DeviceButtonPress] = SEventIDispatch; - EventSwapVector[DeviceButtonRelease] = SEventIDispatch; - EventSwapVector[DeviceMotionNotify] = SEventIDispatch; - EventSwapVector[DeviceFocusIn] = SEventIDispatch; - EventSwapVector[DeviceFocusOut] = SEventIDispatch; - EventSwapVector[ProximityIn] = SEventIDispatch; - EventSwapVector[ProximityOut] = SEventIDispatch; - EventSwapVector[DeviceStateNotify] = SEventIDispatch; - EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; - EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; - EventSwapVector[DeviceMappingNotify] = SEventIDispatch; - EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; - } else { - FatalError("IExtensionInit: AddExtensions failed\n"); - } -} - /************************************************************************* * * ProcIDispatch - main dispatch routine for requests to this extension. @@ -260,7 +215,7 @@ XInputExtensionInit(void) * */ -int +static int ProcIDispatch(register ClientPtr client) { REQUEST(xReq); @@ -349,7 +304,7 @@ ProcIDispatch(register ClientPtr client) * */ -int +static int SProcIDispatch(register ClientPtr client) { REQUEST(xReq); @@ -441,7 +396,7 @@ SProcIDispatch(register ClientPtr client) if (rep->RepType == X_##code) \ SRepX##code (client, len, (x##code##Reply *) rep) -void +static void SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) /* All we look at is the type field */ { /* This is common to all replies */ @@ -500,68 +455,13 @@ SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) } } -/***************************************************************************** - * - * SEventIDispatch - * - * Swap any events defined in this extension. - */ -#define DO_SWAP(func,type) func ((type *)from, (type *)to) - -void -SEventIDispatch(xEvent * from, xEvent * to) -{ - int type = from->u.u.type & 0177; - - if (type == DeviceValuator) - DO_SWAP(SEventDeviceValuator, deviceValuator); - else if (type == DeviceKeyPress) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceKeyRelease) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceButtonPress) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceButtonRelease) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceMotionNotify) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceFocusIn) - DO_SWAP(SEventFocus, deviceFocus); - else if (type == DeviceFocusOut) - DO_SWAP(SEventFocus, deviceFocus); - else if (type == ProximityIn) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == ProximityOut) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceStateNotify) - DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); - else if (type == DeviceKeyStateNotify) - DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); - else if (type == DeviceButtonStateNotify) - DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); - else if (type == DeviceMappingNotify) - DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); - else if (type == ChangeDeviceNotify) - DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); - else { - FatalError("XInputExtension: Impossible event!\n"); - } -} - /************************************************************************ * * This function swaps the DeviceValuator event. * */ -void +static void SEventDeviceValuator(deviceValuator * from, deviceValuator * to) { register char n; @@ -577,7 +477,7 @@ SEventDeviceValuator(deviceValuator * from, deviceValuator * to) } } -void +static void SEventFocus(deviceFocus * from, deviceFocus * to) { register char n; @@ -588,7 +488,7 @@ SEventFocus(deviceFocus * from, deviceFocus * to) swapl(&to->window, n); } -void +static void SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) { register int i; @@ -604,7 +504,7 @@ SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) } } -void +static void SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, deviceKeyStateNotify * to) { @@ -614,7 +514,7 @@ SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, swaps(&to->sequenceNumber, n); } -void +static void SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from, deviceButtonStateNotify * to) { @@ -624,7 +524,7 @@ SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from, swaps(&to->sequenceNumber, n); } -void +static void SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to) { register char n; @@ -634,7 +534,7 @@ SChangeDeviceNotifyEvent(changeDeviceNotify * from, changeDeviceNotify * to) swapl(&to->time, n); } -void +static void SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) { register char n; @@ -644,7 +544,7 @@ SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) swapl(&to->time, n); } -void +static void SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to) { register char n; @@ -655,13 +555,106 @@ SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to swaps(&to->control, n); } +/************************************************************************** + * + * Allow the specified event to have its propagation suppressed. + * The default is to not allow suppression of propagation. + * + */ + +static void +AllowPropagateSuppress(Mask mask) +{ + int i; + + for (i = 0; i < MAX_DEVICES; i++) + PropagateMask[i] |= mask; +} + +/************************************************************************** + * + * Return the next available extension event mask. + * + */ + +static Mask +GetNextExtEventMask(void) +{ + int i; + Mask mask = lastExtEventMask; + + if (lastExtEventMask == 0) { + FatalError("GetNextExtEventMask: no more events are available."); + } + lastExtEventMask <<= 1; + + for (i = 0; i < MAX_DEVICES; i++) + ExtValidMasks[i] |= mask; + return mask; +} + +/************************************************************************** + * + * Record an event mask where there is no unique corresponding event type. + * We can't call SetMaskForEvent, since that would clobber the existing + * mask for that event. MotionHint and ButtonMotion are examples. + * + * 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 + * DevicePointerMotionHint must have access to the same constants. + * + */ + +static void +SetEventInfo(Mask mask, int constant) +{ + EventInfo[ExtEventIndex].mask = mask; + EventInfo[ExtEventIndex++].type = constant; +} + +/************************************************************************** + * + * Allow the specified event to be restricted to being selected by one + * client at a time. + * The default is to allow more than one client to select the event. + * + */ + +static void +SetExclusiveAccess(Mask mask) +{ + int i; + + for (i = 0; i < MAX_DEVICES; i++) + ExtExclusiveMasks[i] |= mask; +} + +/************************************************************************** + * + * Assign the specified mask to the specified event. + * + */ + +static void +SetMaskForExtEvent(Mask mask, int event) +{ + + EventInfo[ExtEventIndex].mask = mask; + EventInfo[ExtEventIndex++].type = event; + + if ((event < LASTEvent) || (event >= 128)) + FatalError("MaskForExtensionEvent: bogus event number"); + SetMaskForEvent(mask, event); +} + /************************************************************************ * * This function sets up extension event types and masks. * */ -void +static void FixExtensionEvents(ExtensionEntry * extEntry) { Mask mask; @@ -767,7 +760,7 @@ FixExtensionEvents(ExtensionEntry * extEntry) * */ -void +static void RestoreExtensionEvents(void) { int i; @@ -815,7 +808,7 @@ RestoreExtensionEvents(void) * */ -void +static void IResetProc(ExtensionEntry * unused) { @@ -859,7 +852,7 @@ AssignTypeAndName(DeviceIntPtr dev, Atom type, char *name) * */ -void +static void MakeDeviceTypeAtoms(void) { int i; @@ -892,95 +885,102 @@ LookupDeviceIntRec(CARD8 id) return NULL; } -/************************************************************************** - * - * Allow the specified event to be restricted to being selected by one - * client at a time. - * The default is to allow more than one client to select the event. - * - */ - -void -SetExclusiveAccess(Mask mask) -{ - int i; - - for (i = 0; i < MAX_DEVICES; i++) - ExtExclusiveMasks[i] |= mask; -} - -/************************************************************************** - * - * Allow the specified event to have its propagation suppressed. - * The default is to not allow suppression of propagation. - * - */ - -void -AllowPropagateSuppress(Mask mask) -{ - int i; - - for (i = 0; i < MAX_DEVICES; i++) - PropagateMask[i] |= mask; -} - -/************************************************************************** +/***************************************************************************** * - * Return the next available extension event mask. + * SEventIDispatch * + * Swap any events defined in this extension. */ +#define DO_SWAP(func,type) func ((type *)from, (type *)to) -Mask -GetNextExtEventMask(void) +static void +SEventIDispatch(xEvent * from, xEvent * to) { - int i; - Mask mask = lastExtEventMask; + int type = from->u.u.type & 0177; - if (lastExtEventMask == 0) { - FatalError("GetNextExtEventMask: no more events are available."); + if (type == DeviceValuator) + DO_SWAP(SEventDeviceValuator, deviceValuator); + else if (type == DeviceKeyPress) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceKeyRelease) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceButtonPress) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceButtonRelease) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceMotionNotify) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceFocusIn) + DO_SWAP(SEventFocus, deviceFocus); + else if (type == DeviceFocusOut) + DO_SWAP(SEventFocus, deviceFocus); + else if (type == ProximityIn) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == ProximityOut) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } else if (type == DeviceStateNotify) + DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); + else if (type == DeviceKeyStateNotify) + DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); + else if (type == DeviceButtonStateNotify) + DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); + else if (type == DeviceMappingNotify) + DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); + else if (type == ChangeDeviceNotify) + DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); + else { + FatalError("XInputExtension: Impossible event!\n"); } - lastExtEventMask <<= 1; - - for (i = 0; i < MAX_DEVICES; i++) - ExtValidMasks[i] |= mask; - return mask; } -/************************************************************************** - * - * Assign the specified mask to the specified event. +/********************************************************************** * - */ - -void -SetMaskForExtEvent(Mask mask, int event) -{ - - EventInfo[ExtEventIndex].mask = mask; - EventInfo[ExtEventIndex++].type = event; - - if ((event < LASTEvent) || (event >= 128)) - FatalError("MaskForExtensionEvent: bogus event number"); - SetMaskForEvent(mask, event); -} - -/************************************************************************** + * IExtensionInit - initialize the input extension. * - * Record an event mask where there is no unique corresponding event type. - * We can't call SetMaskForEvent, since that would clobber the existing - * mask for that event. MotionHint and ButtonMotion are examples. + * Called from InitExtensions in main() or from QueryExtension() if the + * extension is dynamically loaded. * - * 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 - * DevicePointerMotionHint must have access to the same constants. + * This extension has several events and errors. * */ void -SetEventInfo(Mask mask, int constant) +XInputExtensionInit(void) { - EventInfo[ExtEventIndex].mask = mask; - EventInfo[ExtEventIndex++].type = constant; + ExtensionEntry *extEntry; + + extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, + SProcIDispatch, IResetProc, StandardMinorOpcode); + if (extEntry) { + IReqCode = extEntry->base; + AllExtensionVersions[IReqCode - 128] = thisversion; + MakeDeviceTypeAtoms(); + RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone); + FixExtensionEvents(extEntry); + ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; + EventSwapVector[DeviceValuator] = SEventIDispatch; + EventSwapVector[DeviceKeyPress] = SEventIDispatch; + EventSwapVector[DeviceKeyRelease] = SEventIDispatch; + EventSwapVector[DeviceButtonPress] = SEventIDispatch; + EventSwapVector[DeviceButtonRelease] = SEventIDispatch; + EventSwapVector[DeviceMotionNotify] = SEventIDispatch; + EventSwapVector[DeviceFocusIn] = SEventIDispatch; + EventSwapVector[DeviceFocusOut] = SEventIDispatch; + EventSwapVector[ProximityIn] = SEventIDispatch; + EventSwapVector[ProximityOut] = SEventIDispatch; + EventSwapVector[DeviceStateNotify] = SEventIDispatch; + EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; + EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; + EventSwapVector[DeviceMappingNotify] = SEventIDispatch; + EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; + } else { + FatalError("IExtensionInit: AddExtensions failed\n"); + } } diff --git a/Xi/getdctl.c b/Xi/getdctl.c index d738ef83b..c264d4f8c 100644 --- a/Xi/getdctl.c +++ b/Xi/getdctl.c @@ -88,112 +88,11 @@ SProcXGetDeviceControl(register ClientPtr client) /*********************************************************************** * - * Get the state of the specified device control. - * - */ - -int -ProcXGetDeviceControl(ClientPtr client) -{ - int total_length = 0; - char *buf, *savbuf; - register DeviceIntPtr dev; - xGetDeviceControlReply rep; - - REQUEST(xGetDeviceControlReq); - REQUEST_SIZE_MATCH(xGetDeviceControlReq); - - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice); - return Success; - } - - rep.repType = X_Reply; - rep.RepType = X_GetDeviceControl; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - switch (stuff->control) { - case DEVICE_RESOLUTION: - if (!dev->valuator) { - SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, - BadMatch); - return Success; - } - 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; - } - - buf = (char *)xalloc(total_length); - if (!buf) { - SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc); - return Success; - } - savbuf = buf; - - switch (stuff->control) { - 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; - } - - rep.length = (total_length + 3) >> 2; - WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep); - WriteToClient(client, total_length, savbuf); - xfree(savbuf); - return Success; -} - -/*********************************************************************** - * * This procedure copies DeviceResolution data, swapping if necessary. * */ -void +static void CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, int length) { @@ -225,7 +124,7 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, } } -void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts, +static void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts, char *buf) { register char n; @@ -256,7 +155,7 @@ void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts, } } -void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts, +static void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts, char *buf) { register char n; @@ -283,7 +182,7 @@ void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts, } } -void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) +static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) { register char n; xDeviceCoreState *c = (xDeviceCoreState *) buf; @@ -300,7 +199,7 @@ void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) } } -void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf) +static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf) { register char n; xDeviceEnableState *e = (xDeviceEnableState *) buf; @@ -316,7 +215,6 @@ void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf) } } - /*********************************************************************** * * This procedure writes the reply for the xGetDeviceControl function, @@ -333,3 +231,104 @@ SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep) swapl(&rep->length, n); WriteToClient(client, size, (char *)rep); } + +/*********************************************************************** + * + * Get the state of the specified device control. + * + */ + +int +ProcXGetDeviceControl(ClientPtr client) +{ + int total_length = 0; + char *buf, *savbuf; + register DeviceIntPtr dev; + xGetDeviceControlReply rep; + + REQUEST(xGetDeviceControlReq); + REQUEST_SIZE_MATCH(xGetDeviceControlReq); + + dev = LookupDeviceIntRec(stuff->deviceid); + if (dev == NULL) { + SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadDevice); + return Success; + } + + rep.repType = X_Reply; + rep.RepType = X_GetDeviceControl; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + switch (stuff->control) { + case DEVICE_RESOLUTION: + if (!dev->valuator) { + SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, + BadMatch); + return Success; + } + 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; + } + + buf = (char *)xalloc(total_length); + if (!buf) { + SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadAlloc); + return Success; + } + savbuf = buf; + + switch (stuff->control) { + 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; + } + + rep.length = (total_length + 3) >> 2; + WriteReplyToClient(client, sizeof(xGetDeviceControlReply), &rep); + WriteToClient(client, total_length, savbuf); + xfree(savbuf); + return Success; +} diff --git a/Xi/getdctl.h b/Xi/getdctl.h index 36868d8be..19c189f36 100644 --- a/Xi/getdctl.h +++ b/Xi/getdctl.h @@ -36,30 +36,6 @@ int SProcXGetDeviceControl(ClientPtr /* client */ int ProcXGetDeviceControl(ClientPtr /* client */ ); -void CopySwapDeviceResolution(ClientPtr /* client */ , - ValuatorClassPtr /* v */ , - char * /* buf */ , - 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/getfctl.c b/Xi/getfctl.c index 870348fbb..28360ee54 100644 --- a/Xi/getfctl.c +++ b/Xi/getfctl.c @@ -86,104 +86,11 @@ SProcXGetFeedbackControl(register ClientPtr client) /*********************************************************************** * - * Get the feedback control state. - * - */ - -int -ProcXGetFeedbackControl(ClientPtr client) -{ - int total_length = 0; - char *buf, *savbuf; - register DeviceIntPtr dev; - KbdFeedbackPtr k; - PtrFeedbackPtr p; - IntegerFeedbackPtr i; - StringFeedbackPtr s; - BellFeedbackPtr b; - LedFeedbackPtr l; - xGetFeedbackControlReply rep; - - REQUEST(xGetFeedbackControlReq); - REQUEST_SIZE_MATCH(xGetFeedbackControlReq); - - dev = LookupDeviceIntRec(stuff->deviceid); - if (dev == NULL) { - SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice); - return Success; - } - - rep.repType = X_Reply; - rep.RepType = X_GetFeedbackControl; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.num_feedbacks = 0; - - for (k = dev->kbdfeed; k; k = k->next) { - rep.num_feedbacks++; - total_length += sizeof(xKbdFeedbackState); - } - for (p = dev->ptrfeed; p; p = p->next) { - rep.num_feedbacks++; - total_length += sizeof(xPtrFeedbackState); - } - for (s = dev->stringfeed; s; s = s->next) { - rep.num_feedbacks++; - total_length += sizeof(xStringFeedbackState) + - (s->ctrl.num_symbols_supported * sizeof(KeySym)); - } - for (i = dev->intfeed; i; i = i->next) { - rep.num_feedbacks++; - total_length += sizeof(xIntegerFeedbackState); - } - for (l = dev->leds; l; l = l->next) { - rep.num_feedbacks++; - total_length += sizeof(xLedFeedbackState); - } - for (b = dev->bell; b; b = b->next) { - rep.num_feedbacks++; - total_length += sizeof(xBellFeedbackState); - } - - if (total_length == 0) { - SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch); - return Success; - } - - buf = (char *)xalloc(total_length); - if (!buf) { - SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc); - return Success; - } - savbuf = buf; - - for (k = dev->kbdfeed; k; k = k->next) - CopySwapKbdFeedback(client, k, &buf); - for (p = dev->ptrfeed; p; p = p->next) - CopySwapPtrFeedback(client, p, &buf); - for (s = dev->stringfeed; s; s = s->next) - CopySwapStringFeedback(client, s, &buf); - for (i = dev->intfeed; i; i = i->next) - CopySwapIntegerFeedback(client, i, &buf); - for (l = dev->leds; l; l = l->next) - CopySwapLedFeedback(client, l, &buf); - for (b = dev->bell; b; b = b->next) - CopySwapBellFeedback(client, b, &buf); - - rep.length = (total_length + 3) >> 2; - WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep); - WriteToClient(client, total_length, savbuf); - xfree(savbuf); - return Success; -} - -/*********************************************************************** - * * This procedure copies KbdFeedbackClass data, swapping if necessary. * */ -void +static void CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf) { int i; @@ -218,7 +125,7 @@ CopySwapKbdFeedback(ClientPtr client, KbdFeedbackPtr k, char **buf) * */ -void +static void CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf) { register char n; @@ -246,7 +153,7 @@ CopySwapPtrFeedback(ClientPtr client, PtrFeedbackPtr p, char **buf) * */ -void +static void CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf) { register char n; @@ -274,7 +181,7 @@ CopySwapIntegerFeedback(ClientPtr client, IntegerFeedbackPtr i, char **buf) * */ -void +static void CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf) { int i; @@ -311,7 +218,7 @@ CopySwapStringFeedback(ClientPtr client, StringFeedbackPtr s, char **buf) * */ -void +static void CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf) { register char n; @@ -337,7 +244,7 @@ CopySwapLedFeedback(ClientPtr client, LedFeedbackPtr l, char **buf) * */ -void +static void CopySwapBellFeedback(ClientPtr client, BellFeedbackPtr b, char **buf) { register char n; @@ -376,3 +283,96 @@ SRepXGetFeedbackControl(ClientPtr client, int size, swaps(&rep->num_feedbacks, n); WriteToClient(client, size, (char *)rep); } + +/*********************************************************************** + * + * Get the feedback control state. + * + */ + +int +ProcXGetFeedbackControl(ClientPtr client) +{ + int total_length = 0; + char *buf, *savbuf; + register DeviceIntPtr dev; + KbdFeedbackPtr k; + PtrFeedbackPtr p; + IntegerFeedbackPtr i; + StringFeedbackPtr s; + BellFeedbackPtr b; + LedFeedbackPtr l; + xGetFeedbackControlReply rep; + + REQUEST(xGetFeedbackControlReq); + REQUEST_SIZE_MATCH(xGetFeedbackControlReq); + + dev = LookupDeviceIntRec(stuff->deviceid); + if (dev == NULL) { + SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadDevice); + return Success; + } + + rep.repType = X_Reply; + rep.RepType = X_GetFeedbackControl; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.num_feedbacks = 0; + + for (k = dev->kbdfeed; k; k = k->next) { + rep.num_feedbacks++; + total_length += sizeof(xKbdFeedbackState); + } + for (p = dev->ptrfeed; p; p = p->next) { + rep.num_feedbacks++; + total_length += sizeof(xPtrFeedbackState); + } + for (s = dev->stringfeed; s; s = s->next) { + rep.num_feedbacks++; + total_length += sizeof(xStringFeedbackState) + + (s->ctrl.num_symbols_supported * sizeof(KeySym)); + } + for (i = dev->intfeed; i; i = i->next) { + rep.num_feedbacks++; + total_length += sizeof(xIntegerFeedbackState); + } + for (l = dev->leds; l; l = l->next) { + rep.num_feedbacks++; + total_length += sizeof(xLedFeedbackState); + } + for (b = dev->bell; b; b = b->next) { + rep.num_feedbacks++; + total_length += sizeof(xBellFeedbackState); + } + + if (total_length == 0) { + SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadMatch); + return Success; + } + + buf = (char *)xalloc(total_length); + if (!buf) { + SendErrorToClient(client, IReqCode, X_GetFeedbackControl, 0, BadAlloc); + return Success; + } + savbuf = buf; + + for (k = dev->kbdfeed; k; k = k->next) + CopySwapKbdFeedback(client, k, &buf); + for (p = dev->ptrfeed; p; p = p->next) + CopySwapPtrFeedback(client, p, &buf); + for (s = dev->stringfeed; s; s = s->next) + CopySwapStringFeedback(client, s, &buf); + for (i = dev->intfeed; i; i = i->next) + CopySwapIntegerFeedback(client, i, &buf); + for (l = dev->leds; l; l = l->next) + CopySwapLedFeedback(client, l, &buf); + for (b = dev->bell; b; b = b->next) + CopySwapBellFeedback(client, b, &buf); + + rep.length = (total_length + 3) >> 2; + WriteReplyToClient(client, sizeof(xGetFeedbackControlReply), &rep); + WriteToClient(client, total_length, savbuf); + xfree(savbuf); + return Success; +} diff --git a/Xi/getfctl.h b/Xi/getfctl.h index 7d2d17ab1..0ad58aa2b 100644 --- a/Xi/getfctl.h +++ b/Xi/getfctl.h @@ -36,36 +36,6 @@ int SProcXGetFeedbackControl(ClientPtr /* client */ int ProcXGetFeedbackControl(ClientPtr /* client */ ); -void CopySwapKbdFeedback(ClientPtr /* client */ , - KbdFeedbackPtr /* k */ , - char ** /* buf */ - ); - -void CopySwapPtrFeedback(ClientPtr /* client */ , - PtrFeedbackPtr /* p */ , - char ** /* buf */ - ); - -void CopySwapIntegerFeedback(ClientPtr /* client */ , - IntegerFeedbackPtr /* i */ , - char ** /* buf */ - ); - -void CopySwapStringFeedback(ClientPtr /* client */ , - StringFeedbackPtr /* s */ , - char ** /* buf */ - ); - -void CopySwapLedFeedback(ClientPtr /* client */ , - LedFeedbackPtr /* l */ , - char ** /* buf */ - ); - -void CopySwapBellFeedback(ClientPtr /* client */ , - BellFeedbackPtr /* b */ , - char ** /* buf */ - ); - void SRepXGetFeedbackControl(ClientPtr /* client */ , int /* size */ , xGetFeedbackControlReply * /* rep */ diff --git a/Xi/listdev.c b/Xi/listdev.c index 02d55ad4c..257ee59bc 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -88,71 +88,12 @@ SProcXListInputDevices(register ClientPtr client) /*********************************************************************** * - * This procedure lists the input devices available to the server. - * - */ - -int -ProcXListInputDevices(register ClientPtr client) -{ - xListInputDevicesReply rep; - int numdevs = 0; - int namesize = 1; /* need 1 extra byte for strcpy */ - int size = 0; - int total_length; - char *devbuf; - char *classbuf; - char *namebuf; - char *savbuf; - xDeviceInfo *dev; - DeviceIntPtr d; - - REQUEST_SIZE_MATCH(xListInputDevicesReq); - - rep.repType = X_Reply; - rep.RepType = X_ListInputDevices; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - AddOtherInputDevices(); - - for (d = inputInfo.devices; d; d = d->next) { - SizeDeviceInfo(d, &namesize, &size); - 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); - classbuf = devbuf + (numdevs * sizeof(xDeviceInfo)); - namebuf = classbuf + size; - savbuf = devbuf; - - dev = (xDeviceInfoPtr) devbuf; - for (d = inputInfo.devices; d; d = d->next, dev++) - ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); - for (d = inputInfo.off_devices; d; d = d->next, dev++) - ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); - - rep.ndevices = numdevs; - rep.length = (total_length + 3) >> 2; - WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep); - WriteToClient(client, total_length, savbuf); - xfree(savbuf); - return Success; -} - -/*********************************************************************** - * * This procedure calculates the size of the information to be returned * for an input device. * */ -void +static void SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) { int chunks; @@ -173,32 +114,6 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) /*********************************************************************** * - * This procedure lists information to be returned for an input device. - * - */ - -void -ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, - char **devbuf, char **classbuf, char **namebuf) -{ - CopyDeviceName(namebuf, d->name); - CopySwapDevice(client, d, 0, devbuf); - if (d->key != NULL) { - CopySwapKeyClass(client, d->key, classbuf); - dev->num_classes++; - } - if (d->button != NULL) { - CopySwapButtonClass(client, d->button, classbuf); - dev->num_classes++; - } - if (d->valuator != NULL) { - dev->num_classes += - CopySwapValuatorClass(client, d->valuator, classbuf); - } -} - -/*********************************************************************** - * * This procedure copies data to the DeviceInfo struct, swapping if necessary. * * We need the extra byte in the allocated buffer, because the trailing null @@ -207,7 +122,7 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, * */ -void +static void CopyDeviceName(char **namebuf, char *name) { char *nameptr = (char *)*namebuf; @@ -224,11 +139,33 @@ CopyDeviceName(char **namebuf, char *name) /*********************************************************************** * + * This procedure copies ButtonClass information, swapping if necessary. + * + */ + +static void +CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf) +{ + register char n; + xButtonInfoPtr b2; + + b2 = (xButtonInfoPtr) * buf; + b2->class = ButtonClass; + b2->length = sizeof(xButtonInfo); + b2->num_buttons = b->numButtons; + if (client->swapped) { + swaps(&b2->num_buttons, n); /* macro - braces are required */ + } + *buf += sizeof(xButtonInfo); +} + +/*********************************************************************** + * * This procedure copies data to the DeviceInfo struct, swapping if necessary. * */ -void +static void CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes, char **buf) { @@ -262,7 +199,7 @@ CopySwapDevice(register ClientPtr client, DeviceIntPtr d, int num_classes, * */ -void +static void CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf) { register char n; @@ -282,28 +219,6 @@ CopySwapKeyClass(register ClientPtr client, KeyClassPtr k, char **buf) /*********************************************************************** * - * This procedure copies ButtonClass information, swapping if necessary. - * - */ - -void -CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf) -{ - register char n; - xButtonInfoPtr b2; - - b2 = (xButtonInfoPtr) * buf; - b2->class = ButtonClass; - b2->length = sizeof(xButtonInfo); - b2->num_buttons = b->numButtons; - if (client->swapped) { - swaps(&b2->num_buttons, n); /* macro - braces are required */ - } - *buf += sizeof(xButtonInfo); -} - -/*********************************************************************** - * * This procedure copies ValuatorClass information, swapping if necessary. * * Devices may have up to 255 valuators. The length of a ValuatorClass is @@ -314,7 +229,7 @@ CopySwapButtonClass(register ClientPtr client, ButtonClassPtr b, char **buf) * */ -int +static int CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf) { int i, j, axes, t_axes; @@ -359,6 +274,91 @@ CopySwapValuatorClass(register ClientPtr client, ValuatorClassPtr v, char **buf) /*********************************************************************** * + * This procedure lists information to be returned for an input device. + * + */ + +static void +ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, + char **devbuf, char **classbuf, char **namebuf) +{ + CopyDeviceName(namebuf, d->name); + CopySwapDevice(client, d, 0, devbuf); + if (d->key != NULL) { + CopySwapKeyClass(client, d->key, classbuf); + dev->num_classes++; + } + if (d->button != NULL) { + CopySwapButtonClass(client, d->button, classbuf); + dev->num_classes++; + } + if (d->valuator != NULL) { + dev->num_classes += + CopySwapValuatorClass(client, d->valuator, classbuf); + } +} + +/*********************************************************************** + * + * This procedure lists the input devices available to the server. + * + */ + +int +ProcXListInputDevices(register ClientPtr client) +{ + xListInputDevicesReply rep; + int numdevs = 0; + int namesize = 1; /* need 1 extra byte for strcpy */ + int size = 0; + int total_length; + char *devbuf; + char *classbuf; + char *namebuf; + char *savbuf; + xDeviceInfo *dev; + DeviceIntPtr d; + + REQUEST_SIZE_MATCH(xListInputDevicesReq); + + rep.repType = X_Reply; + rep.RepType = X_ListInputDevices; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + AddOtherInputDevices(); + + for (d = inputInfo.devices; d; d = d->next) { + SizeDeviceInfo(d, &namesize, &size); + 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); + classbuf = devbuf + (numdevs * sizeof(xDeviceInfo)); + namebuf = classbuf + size; + savbuf = devbuf; + + dev = (xDeviceInfoPtr) devbuf; + for (d = inputInfo.devices; d; d = d->next, dev++) + ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); + for (d = inputInfo.off_devices; d; d = d->next, dev++) + ListDeviceInfo(client, d, dev, &devbuf, &classbuf, &namebuf); + + rep.ndevices = numdevs; + rep.length = (total_length + 3) >> 2; + WriteReplyToClient(client, sizeof(xListInputDevicesReply), &rep); + WriteToClient(client, total_length, savbuf); + xfree(savbuf); + return Success; +} + +/*********************************************************************** + * * This procedure writes the reply for the XListInputDevices function, * if the client and server have a different byte ordering. * diff --git a/Xi/listdev.h b/Xi/listdev.h index bdd67ce70..db376decf 100644 --- a/Xi/listdev.h +++ b/Xi/listdev.h @@ -36,44 +36,6 @@ int SProcXListInputDevices(ClientPtr /* client */ int ProcXListInputDevices(ClientPtr /* client */ ); -void SizeDeviceInfo(DeviceIntPtr /* d */ , - int * /* namesize */ , - int * /* size */ - ); - -void ListDeviceInfo(ClientPtr /* client */ , - DeviceIntPtr /* d */ , - xDeviceInfoPtr /* dev */ , - char ** /* devbuf */ , - char ** /* classbuf */ , - char ** /* namebuf */ - ); - -void CopyDeviceName(char ** /* namebuf */ , - char * /* name */ - ); - -void CopySwapDevice(ClientPtr /* client */ , - DeviceIntPtr /* d */ , - int /* num_classes */ , - char ** /* buf */ - ); - -void CopySwapKeyClass(ClientPtr /* client */ , - KeyClassPtr /* k */ , - char ** /* buf */ - ); - -void CopySwapButtonClass(ClientPtr /* client */ , - ButtonClassPtr /* b */ , - char ** /* buf */ - ); - -int CopySwapValuatorClass(ClientPtr /* client */ , - ValuatorClassPtr /* v */ , - char ** /* buf */ - ); - void SRepXListInputDevices(ClientPtr /* client */ , int /* size */ , xListInputDevicesReply * /* rep */ |