diff options
40 files changed, 1998 insertions, 2051 deletions
@@ -1,3 +1,9 @@ +2006-03-31 Daniel Stone <daniel@freedesktop.org> + + * **/*.[ch]: + Reindent with -bad -bap -c0 -cd0 -cp0 -ncdb -ci4 -cli0 -ncs -d0 -di4 + -i4 -ip4 -l80 -npcs -psl -sob -ss -ce -sc -br -cdw -lp -cbi0. + 2006-03-20 Adam Jackson <ajax@freedesktop.org> * src/Makefile.am: diff --git a/src/XAllowDv.c b/src/XAllowDv.c index d745046..94a27ca 100644 --- a/src/XAllowDv.c +++ b/src/XAllowDv.c @@ -61,20 +61,20 @@ SOFTWARE. #include "XIint.h" int -XAllowDeviceEvents (dpy, dev, event_mode, time) - register Display *dpy; - XDevice *dev; - int event_mode; - Time time; - { - xAllowDeviceEventsReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XAllowDeviceEvents(dpy, dev, event_mode, time) + register Display *dpy; + XDevice *dev; + int event_mode; + Time time; +{ + xAllowDeviceEventsReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(AllowDeviceEvents,req); + GetReq(AllowDeviceEvents, req); req->reqType = info->codes->major_opcode; req->ReqType = X_AllowDeviceEvents; req->deviceid = dev->device_id; @@ -84,5 +84,4 @@ XAllowDeviceEvents (dpy, dev, event_mode, time) UnlockDisplay(dpy); SyncHandle(); return (Success); - } - +} diff --git a/src/XChgDCtl.c b/src/XChgDCtl.c index b1fd7a1..be5d941 100644 --- a/src/XChgDCtl.c +++ b/src/XChgDCtl.c @@ -62,69 +62,65 @@ SOFTWARE. #include "XIint.h" int -XChangeDeviceControl (dpy, dev, control, d) - register Display *dpy; - XDevice *dev; - int control; - XDeviceControl *d; - { +XChangeDeviceControl(dpy, dev, control, d) + register Display *dpy; + XDevice *dev; + int control; + XDeviceControl *d; +{ int length; - xChangeDeviceControlReq *req; - xChangeDeviceControlReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); + xChangeDeviceControlReq *req; + xChangeDeviceControlReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1) return (NoSuchExtension); - GetReq(ChangeDeviceControl,req); + GetReq(ChangeDeviceControl, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ChangeDeviceControl; req->deviceid = dev->device_id; req->control = control; - switch (control) - { - case DEVICE_RESOLUTION: - { - XDeviceResolutionControl *R; - xDeviceResolutionCtl r; - - R = (XDeviceResolutionControl *) d; - r.control = DEVICE_RESOLUTION; - r.length = sizeof (xDeviceResolutionCtl) + - R->num_valuators * sizeof(int); - r.first_valuator = R->first_valuator; - r.num_valuators = R->num_valuators; - req->length += ((unsigned)(r.length + 3) >> 2); - length = sizeof (xDeviceResolutionCtl); - Data (dpy, (char *) &r, length); - length = r.num_valuators * sizeof(int); - Data (dpy, (char *) R->resolutions, length); - if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) - { - UnlockDisplay(dpy); - SyncHandle(); - return (NoSuchExtension); - } - else - return (rep.status); - } - default: - { - xDeviceCtl u; - - u.control = d->control; - u.length = d->length - sizeof (int); - length = ((unsigned)(u.length + 3) >> 2); - req->length += length; - length <<= 2; - Data (dpy, (char *) &u, length); - } - } + switch (control) { + case DEVICE_RESOLUTION: + { + XDeviceResolutionControl *R; + xDeviceResolutionCtl r; + + R = (XDeviceResolutionControl *) d; + r.control = DEVICE_RESOLUTION; + r.length = sizeof(xDeviceResolutionCtl) + + R->num_valuators * sizeof(int); + r.first_valuator = R->first_valuator; + r.num_valuators = R->num_valuators; + req->length += ((unsigned)(r.length + 3) >> 2); + length = sizeof(xDeviceResolutionCtl); + Data(dpy, (char *)&r, length); + length = r.num_valuators * sizeof(int); + Data(dpy, (char *)R->resolutions, length); + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { + UnlockDisplay(dpy); + SyncHandle(); + return (NoSuchExtension); + } else + return (rep.status); + } + default: + { + xDeviceCtl u; + + u.control = d->control; + u.length = d->length - sizeof(int); + length = ((unsigned)(u.length + 3) >> 2); + req->length += length; + length <<= 2; + Data(dpy, (char *)&u, length); + } + } UnlockDisplay(dpy); SyncHandle(); return (Success); - } - +} diff --git a/src/XChgFCtl.c b/src/XChgFCtl.c index 8f4c009..32c7b24 100644 --- a/src/XChgFCtl.c +++ b/src/XChgFCtl.c @@ -62,35 +62,34 @@ SOFTWARE. #include "XIint.h" int -XChangeFeedbackControl (dpy, dev, mask, f) - register Display *dpy; - XDevice *dev; - unsigned long mask; - XFeedbackControl *f; - { +XChangeFeedbackControl(dpy, dev, mask, f) + register Display *dpy; + XDevice *dev; + unsigned long mask; + XFeedbackControl *f; +{ int length; - xChangeFeedbackControlReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); + xChangeFeedbackControlReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(ChangeFeedbackControl,req); + GetReq(ChangeFeedbackControl, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ChangeFeedbackControl; req->deviceid = dev->device_id; req->mask = mask; req->feedbackid = f->class; - if (f->class == KbdFeedbackClass) - { - XKbdFeedbackControl *K; - xKbdFeedbackCtl k; + if (f->class == KbdFeedbackClass) { + XKbdFeedbackControl *K; + xKbdFeedbackCtl k; K = (XKbdFeedbackControl *) f; k.class = KbdFeedbackClass; - k.length = sizeof (xKbdFeedbackCtl); + k.length = sizeof(xKbdFeedbackCtl); k.id = K->id; k.click = K->click; k.percent = K->percent; @@ -103,16 +102,14 @@ XChangeFeedbackControl (dpy, dev, mask, f) length = ((unsigned)(k.length + 3) >> 2); req->length += length; length <<= 2; - Data (dpy, (char *) &k, length); - } - else if (f->class == PtrFeedbackClass) - { - XPtrFeedbackControl *P; - xPtrFeedbackCtl p; + Data(dpy, (char *)&k, length); + } else if (f->class == PtrFeedbackClass) { + XPtrFeedbackControl *P; + xPtrFeedbackCtl p; P = (XPtrFeedbackControl *) f; p.class = PtrFeedbackClass; - p.length = sizeof (xPtrFeedbackCtl); + p.length = sizeof(xPtrFeedbackCtl); p.id = P->id; p.num = P->accelNum; p.denom = P->accelDenom; @@ -120,48 +117,42 @@ XChangeFeedbackControl (dpy, dev, mask, f) length = ((unsigned)(p.length + 3) >> 2); req->length += length; length <<= 2; - Data (dpy, (char *) &p, length); - } - else if (f->class == IntegerFeedbackClass) - { - XIntegerFeedbackControl *I; - xIntegerFeedbackCtl i; + Data(dpy, (char *)&p, length); + } else if (f->class == IntegerFeedbackClass) { + XIntegerFeedbackControl *I; + xIntegerFeedbackCtl i; I = (XIntegerFeedbackControl *) f; i.class = IntegerFeedbackClass; - i.length = sizeof (xIntegerFeedbackCtl); + i.length = sizeof(xIntegerFeedbackCtl); i.id = I->id; i.int_to_display = I->int_to_display; length = ((unsigned)(i.length + 3) >> 2); req->length += length; length <<= 2; - Data (dpy, (char *) &i, length); - } - else if (f->class == StringFeedbackClass) - { - XStringFeedbackControl *S; - xStringFeedbackCtl s; + Data(dpy, (char *)&i, length); + } else if (f->class == StringFeedbackClass) { + XStringFeedbackControl *S; + xStringFeedbackCtl s; S = (XStringFeedbackControl *) f; s.class = StringFeedbackClass; - s.length = sizeof (xStringFeedbackCtl) + - (S->num_keysyms * sizeof (KeySym)); + s.length = sizeof(xStringFeedbackCtl) + + (S->num_keysyms * sizeof(KeySym)); s.id = S->id; s.num_keysyms = S->num_keysyms; req->length += ((unsigned)(s.length + 3) >> 2); - length = sizeof (xStringFeedbackCtl); - Data (dpy, (char *) &s, length); - length = (s.num_keysyms * sizeof (KeySym)); - Data (dpy, (char *) S->syms_to_display, length); - } - else if (f->class == BellFeedbackClass) - { - XBellFeedbackControl *B; - xBellFeedbackCtl b; + length = sizeof(xStringFeedbackCtl); + Data(dpy, (char *)&s, length); + length = (s.num_keysyms * sizeof(KeySym)); + Data(dpy, (char *)S->syms_to_display, length); + } else if (f->class == BellFeedbackClass) { + XBellFeedbackControl *B; + xBellFeedbackCtl b; B = (XBellFeedbackControl *) f; b.class = BellFeedbackClass; - b.length = sizeof (xBellFeedbackCtl); + b.length = sizeof(xBellFeedbackCtl); b.id = B->id; b.percent = B->percent; b.pitch = B->pitch; @@ -169,39 +160,34 @@ XChangeFeedbackControl (dpy, dev, mask, f) length = ((unsigned)(b.length + 3) >> 2); req->length += length; length <<= 2; - Data (dpy, (char *) &b, length); - } - else if (f->class == LedFeedbackClass) - { - XLedFeedbackControl *L; - xLedFeedbackCtl l; + Data(dpy, (char *)&b, length); + } else if (f->class == LedFeedbackClass) { + XLedFeedbackControl *L; + xLedFeedbackCtl l; L = (XLedFeedbackControl *) f; l.class = LedFeedbackClass; - l.length = sizeof (xLedFeedbackCtl); + l.length = sizeof(xLedFeedbackCtl); l.id = L->id; l.led_mask = L->led_mask; l.led_values = L->led_values; length = ((unsigned)(l.length + 3) >> 2); req->length += length; length <<= 2; - Data (dpy, (char *) &l, length); - } - else - { - xFeedbackCtl u; + Data(dpy, (char *)&l, length); + } else { + xFeedbackCtl u; u.class = f->class; - u.length = f->length - sizeof (int); + u.length = f->length - sizeof(int); u.id = f->id; length = ((unsigned)(u.length + 3) >> 2); req->length += length; length <<= 2; - Data (dpy, (char *) &u, length); - } + Data(dpy, (char *)&u, length); + } UnlockDisplay(dpy); SyncHandle(); return (Success); - } - +} diff --git a/src/XChgKMap.c b/src/XChgKMap.c index 8ad77ca..d0a334f 100644 --- a/src/XChgKMap.c +++ b/src/XChgKMap.c @@ -61,23 +61,23 @@ SOFTWARE. #include "XIint.h" int -XChangeDeviceKeyMapping (dpy, dev, first, syms_per_code, keysyms, count) - register Display *dpy; - XDevice *dev; - int first; - int syms_per_code; - KeySym *keysyms; - int count; - { +XChangeDeviceKeyMapping(dpy, dev, first, syms_per_code, keysyms, count) + register Display *dpy; + XDevice *dev; + int first; + int syms_per_code; + KeySym *keysyms; + int count; +{ register long nbytes; xChangeDeviceKeyMappingReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(ChangeDeviceKeyMapping,req); + GetReq(ChangeDeviceKeyMapping, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ChangeDeviceKeyMapping; req->deviceid = dev->device_id; @@ -85,10 +85,10 @@ XChangeDeviceKeyMapping (dpy, dev, first, syms_per_code, keysyms, count) req->keyCodes = count; req->keySymsPerKeyCode = syms_per_code; req->length += count * syms_per_code; - nbytes = syms_per_code * count * sizeof (CARD32); - Data (dpy, (char *)keysyms, nbytes); + nbytes = syms_per_code * count * sizeof(CARD32); + Data(dpy, (char *)keysyms, nbytes); UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XChgKbd.c b/src/XChgKbd.c index b3e2c06..feba239 100644 --- a/src/XChgKbd.c +++ b/src/XChgKbd.c @@ -61,28 +61,27 @@ SOFTWARE. #include "XIint.h" int -XChangeKeyboardDevice (dpy, dev) - register Display *dpy; - XDevice *dev; - { - xChangeKeyboardDeviceReq *req; - xChangeKeyboardDeviceReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XChangeKeyboardDevice(dpy, dev) + register Display *dpy; + XDevice *dev; +{ + xChangeKeyboardDeviceReq *req; + xChangeKeyboardDeviceReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(ChangeKeyboardDevice,req); + GetReq(ChangeKeyboardDevice, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ChangeKeyboardDevice; req->deviceid = dev->device_id; rep.status = Success; - (void) _XReply (dpy, (xReply *) &rep, 0, xTrue); + (void)_XReply(dpy, (xReply *) & rep, 0, xTrue); UnlockDisplay(dpy); SyncHandle(); return (rep.status); - } - +} diff --git a/src/XChgPnt.c b/src/XChgPnt.c index c7248fd..9e0a617 100644 --- a/src/XChgPnt.c +++ b/src/XChgPnt.c @@ -61,21 +61,21 @@ SOFTWARE. #include "XIint.h" int -XChangePointerDevice (dpy, dev, xaxis, yaxis) - register Display *dpy; - XDevice *dev; - int xaxis; - int yaxis; - { - xChangePointerDeviceReq *req; - xChangePointerDeviceReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XChangePointerDevice(dpy, dev, xaxis, yaxis) + register Display *dpy; + XDevice *dev; + int xaxis; + int yaxis; +{ + xChangePointerDeviceReq *req; + xChangePointerDeviceReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(ChangePointerDevice,req); + GetReq(ChangePointerDevice, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ChangePointerDevice; req->deviceid = dev->device_id; @@ -83,10 +83,9 @@ XChangePointerDevice (dpy, dev, xaxis, yaxis) req->yaxis = yaxis; rep.status = Success; - (void) _XReply (dpy, (xReply *) &rep, 0, xTrue); + (void)_XReply(dpy, (xReply *) & rep, 0, xTrue); UnlockDisplay(dpy); SyncHandle(); return (rep.status); - } - +} diff --git a/src/XChgProp.c b/src/XChgProp.c index 3fa68cf..6939cb3 100644 --- a/src/XChgProp.c +++ b/src/XChgProp.c @@ -62,21 +62,21 @@ SOFTWARE. #include "XIint.h" int -XChangeDeviceDontPropagateList (dpy, window, count, events, mode) - register Display *dpy; - Window window; - int count; - XEventClass *events; - int mode; - { - xChangeDeviceDontPropagateListReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XChangeDeviceDontPropagateList(dpy, window, count, events, mode) + register Display *dpy; + Window window; + int count; + XEventClass *events; + int mode; +{ + xChangeDeviceDontPropagateListReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(ChangeDeviceDontPropagateList,req); + GetReq(ChangeDeviceDontPropagateList, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ChangeDeviceDontPropagateList; req->window = window; @@ -85,14 +85,13 @@ XChangeDeviceDontPropagateList (dpy, window, count, events, mode) req->length += count; /* note: Data is a macro that uses its arguments multiple - times, so "nvalues" is changed in a separate assignment - statement */ + * times, so "nvalues" is changed in a separate assignment + * statement */ count <<= 2; - Data32 (dpy, (long *) events, count); + Data32(dpy, (long *)events, count); UnlockDisplay(dpy); SyncHandle(); return (Success); - } - +} diff --git a/src/XCloseDev.c b/src/XCloseDev.c index 170843b..71e792a 100644 --- a/src/XCloseDev.c +++ b/src/XCloseDev.c @@ -62,24 +62,23 @@ SOFTWARE. int XCloseDevice(dpy, dev) - register Display *dpy; - register XDevice *dev; - { - xCloseDeviceReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); + register Display *dpy; + register XDevice *dev; +{ + xCloseDeviceReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(CloseDevice,req); + GetReq(CloseDevice, req); req->reqType = info->codes->major_opcode; req->ReqType = X_CloseDevice; req->deviceid = dev->device_id; - XFree ((char *)dev); - UnlockDisplay (dpy); + XFree((char *)dev); + UnlockDisplay(dpy); SyncHandle(); return (Success); - } - +} diff --git a/src/XDevBell.c b/src/XDevBell.c index 2b7669f..276a1b8 100644 --- a/src/XDevBell.c +++ b/src/XDevBell.c @@ -61,20 +61,20 @@ SOFTWARE. #include "XIint.h" int -XDeviceBell (dpy, dev, feedbackclass, feedbackid, percent) - register Display *dpy; - XDevice *dev; - XID feedbackclass, feedbackid; - int percent; - { - xDeviceBellReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XDeviceBell(dpy, dev, feedbackclass, feedbackid, percent) + register Display *dpy; + XDevice *dev; + XID feedbackclass, feedbackid; + int percent; +{ + xDeviceBellReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Add_XDeviceBell) == -1) return (NoSuchExtension); - GetReq(DeviceBell,req); + GetReq(DeviceBell, req); req->reqType = info->codes->major_opcode; req->ReqType = X_DeviceBell; req->deviceid = dev->device_id; @@ -85,5 +85,4 @@ XDeviceBell (dpy, dev, feedbackclass, feedbackid, percent) UnlockDisplay(dpy); SyncHandle(); return (Success); - } - +} diff --git a/src/XExtInt.c b/src/XExtInt.c index 9e569df..811c0c3 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -66,63 +66,64 @@ SOFTWARE. #define ENQUEUE_EVENT True #define DONT_ENQUEUE False -static XExtensionInfo *xinput_info; -static /* const */ char *xinput_extension_name = INAME; -static int XInputClose(); -static char *XInputError(); +static XExtensionInfo *xinput_info; +static /* const */ char *xinput_extension_name = INAME; +static int XInputClose(); +static char *XInputError(); static Bool XInputWireToEvent(); -Status _XiEventToWire(); -static /* const */ XEvent emptyevent; +Status _XiEventToWire(); +static /* const */ XEvent emptyevent; typedef struct _XInputData - { - XEvent data; - XExtensionVersion *vers; - } XInputData; +{ + XEvent data; + XExtensionVersion *vers; +} XInputData; #define XInputCheckExtension(dpy,i,val) \ XextCheckExtension (dpy, i, xinput_extension_name, val) static /* const */ XExtensionHooks xinput_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - XInputClose, /* close_display */ - XInputWireToEvent, /* wire_to_event */ - _XiEventToWire, /* event_to_wire */ - NULL, /* error */ - XInputError, /* error_string */ + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + XInputClose, /* close_display */ + XInputWireToEvent, /* wire_to_event */ + _XiEventToWire, /* event_to_wire */ + NULL, /* error */ + XInputError, /* error_string */ }; static char *XInputErrorList[] = { - "BadDevice, invalid or uninitialized input device", /* BadDevice */ - "BadEvent, invalid event type", /* BadEvent */ - "BadMode, invalid mode parameter", /* BadMode */ - "DeviceBusy, device is busy", /* DeviceBusy */ - "BadClass, invalid event class", /* BadClass */ + "BadDevice, invalid or uninitialized input device", /* BadDevice */ + "BadEvent, invalid event type", /* BadEvent */ + "BadMode, invalid mode parameter", /* BadMode */ + "DeviceBusy, device is busy", /* DeviceBusy */ + "BadClass, invalid event class", /* BadClass */ }; -XEXT_GENERATE_FIND_DISPLAY (XInput_find_display, xinput_info, - xinput_extension_name, &xinput_extension_hooks, IEVENTS, NULL) +XEXT_GENERATE_FIND_DISPLAY(XInput_find_display, xinput_info, + xinput_extension_name, &xinput_extension_hooks, + IEVENTS, NULL) -static XEXT_GENERATE_ERROR_STRING (XInputError, xinput_extension_name, - IERRORS, XInputErrorList) + static XEXT_GENERATE_ERROR_STRING(XInputError, xinput_extension_name, + IERRORS, XInputErrorList) /******************************************************************* * * Input extension versions. * */ - -static XExtensionVersion versions[] = {{XI_Absent,0,0}, - {XI_Present, XI_Initial_Release_Major, XI_Initial_Release_Minor}, - {XI_Present, XI_Add_XDeviceBell_Major, XI_Add_XDeviceBell_Minor}, - {XI_Present, XI_Add_XSetDeviceValuators_Major, - XI_Add_XSetDeviceValuators_Minor}, - {XI_Present, XI_Add_XChangeDeviceControl_Major, - XI_Add_XChangeDeviceControl_Minor}}; + static XExtensionVersion versions[] = { {XI_Absent, 0, 0}, + {XI_Present, XI_Initial_Release_Major, XI_Initial_Release_Minor}, + {XI_Present, XI_Add_XDeviceBell_Major, XI_Add_XDeviceBell_Minor}, + {XI_Present, XI_Add_XSetDeviceValuators_Major, + XI_Add_XSetDeviceValuators_Minor}, + {XI_Present, XI_Add_XChangeDeviceControl_Major, + XI_Add_XChangeDeviceControl_Minor} + }; /*********************************************************************** * @@ -130,45 +131,55 @@ static XExtensionVersion versions[] = {{XI_Absent,0,0}, * */ -void _xibaddevice (dpy, error) +void +_xibaddevice(dpy, error) Display *dpy; int *error; - { - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + XExtDisplayInfo *info = XInput_find_display(dpy); + *error = info->codes->first_error + XI_BadDevice; - } +} -void _xibadclass (dpy, error) +void +_xibadclass(dpy, error) Display *dpy; int *error; - { - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + XExtDisplayInfo *info = XInput_find_display(dpy); + *error = info->codes->first_error + XI_BadClass; - } +} -void _xibadevent (dpy, error) +void +_xibadevent(dpy, error) Display *dpy; int *error; - { - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + XExtDisplayInfo *info = XInput_find_display(dpy); + *error = info->codes->first_error + XI_BadEvent; - } +} -void _xibadmode (dpy, error) +void +_xibadmode(dpy, error) Display *dpy; int *error; - { - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + XExtDisplayInfo *info = XInput_find_display(dpy); + *error = info->codes->first_error + XI_BadMode; - } +} -void _xidevicebusy (dpy, error) +void +_xidevicebusy(dpy, error) Display *dpy; int *error; - { - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + XExtDisplayInfo *info = XInput_find_display(dpy); + *error = info->codes->first_error + XI_DeviceBusy; - } +} /*********************************************************************** * @@ -179,39 +190,35 @@ void _xidevicebusy (dpy, error) int _XiCheckExtInit(dpy, version_index) - register Display *dpy; - register int version_index; - { - XExtensionVersion *ext; - XExtDisplayInfo *info = XInput_find_display (dpy); + register Display *dpy; + register int version_index; +{ + XExtensionVersion *ext; + XExtDisplayInfo *info = XInput_find_display(dpy); - XInputCheckExtension (dpy, info, -1); + XInputCheckExtension(dpy, info, -1); - if (info->data == NULL) - { - info->data = (XPointer) Xmalloc (sizeof (XInputData)); - if (!info->data) - { - UnlockDisplay(dpy); + if (info->data == NULL) { + info->data = (XPointer) Xmalloc(sizeof(XInputData)); + if (!info->data) { + UnlockDisplay(dpy); return (-1); - } - ((XInputData *) info->data)->vers = - _XiGetExtensionVersion (dpy, "XInputExtension"); } + ((XInputData *) info->data)->vers = + _XiGetExtensionVersion(dpy, "XInputExtension"); + } - if (versions[version_index].major_version > Dont_Check) - { + if (versions[version_index].major_version > Dont_Check) { ext = ((XInputData *) info->data)->vers; if ((ext->major_version < versions[version_index].major_version) || ((ext->major_version == versions[version_index].major_version) && - (ext->minor_version < versions[version_index].minor_version))) - { - UnlockDisplay(dpy); + (ext->minor_version < versions[version_index].minor_version))) { + UnlockDisplay(dpy); return (-1); - } } - return (0); } + return (0); +} /*********************************************************************** * @@ -220,28 +227,27 @@ _XiCheckExtInit(dpy, version_index) */ static int -XInputClose (dpy, codes) +XInputClose(dpy, codes) Display *dpy; XExtCodes *codes; - { - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + XExtDisplayInfo *info = XInput_find_display(dpy); - if(info->data != NULL) { + if (info->data != NULL) { XFree((char *)((XInputData *) info->data)->vers); XFree((char *)info->data); } - return XextRemoveDisplay (xinput_info, dpy); - } - + return XextRemoveDisplay(xinput_info, dpy); +} static int -Ones(mask) +Ones(mask) Mask mask; { register Mask y; - y = (mask >> 1) &033333333333; - y = mask - y - ((y >>1) & 033333333333); + y = (mask >> 1) & 033333333333; + y = mask - y - ((y >> 1) & 033333333333); return (((y + (y >> 3)) & 030707070707) % 077); } @@ -253,411 +259,416 @@ Ones(mask) */ static Bool -XInputWireToEvent (dpy, re, event) - Display *dpy; - XEvent *re; - xEvent *event; - { - unsigned int type, reltype; - unsigned int i,j; - XExtDisplayInfo *info = XInput_find_display (dpy); - XEvent *save = (XEvent *) info->data; +XInputWireToEvent(dpy, re, event) + Display *dpy; + XEvent *re; + xEvent *event; +{ + unsigned int type, reltype; + unsigned int i, j; + XExtDisplayInfo *info = XInput_find_display(dpy); + XEvent *save = (XEvent *) info->data; type = event->u.u.type & 0x7f; reltype = (type - info->codes->first_event); - - - if (reltype != XI_DeviceValuator && + if (reltype != XI_DeviceValuator && reltype != XI_DeviceKeystateNotify && - reltype != XI_DeviceButtonstateNotify) - { + reltype != XI_DeviceButtonstateNotify) { *save = emptyevent; - save->type = type; - ((XAnyEvent *)save)->serial = _XSetLastRequestRead(dpy, - (xGenericReply *)event); - ((XAnyEvent *)save)->send_event = ((event->u.u.type & 0x80) != 0); - ((XAnyEvent *)save)->display = dpy; + save->type = type; + ((XAnyEvent *) save)->serial = _XSetLastRequestRead(dpy, + (xGenericReply *) + event); + ((XAnyEvent *) save)->send_event = ((event->u.u.type & 0x80) != 0); + ((XAnyEvent *) save)->display = dpy; + } + + switch (reltype) { + case XI_DeviceMotionNotify: + { + register XDeviceMotionEvent *ev = (XDeviceMotionEvent *) save; + deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; + + ev->root = ev2->root; + ev->window = ev2->event; + ev->subwindow = ev2->child; + ev->time = ev2->time; + ev->x_root = ev2->root_x; + ev->y_root = ev2->root_y; + ev->x = ev2->event_x; + ev->y = ev2->event_y; + ev->state = ev2->state; + ev->same_screen = ev2->same_screen; + ev->is_hint = ev2->detail; + ev->deviceid = ev2->deviceid & DEVICE_BITS; + return (DONT_ENQUEUE); + } + break; + case XI_DeviceKeyPress: + case XI_DeviceKeyRelease: + { + register XDeviceKeyEvent *ev = (XDeviceKeyEvent *) save; + deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; + + ev->root = ev2->root; + ev->window = ev2->event; + ev->subwindow = ev2->child; + ev->time = ev2->time; + ev->x_root = ev2->root_x; + ev->y_root = ev2->root_y; + ev->x = ev2->event_x; + ev->y = ev2->event_y; + ev->state = ev2->state; + ev->same_screen = ev2->same_screen; + ev->keycode = ev2->detail; + ev->deviceid = ev2->deviceid & DEVICE_BITS; + if (ev2->deviceid & MORE_EVENTS) + return (DONT_ENQUEUE); + else { + *re = *save; + return (ENQUEUE_EVENT); } - - switch (reltype) - { - case XI_DeviceMotionNotify: - { - register XDeviceMotionEvent *ev = (XDeviceMotionEvent*) save; - deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; - - ev->root = ev2->root; - ev->window = ev2->event; - ev->subwindow = ev2->child; - ev->time = ev2->time; - ev->x_root = ev2->root_x; - ev->y_root = ev2->root_y; - ev->x = ev2->event_x; - ev->y = ev2->event_y; - ev->state = ev2->state; - ev->same_screen = ev2->same_screen; - ev->is_hint = ev2->detail; - ev->deviceid = ev2->deviceid & DEVICE_BITS; - return (DONT_ENQUEUE); - } - break; - case XI_DeviceKeyPress: - case XI_DeviceKeyRelease: - { - register XDeviceKeyEvent *ev = (XDeviceKeyEvent*) save; - deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; - - ev->root = ev2->root; - ev->window = ev2->event; - ev->subwindow = ev2->child; - ev->time = ev2->time; - ev->x_root = ev2->root_x; - ev->y_root = ev2->root_y; - ev->x = ev2->event_x; - ev->y = ev2->event_y; - ev->state = ev2->state; - ev->same_screen = ev2->same_screen; - ev->keycode = ev2->detail; - ev->deviceid = ev2->deviceid & DEVICE_BITS; - if (ev2->deviceid & MORE_EVENTS) - return (DONT_ENQUEUE); - else - { - *re = *save; - return (ENQUEUE_EVENT); - } - } - break; - case XI_DeviceButtonPress: - case XI_DeviceButtonRelease: - { - register XDeviceButtonEvent *ev = (XDeviceButtonEvent*) save; - deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; - - ev->root = ev2->root; - ev->window = ev2->event; - ev->subwindow = ev2->child; - ev->time = ev2->time; - ev->x_root = ev2->root_x; - ev->y_root = ev2->root_y; - ev->x = ev2->event_x; - ev->y = ev2->event_y; - ev->state = ev2->state; - ev->same_screen = ev2->same_screen; - ev->button = ev2->detail; - ev->deviceid = ev2->deviceid & DEVICE_BITS; - if (ev2->deviceid & MORE_EVENTS) - return (DONT_ENQUEUE); - else - { - *re = *save; - return (ENQUEUE_EVENT); - } - } - break; - case XI_ProximityIn: - case XI_ProximityOut: - { - register XProximityNotifyEvent *ev = - (XProximityNotifyEvent *) save; - deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; - - ev->root = ev2->root; - ev->window = ev2->event; - ev->subwindow = ev2->child; - ev->time = ev2->time; - ev->x_root = ev2->root_x; - ev->y_root = ev2->root_y; - ev->x = ev2->event_x; - ev->y = ev2->event_y; - ev->state = ev2->state; - ev->same_screen = ev2->same_screen; - ev->deviceid = ev2->deviceid & DEVICE_BITS; - if (ev2->deviceid & MORE_EVENTS) - return (DONT_ENQUEUE); - else - { - *re = *save; - return (ENQUEUE_EVENT); - } - } - break; - case XI_DeviceValuator: - { - deviceValuator *xev = (deviceValuator *) event; - int save_type = save->type - info->codes->first_event; - - if (save_type == XI_DeviceKeyPress || - save_type == XI_DeviceKeyRelease) - { - XDeviceKeyEvent *kev = (XDeviceKeyEvent*) save; - kev->device_state = xev->device_state; - kev->axes_count = xev->num_valuators; - kev->first_axis = xev->first_valuator; - i = xev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: kev->axis_data[5] = xev->valuator5; - case 5: kev->axis_data[4] = xev->valuator4; - case 4: kev->axis_data[3] = xev->valuator3; - case 3: kev->axis_data[2] = xev->valuator2; - case 2: kev->axis_data[1] = xev->valuator1; - case 1: kev->axis_data[0] = xev->valuator0; - } - } - else if (save_type == XI_DeviceButtonPress || - save_type == XI_DeviceButtonRelease) - { - XDeviceButtonEvent *bev = (XDeviceButtonEvent*) save; - bev->device_state = xev->device_state; - bev->axes_count = xev->num_valuators; - bev->first_axis = xev->first_valuator; - i = xev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: bev->axis_data[5] = xev->valuator5; - case 5: bev->axis_data[4] = xev->valuator4; - case 4: bev->axis_data[3] = xev->valuator3; - case 3: bev->axis_data[2] = xev->valuator2; - case 2: bev->axis_data[1] = xev->valuator1; - case 1: bev->axis_data[0] = xev->valuator0; - } - } - else if (save_type == XI_DeviceMotionNotify) - { - XDeviceMotionEvent *mev = (XDeviceMotionEvent*) save; - mev->device_state = xev->device_state; - mev->axes_count = xev->num_valuators; - mev->first_axis = xev->first_valuator; - i = xev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: mev->axis_data[5] = xev->valuator5; - case 5: mev->axis_data[4] = xev->valuator4; - case 4: mev->axis_data[3] = xev->valuator3; - case 3: mev->axis_data[2] = xev->valuator2; - case 2: mev->axis_data[1] = xev->valuator1; - case 1: mev->axis_data[0] = xev->valuator0; - } - } - else if (save_type == XI_ProximityIn || - save_type == XI_ProximityOut) - { - XProximityNotifyEvent *pev = - (XProximityNotifyEvent*) save; - pev->device_state = xev->device_state; - pev->axes_count = xev->num_valuators; - pev->first_axis = xev->first_valuator; - i = xev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: pev->axis_data[5] = xev->valuator5; - case 5: pev->axis_data[4] = xev->valuator4; - case 4: pev->axis_data[3] = xev->valuator3; - case 3: pev->axis_data[2] = xev->valuator2; - case 2: pev->axis_data[1] = xev->valuator1; - case 1: pev->axis_data[0] = xev->valuator0; - } - } - else if (save_type == XI_DeviceStateNotify) - { - XDeviceStateNotifyEvent *sev = - (XDeviceStateNotifyEvent*) save; - XInputClass *any = (XInputClass *) &sev->data[0]; - XValuatorStatus *v; - - for (i=0; i<sev->num_classes; i++) - if (any->class != ValuatorClass) - any = (XInputClass *) ((char *) any + any->length); - v = (XValuatorStatus *) any; - i = v->num_valuators; - j = xev->num_valuators; - if (j > 3) j = 3; - switch (j) - { - case 3: v->valuators[i + 2] = xev->valuator2; - case 2: v->valuators[i + 1] = xev->valuator1; - case 1: v->valuators[i + 0] = xev->valuator0; - } - v->num_valuators += j; - - } + } + break; + case XI_DeviceButtonPress: + case XI_DeviceButtonRelease: + { + register XDeviceButtonEvent *ev = (XDeviceButtonEvent *) save; + deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; + + ev->root = ev2->root; + ev->window = ev2->event; + ev->subwindow = ev2->child; + ev->time = ev2->time; + ev->x_root = ev2->root_x; + ev->y_root = ev2->root_y; + ev->x = ev2->event_x; + ev->y = ev2->event_y; + ev->state = ev2->state; + ev->same_screen = ev2->same_screen; + ev->button = ev2->detail; + ev->deviceid = ev2->deviceid & DEVICE_BITS; + if (ev2->deviceid & MORE_EVENTS) + return (DONT_ENQUEUE); + else { *re = *save; return (ENQUEUE_EVENT); + } + } + break; + case XI_ProximityIn: + case XI_ProximityOut: + { + register XProximityNotifyEvent *ev = (XProximityNotifyEvent *) save; + deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event; + + ev->root = ev2->root; + ev->window = ev2->event; + ev->subwindow = ev2->child; + ev->time = ev2->time; + ev->x_root = ev2->root_x; + ev->y_root = ev2->root_y; + ev->x = ev2->event_x; + ev->y = ev2->event_y; + ev->state = ev2->state; + ev->same_screen = ev2->same_screen; + ev->deviceid = ev2->deviceid & DEVICE_BITS; + if (ev2->deviceid & MORE_EVENTS) + return (DONT_ENQUEUE); + else { + *re = *save; + return (ENQUEUE_EVENT); + } + } + break; + case XI_DeviceValuator: + { + deviceValuator *xev = (deviceValuator *) event; + int save_type = save->type - info->codes->first_event; + + if (save_type == XI_DeviceKeyPress || save_type == XI_DeviceKeyRelease) { + XDeviceKeyEvent *kev = (XDeviceKeyEvent *) save; + + kev->device_state = xev->device_state; + kev->axes_count = xev->num_valuators; + kev->first_axis = xev->first_valuator; + i = xev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + kev->axis_data[5] = xev->valuator5; + case 5: + kev->axis_data[4] = xev->valuator4; + case 4: + kev->axis_data[3] = xev->valuator3; + case 3: + kev->axis_data[2] = xev->valuator2; + case 2: + kev->axis_data[1] = xev->valuator1; + case 1: + kev->axis_data[0] = xev->valuator0; } - break; - case XI_DeviceFocusIn: - case XI_DeviceFocusOut: - { - register XDeviceFocusChangeEvent *ev = - (XDeviceFocusChangeEvent *) re; - deviceFocus *fev = (deviceFocus *) event; - - *ev = *((XDeviceFocusChangeEvent *) save); - ev->window = fev->window; - ev->time = fev->time; - ev->mode = fev->mode; - ev->detail = fev->detail; - ev->deviceid = fev->deviceid & DEVICE_BITS; - return (ENQUEUE_EVENT); - } - break; - case XI_DeviceStateNotify: - { - XDeviceStateNotifyEvent *stev = - (XDeviceStateNotifyEvent *) save; - deviceStateNotify *sev = (deviceStateNotify *) event; - char *data; - - stev->window = None; - stev->deviceid = sev->deviceid & DEVICE_BITS; - stev->time = sev->time; - stev->num_classes = Ones ((Mask)sev->classes_reported & InputClassBits); - data = (char *) &stev->data[0]; - if (sev->classes_reported & (1 << KeyClass)) - { - register XKeyStatus *kstev = (XKeyStatus *) data; - kstev->class = KeyClass; - kstev->length = sizeof (XKeyStatus); - kstev->num_keys = sev->num_keys; - memcpy ((char *) &kstev->keys[0], (char *) &sev->keys[0], 4); - data += sizeof (XKeyStatus); - } - if (sev->classes_reported & (1 << ButtonClass)) - { - register XButtonStatus *bev = (XButtonStatus *) data; - bev->class = ButtonClass; - bev->length = sizeof (XButtonStatus); - bev->num_buttons = sev->num_buttons; - memcpy ((char *) bev->buttons, (char *) sev->buttons, 4); - data += sizeof (XButtonStatus); - } - if (sev->classes_reported & (1 << ValuatorClass)) - { - register XValuatorStatus *vev = (XValuatorStatus *) data; - vev->class = ValuatorClass; - vev->length = sizeof (XValuatorStatus); - vev->num_valuators = sev->num_valuators; - vev->mode = sev->classes_reported >> ModeBitsShift; - j = sev->num_valuators; - if (j > 3) j = 3; - switch (j) - { - case 3: vev->valuators[2] = sev->valuator2; - case 2: vev->valuators[1] = sev->valuator1; - case 1: vev->valuators[0] = sev->valuator0; - } - data += sizeof (XValuatorStatus); - } - if (sev->deviceid & MORE_EVENTS) - return (DONT_ENQUEUE); - else - { - *re = *save; - stev = (XDeviceStateNotifyEvent *) re; - return (ENQUEUE_EVENT); - } + } else if (save_type == XI_DeviceButtonPress || + save_type == XI_DeviceButtonRelease) { + XDeviceButtonEvent *bev = (XDeviceButtonEvent *) save; + + bev->device_state = xev->device_state; + bev->axes_count = xev->num_valuators; + bev->first_axis = xev->first_valuator; + i = xev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + bev->axis_data[5] = xev->valuator5; + case 5: + bev->axis_data[4] = xev->valuator4; + case 4: + bev->axis_data[3] = xev->valuator3; + case 3: + bev->axis_data[2] = xev->valuator2; + case 2: + bev->axis_data[1] = xev->valuator1; + case 1: + bev->axis_data[0] = xev->valuator0; } - break; - case XI_DeviceKeystateNotify: - { - int i; - XInputClass *anyclass; - register XKeyStatus *kv; - deviceKeyStateNotify *ksev = (deviceKeyStateNotify *) event; - XDeviceStateNotifyEvent *kstev = - (XDeviceStateNotifyEvent *) save; - - anyclass = (XInputClass *) &kstev->data[0]; - for (i=0; i<kstev->num_classes; i++) - if (anyclass->class == KeyClass) - break; - else - anyclass = (XInputClass *) ((char *) anyclass + - anyclass->length); - - kv = (XKeyStatus *) anyclass; - kv->num_keys = 256; - memcpy ((char *) &kv->keys[4], (char *) ksev->keys, 28); - if (ksev->deviceid & MORE_EVENTS) - return (DONT_ENQUEUE); - else - { - *re = *save; - kstev = (XDeviceStateNotifyEvent *) re; - return (ENQUEUE_EVENT); - } + } else if (save_type == XI_DeviceMotionNotify) { + XDeviceMotionEvent *mev = (XDeviceMotionEvent *) save; + + mev->device_state = xev->device_state; + mev->axes_count = xev->num_valuators; + mev->first_axis = xev->first_valuator; + i = xev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + mev->axis_data[5] = xev->valuator5; + case 5: + mev->axis_data[4] = xev->valuator4; + case 4: + mev->axis_data[3] = xev->valuator3; + case 3: + mev->axis_data[2] = xev->valuator2; + case 2: + mev->axis_data[1] = xev->valuator1; + case 1: + mev->axis_data[0] = xev->valuator0; } - break; - case XI_DeviceButtonstateNotify: - { - int i; - XInputClass *anyclass; - register XButtonStatus *bv; - deviceButtonStateNotify *bsev = (deviceButtonStateNotify *) event; - XDeviceStateNotifyEvent *bstev = - (XDeviceStateNotifyEvent *) save; - - - anyclass = (XInputClass *) &bstev->data[0]; - for (i=0; i<bstev->num_classes; i++) - if (anyclass->class == ButtonClass) - break; - else - anyclass = (XInputClass *) ((char *) anyclass + - anyclass->length); - - bv = (XButtonStatus *) anyclass; - bv->num_buttons = 256; - memcpy ((char *) &bv->buttons[4], (char *) bsev->buttons, 28); - if (bsev->deviceid & MORE_EVENTS) - return (DONT_ENQUEUE); - else - { - *re = *save; - bstev = (XDeviceStateNotifyEvent *) re; - return (ENQUEUE_EVENT); - } + } else if (save_type == XI_ProximityIn || save_type == XI_ProximityOut) { + XProximityNotifyEvent *pev = (XProximityNotifyEvent *) save; + + pev->device_state = xev->device_state; + pev->axes_count = xev->num_valuators; + pev->first_axis = xev->first_valuator; + i = xev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + pev->axis_data[5] = xev->valuator5; + case 5: + pev->axis_data[4] = xev->valuator4; + case 4: + pev->axis_data[3] = xev->valuator3; + case 3: + pev->axis_data[2] = xev->valuator2; + case 2: + pev->axis_data[1] = xev->valuator1; + case 1: + pev->axis_data[0] = xev->valuator0; } - break; - case XI_DeviceMappingNotify: - { - register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re; - deviceMappingNotify *ev2 = (deviceMappingNotify *) event; - - *ev = *((XDeviceMappingEvent *) save); - ev->window = 0; - ev->first_keycode = ev2->firstKeyCode; - ev->request = ev2->request; - ev->count = ev2->count; - ev->time = ev2->time; - ev->deviceid = ev2->deviceid & DEVICE_BITS; - return (ENQUEUE_EVENT); + } else if (save_type == XI_DeviceStateNotify) { + XDeviceStateNotifyEvent *sev = (XDeviceStateNotifyEvent *) save; + XInputClass *any = (XInputClass *) & sev->data[0]; + XValuatorStatus *v; + + for (i = 0; i < sev->num_classes; i++) + if (any->class != ValuatorClass) + any = (XInputClass *) ((char *)any + any->length); + v = (XValuatorStatus *) any; + i = v->num_valuators; + j = xev->num_valuators; + if (j > 3) + j = 3; + switch (j) { + case 3: + v->valuators[i + 2] = xev->valuator2; + case 2: + v->valuators[i + 1] = xev->valuator1; + case 1: + v->valuators[i + 0] = xev->valuator0; } - break; - case XI_ChangeDeviceNotify: - { - register XChangeDeviceNotifyEvent *ev = - (XChangeDeviceNotifyEvent *) re; - changeDeviceNotify *ev2 = (changeDeviceNotify *) event; - - *ev = *((XChangeDeviceNotifyEvent *) save); - ev->window = 0; - ev->request = ev2->request; - ev->time = ev2->time; - ev->deviceid = ev2->deviceid & DEVICE_BITS; - return (ENQUEUE_EVENT); + v->num_valuators += j; + + } + *re = *save; + return (ENQUEUE_EVENT); + } + break; + case XI_DeviceFocusIn: + case XI_DeviceFocusOut: + { + register XDeviceFocusChangeEvent *ev = (XDeviceFocusChangeEvent *) re; + deviceFocus *fev = (deviceFocus *) event; + + *ev = *((XDeviceFocusChangeEvent *) save); + ev->window = fev->window; + ev->time = fev->time; + ev->mode = fev->mode; + ev->detail = fev->detail; + ev->deviceid = fev->deviceid & DEVICE_BITS; + return (ENQUEUE_EVENT); + } + break; + case XI_DeviceStateNotify: + { + XDeviceStateNotifyEvent *stev = (XDeviceStateNotifyEvent *) save; + deviceStateNotify *sev = (deviceStateNotify *) event; + char *data; + + stev->window = None; + stev->deviceid = sev->deviceid & DEVICE_BITS; + stev->time = sev->time; + stev->num_classes = Ones((Mask) sev->classes_reported & InputClassBits); + data = (char *)&stev->data[0]; + if (sev->classes_reported & (1 << KeyClass)) { + register XKeyStatus *kstev = (XKeyStatus *) data; + + kstev->class = KeyClass; + kstev->length = sizeof(XKeyStatus); + kstev->num_keys = sev->num_keys; + memcpy((char *)&kstev->keys[0], (char *)&sev->keys[0], 4); + data += sizeof(XKeyStatus); + } + if (sev->classes_reported & (1 << ButtonClass)) { + register XButtonStatus *bev = (XButtonStatus *) data; + + bev->class = ButtonClass; + bev->length = sizeof(XButtonStatus); + bev->num_buttons = sev->num_buttons; + memcpy((char *)bev->buttons, (char *)sev->buttons, 4); + data += sizeof(XButtonStatus); + } + if (sev->classes_reported & (1 << ValuatorClass)) { + register XValuatorStatus *vev = (XValuatorStatus *) data; + + vev->class = ValuatorClass; + vev->length = sizeof(XValuatorStatus); + vev->num_valuators = sev->num_valuators; + vev->mode = sev->classes_reported >> ModeBitsShift; + j = sev->num_valuators; + if (j > 3) + j = 3; + switch (j) { + case 3: + vev->valuators[2] = sev->valuator2; + case 2: + vev->valuators[1] = sev->valuator1; + case 1: + vev->valuators[0] = sev->valuator0; } - break; - default: - printf ("XInputWireToEvent: UNKNOWN WIRE EVENT! type=%d\n",type); - break; + data += sizeof(XValuatorStatus); + } + if (sev->deviceid & MORE_EVENTS) + return (DONT_ENQUEUE); + else { + *re = *save; + stev = (XDeviceStateNotifyEvent *) re; + return (ENQUEUE_EVENT); + } + } + break; + case XI_DeviceKeystateNotify: + { + int i; + XInputClass *anyclass; + register XKeyStatus *kv; + deviceKeyStateNotify *ksev = (deviceKeyStateNotify *) event; + XDeviceStateNotifyEvent *kstev = (XDeviceStateNotifyEvent *) save; + + anyclass = (XInputClass *) & kstev->data[0]; + for (i = 0; i < kstev->num_classes; i++) + if (anyclass->class == KeyClass) + break; + else + anyclass = (XInputClass *) ((char *)anyclass + + anyclass->length); + + kv = (XKeyStatus *) anyclass; + kv->num_keys = 256; + memcpy((char *)&kv->keys[4], (char *)ksev->keys, 28); + if (ksev->deviceid & MORE_EVENTS) + return (DONT_ENQUEUE); + else { + *re = *save; + kstev = (XDeviceStateNotifyEvent *) re; + return (ENQUEUE_EVENT); + } + } + break; + case XI_DeviceButtonstateNotify: + { + int i; + XInputClass *anyclass; + register XButtonStatus *bv; + deviceButtonStateNotify *bsev = (deviceButtonStateNotify *) event; + XDeviceStateNotifyEvent *bstev = (XDeviceStateNotifyEvent *) save; + + anyclass = (XInputClass *) & bstev->data[0]; + for (i = 0; i < bstev->num_classes; i++) + if (anyclass->class == ButtonClass) + break; + else + anyclass = (XInputClass *) ((char *)anyclass + + anyclass->length); + + bv = (XButtonStatus *) anyclass; + bv->num_buttons = 256; + memcpy((char *)&bv->buttons[4], (char *)bsev->buttons, 28); + if (bsev->deviceid & MORE_EVENTS) + return (DONT_ENQUEUE); + else { + *re = *save; + bstev = (XDeviceStateNotifyEvent *) re; + return (ENQUEUE_EVENT); } + } + break; + case XI_DeviceMappingNotify: + { + register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re; + deviceMappingNotify *ev2 = (deviceMappingNotify *) event; + + *ev = *((XDeviceMappingEvent *) save); + ev->window = 0; + ev->first_keycode = ev2->firstKeyCode; + ev->request = ev2->request; + ev->count = ev2->count; + ev->time = ev2->time; + ev->deviceid = ev2->deviceid & DEVICE_BITS; + return (ENQUEUE_EVENT); + } + break; + case XI_ChangeDeviceNotify: + { + register XChangeDeviceNotifyEvent *ev = (XChangeDeviceNotifyEvent *) re; + changeDeviceNotify *ev2 = (changeDeviceNotify *) event; + + *ev = *((XChangeDeviceNotifyEvent *) save); + ev->window = 0; + ev->request = ev2->request; + ev->time = ev2->time; + ev->deviceid = ev2->deviceid & DEVICE_BITS; + return (ENQUEUE_EVENT); + } + break; + default: + printf("XInputWireToEvent: UNKNOWN WIRE EVENT! type=%d\n", type); + break; + } return (DONT_ENQUEUE); - } +} diff --git a/src/XExtToWire.c b/src/XExtToWire.c index 30f0140..213da32 100644 --- a/src/XExtToWire.c +++ b/src/XExtToWire.c @@ -67,386 +67,395 @@ _XiEventToWire(dpy, re, event, count) register XEvent *re; /* pointer to client event */ register xEvent **event; /* wire protocol event */ register int *count; - { - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + XExtDisplayInfo *info = XInput_find_display(dpy); int i; - switch ((re->type & 0x7f) - info->codes->first_event) - { - case XI_DeviceKeyPress: - case XI_DeviceKeyRelease: - { - register XDeviceKeyEvent *ev = (XDeviceKeyEvent*) re; - register deviceKeyButtonPointer *kev; - register deviceValuator *vev; - - *count = 2; - kev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent)); - if (!kev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) kev; - - kev->type = ev->type; - kev->root = ev->root; - kev->event = ev->window; - kev->child = ev->subwindow; - kev->time = ev->time; - kev->event_x = ev->x ; - kev->event_y = ev->y ; - kev->root_x = ev->x_root; - kev->root_y = ev->y_root; - kev->state = ev->state; - kev->same_screen = ev->same_screen; - kev->detail = ev->keycode; - kev->deviceid = ev->deviceid | MORE_EVENTS; - - vev = (deviceValuator *) ++kev; - vev->type = info->codes->first_event + XI_DeviceValuator; - vev->deviceid = ev->deviceid; - vev->device_state = ev->device_state; - vev->first_valuator = ev->first_axis; - vev->num_valuators = ev->axes_count; - i = vev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: vev->valuator5 = ev->axis_data[5]; - case 5: vev->valuator4 = ev->axis_data[4]; - case 4: vev->valuator3 = ev->axis_data[3]; - case 3: vev->valuator2 = ev->axis_data[2]; - case 2: vev->valuator1 = ev->axis_data[1]; - case 1: vev->valuator0 = ev->axis_data[0]; - } - break; - } - case XI_ProximityIn: - case XI_ProximityOut: - { - register XProximityNotifyEvent *ev = - (XProximityNotifyEvent *) re; - register deviceKeyButtonPointer *pev; - register deviceValuator *vev; - - *count = 2; - pev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent)); - if (!pev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) pev; - - pev->type = ev->type; - pev->root = ev->root; - pev->event = ev->window; - pev->child = ev->subwindow; - pev->time = ev->time; - pev->event_x = ev->x ; - pev->event_y = ev->y ; - pev->root_x = ev->x_root; - pev->root_y = ev->y_root; - pev->state = ev->state; - pev->same_screen = ev->same_screen; - pev->deviceid = ev->deviceid | MORE_EVENTS; - - vev = (deviceValuator *) ++pev; - vev->type = info->codes->first_event + XI_DeviceValuator; - vev->deviceid = ev->deviceid; - vev->device_state = ev->device_state; - vev->first_valuator = ev->first_axis; - vev->num_valuators = ev->axes_count; - - i = vev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: vev->valuator5 = ev->axis_data[5]; - case 5: vev->valuator4 = ev->axis_data[4]; - case 4: vev->valuator3 = ev->axis_data[3]; - case 3: vev->valuator2 = ev->axis_data[2]; - case 2: vev->valuator1 = ev->axis_data[1]; - case 1: vev->valuator0 = ev->axis_data[0]; - } - break; + switch ((re->type & 0x7f) - info->codes->first_event) { + case XI_DeviceKeyPress: + case XI_DeviceKeyRelease: + { + register XDeviceKeyEvent *ev = (XDeviceKeyEvent *) re; + register deviceKeyButtonPointer *kev; + register deviceValuator *vev; + + *count = 2; + kev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); + if (!kev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) kev; + + kev->type = ev->type; + kev->root = ev->root; + kev->event = ev->window; + kev->child = ev->subwindow; + kev->time = ev->time; + kev->event_x = ev->x; + kev->event_y = ev->y; + kev->root_x = ev->x_root; + kev->root_y = ev->y_root; + kev->state = ev->state; + kev->same_screen = ev->same_screen; + kev->detail = ev->keycode; + kev->deviceid = ev->deviceid | MORE_EVENTS; + + vev = (deviceValuator *)++ kev; + vev->type = info->codes->first_event + XI_DeviceValuator; + vev->deviceid = ev->deviceid; + vev->device_state = ev->device_state; + vev->first_valuator = ev->first_axis; + vev->num_valuators = ev->axes_count; + i = vev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + vev->valuator5 = ev->axis_data[5]; + case 5: + vev->valuator4 = ev->axis_data[4]; + case 4: + vev->valuator3 = ev->axis_data[3]; + case 3: + vev->valuator2 = ev->axis_data[2]; + case 2: + vev->valuator1 = ev->axis_data[1]; + case 1: + vev->valuator0 = ev->axis_data[0]; + } + break; + } + case XI_ProximityIn: + case XI_ProximityOut: + { + register XProximityNotifyEvent *ev = (XProximityNotifyEvent *) re; + register deviceKeyButtonPointer *pev; + register deviceValuator *vev; + + *count = 2; + pev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); + if (!pev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) pev; + + pev->type = ev->type; + pev->root = ev->root; + pev->event = ev->window; + pev->child = ev->subwindow; + pev->time = ev->time; + pev->event_x = ev->x; + pev->event_y = ev->y; + pev->root_x = ev->x_root; + pev->root_y = ev->y_root; + pev->state = ev->state; + pev->same_screen = ev->same_screen; + pev->deviceid = ev->deviceid | MORE_EVENTS; + + vev = (deviceValuator *)++ pev; + vev->type = info->codes->first_event + XI_DeviceValuator; + vev->deviceid = ev->deviceid; + vev->device_state = ev->device_state; + vev->first_valuator = ev->first_axis; + vev->num_valuators = ev->axes_count; + + i = vev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + vev->valuator5 = ev->axis_data[5]; + case 5: + vev->valuator4 = ev->axis_data[4]; + case 4: + vev->valuator3 = ev->axis_data[3]; + case 3: + vev->valuator2 = ev->axis_data[2]; + case 2: + vev->valuator1 = ev->axis_data[1]; + case 1: + vev->valuator0 = ev->axis_data[0]; + } + break; + } + case XI_DeviceButtonPress: + case XI_DeviceButtonRelease: + { + register XDeviceButtonEvent *ev = (XDeviceButtonEvent *) re; + register deviceKeyButtonPointer *bev; + register deviceValuator *vev; + + *count = 2; + bev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); + if (!bev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) bev; + + bev->type = ev->type; + bev->root = ev->root; + bev->event = ev->window; + bev->child = ev->subwindow; + bev->time = ev->time; + bev->event_x = ev->x; + bev->event_y = ev->y; + bev->root_x = ev->x_root; + bev->root_y = ev->y_root; + bev->state = ev->state; + bev->same_screen = ev->same_screen; + bev->detail = ev->button; + bev->deviceid = ev->deviceid | MORE_EVENTS; + + vev = (deviceValuator *)++ bev; + vev->type = info->codes->first_event + XI_DeviceValuator; + vev->deviceid = ev->deviceid; + vev->device_state = ev->device_state; + vev->first_valuator = ev->first_axis; + vev->num_valuators = ev->axes_count; + + i = vev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + vev->valuator5 = ev->axis_data[5]; + case 5: + vev->valuator4 = ev->axis_data[4]; + case 4: + vev->valuator3 = ev->axis_data[3]; + case 3: + vev->valuator2 = ev->axis_data[2]; + case 2: + vev->valuator1 = ev->axis_data[1]; + case 1: + vev->valuator0 = ev->axis_data[0]; + } + break; + } + case XI_DeviceMotionNotify: + { + register XDeviceMotionEvent *ev = (XDeviceMotionEvent *) re; + register deviceKeyButtonPointer *mev; + register deviceValuator *vev; + + *count = 2; + mev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); + if (!mev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) mev; + + mev->type = ev->type; + mev->root = ev->root; + mev->event = ev->window; + mev->child = ev->subwindow; + mev->time = ev->time; + mev->event_x = ev->x; + mev->event_y = ev->y; + mev->root_x = ev->x_root; + mev->root_y = ev->y_root; + mev->state = ev->state; + mev->same_screen = ev->same_screen; + mev->detail = ev->is_hint; + mev->deviceid = ev->deviceid | MORE_EVENTS; + + vev = (deviceValuator *)++ mev; + vev->type = info->codes->first_event + XI_DeviceValuator; + vev->deviceid = ev->deviceid; + vev->device_state = ev->device_state; + vev->first_valuator = ev->first_axis; + vev->num_valuators = ev->axes_count; + + i = vev->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + vev->valuator5 = ev->axis_data[5]; + case 5: + vev->valuator4 = ev->axis_data[4]; + case 4: + vev->valuator3 = ev->axis_data[3]; + case 3: + vev->valuator2 = ev->axis_data[2]; + case 2: + vev->valuator1 = ev->axis_data[1]; + case 1: + vev->valuator0 = ev->axis_data[0]; + } + break; + } + case XI_DeviceFocusIn: + case XI_DeviceFocusOut: + { + register XDeviceFocusChangeEvent *ev = (XDeviceFocusChangeEvent *) re; + register deviceFocus *fev; + + *count = 1; + fev = (deviceFocus *) Xmalloc(*count * sizeof(xEvent)); + if (!fev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) fev; + + fev->type = ev->type; + fev->window = ev->window; + fev->mode = ev->mode; + fev->detail = ev->detail; + fev->time = ev->time; + fev->deviceid = ev->deviceid; + break; + } + case XI_DeviceMappingNotify: + { + register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re; + register deviceMappingNotify *mev; + + *count = 1; + mev = (deviceMappingNotify *) Xmalloc(*count * sizeof(xEvent)); + if (!mev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) mev; + + mev->type = ev->type; + mev->firstKeyCode = ev->first_keycode; + mev->request = ev->request; + mev->count = ev->count; + mev->time = ev->time; + mev->deviceid = ev->deviceid; + break; + } + case XI_DeviceStateNotify: + { + register XDeviceStateNotifyEvent *ev = (XDeviceStateNotifyEvent *) re; + register deviceStateNotify *sev; + register xEvent *tev; + XInputClass *any = (XInputClass *) & ev->data[0]; + unsigned char *sav_id; + + *count = 1; + + for (i = 0; i < ev->num_classes; i++) { + if (any->class == KeyClass) { + XKeyStatus *k = (XKeyStatus *) any; + + if (k->num_keys > 32) + (*count)++; + } else if (any->class == ButtonClass) { + XButtonStatus *b = (XButtonStatus *) any; + + if (b->num_buttons > 32) + (*count)++; + } else if (any->class == ValuatorClass) { + XValuatorStatus *v = (XValuatorStatus *) any; + + if (v->num_valuators > 3) + (*count)++; } - case XI_DeviceButtonPress: - case XI_DeviceButtonRelease: - { - register XDeviceButtonEvent *ev = - (XDeviceButtonEvent *) re; - register deviceKeyButtonPointer *bev; - register deviceValuator *vev; - - *count = 2; - bev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent)); - if (!bev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) bev; - - bev->type = ev->type; - bev->root = ev->root; - bev->event = ev->window; - bev->child = ev->subwindow; - bev->time = ev->time; - bev->event_x = ev->x ; - bev->event_y = ev->y ; - bev->root_x = ev->x_root; - bev->root_y = ev->y_root; - bev->state = ev->state; - bev->same_screen = ev->same_screen; - bev->detail = ev->button; - bev->deviceid = ev->deviceid | MORE_EVENTS; - - vev = (deviceValuator *) ++bev; - vev->type = info->codes->first_event + XI_DeviceValuator; - vev->deviceid = ev->deviceid; - vev->device_state = ev->device_state; - vev->first_valuator = ev->first_axis; - vev->num_valuators = ev->axes_count; - - i = vev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: vev->valuator5 = ev->axis_data[5]; - case 5: vev->valuator4 = ev->axis_data[4]; - case 4: vev->valuator3 = ev->axis_data[3]; - case 3: vev->valuator2 = ev->axis_data[2]; - case 2: vev->valuator1 = ev->axis_data[1]; - case 1: vev->valuator0 = ev->axis_data[0]; + any = (XInputClass *) ((char *)any + any->length); + } + + sev = (deviceStateNotify *) Xmalloc(*count * sizeof(xEvent)); + if (!sev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) sev; + tev = (xEvent *) (sev + 1); + + sev->type = ev->type; + sev->deviceid = ev->deviceid; + sav_id = &(sev->deviceid); + sev->time = ev->time; + sev->classes_reported = 0; + + any = (XInputClass *) & ev->data[0]; + for (i = 0; i < ev->num_classes; i++) { + if (any->class == KeyClass) { + XKeyStatus *k = (XKeyStatus *) any; + register deviceKeyStateNotify *kev; + + sev->classes_reported |= (1 << KeyClass); + sev->num_keys = k->num_keys; + memcpy((char *)(sev->keys), (char *)(k->keys), 4); + if (k->num_keys > 32) { + kev = (deviceKeyStateNotify *) tev++; + kev->type = info->codes->first_event + + XI_DeviceKeystateNotify; + kev->deviceid = ev->deviceid; + *sav_id |= MORE_EVENTS; + sav_id = &(kev->deviceid); + memcpy((char *)(kev->keys), (char *)(&k->keys[4]), 28); } - break; - } - case XI_DeviceMotionNotify: - { - register XDeviceMotionEvent *ev = - (XDeviceMotionEvent *)re; - register deviceKeyButtonPointer *mev; - register deviceValuator *vev; - - *count = 2; - mev = (deviceKeyButtonPointer *) Xmalloc (*count * sizeof (xEvent)); - if (!mev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) mev; - - mev->type = ev->type; - mev->root = ev->root; - mev->event = ev->window; - mev->child = ev->subwindow; - mev->time = ev->time; - mev->event_x = ev->x ; - mev->event_y = ev->y ; - mev->root_x = ev->x_root; - mev->root_y = ev->y_root; - mev->state = ev->state; - mev->same_screen = ev->same_screen; - mev->detail = ev->is_hint; - mev->deviceid = ev->deviceid | MORE_EVENTS; - - vev = (deviceValuator *) ++mev; - vev->type = info->codes->first_event + XI_DeviceValuator; - vev->deviceid = ev->deviceid; - vev->device_state = ev->device_state; - vev->first_valuator = ev->first_axis; - vev->num_valuators = ev->axes_count; - - i = vev->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: vev->valuator5 = ev->axis_data[5]; - case 5: vev->valuator4 = ev->axis_data[4]; - case 4: vev->valuator3 = ev->axis_data[3]; - case 3: vev->valuator2 = ev->axis_data[2]; - case 2: vev->valuator1 = ev->axis_data[1]; - case 1: vev->valuator0 = ev->axis_data[0]; + } else if (any->class == ButtonClass) { + XButtonStatus *b = (XButtonStatus *) any; + register deviceButtonStateNotify *bev; + + sev->classes_reported |= (1 << ButtonClass); + sev->num_buttons = b->num_buttons; + memcpy((char *)(sev->buttons), (char *)(b->buttons), 4); + if (b->num_buttons > 32) { + bev = (deviceButtonStateNotify *) tev++; + bev->type = info->codes->first_event + + XI_DeviceButtonstateNotify; + bev->deviceid = ev->deviceid; + *sav_id |= MORE_EVENTS; + sav_id = &(bev->deviceid); + memcpy((char *)(bev->buttons), (char *)(&b->buttons[4]), + 28); } - break; - } - case XI_DeviceFocusIn: - case XI_DeviceFocusOut: - { - register XDeviceFocusChangeEvent *ev = - (XDeviceFocusChangeEvent *) re; - register deviceFocus *fev; - - *count = 1; - fev = (deviceFocus *) Xmalloc (*count * sizeof (xEvent)); - if (!fev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) fev; - - fev->type = ev->type; - fev->window = ev->window; - fev->mode = ev->mode; - fev->detail = ev->detail; - fev->time = ev->time; - fev->deviceid = ev->deviceid; - break; - } - case XI_DeviceMappingNotify: - { - register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re; - register deviceMappingNotify *mev; - - *count = 1; - mev = (deviceMappingNotify *) Xmalloc (*count * sizeof (xEvent)); - if (!mev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) mev; - - mev->type = ev->type; - mev->firstKeyCode = ev->first_keycode; - mev->request = ev->request; - mev->count = ev->count; - mev->time = ev->time; - mev->deviceid = ev->deviceid; - break; - } - case XI_DeviceStateNotify: - { - register XDeviceStateNotifyEvent *ev = - (XDeviceStateNotifyEvent *) re; - register deviceStateNotify *sev; - register xEvent *tev; - XInputClass *any = (XInputClass *) &ev->data[0]; - unsigned char *sav_id; - *count = 1; - - for (i=0; i<ev->num_classes; i++) - { - if (any->class == KeyClass) - { - XKeyStatus *k = (XKeyStatus *) any; - if (k->num_keys > 32) - (*count)++; - } - else if (any->class == ButtonClass) - { - XButtonStatus *b = (XButtonStatus *) any; - if (b->num_buttons > 32) - (*count)++; - } - else if (any->class == ValuatorClass) - { - XValuatorStatus *v = (XValuatorStatus *) any; - if (v->num_valuators > 3) - (*count)++; - } - any = (XInputClass *) ((char *) any + any->length); + } else if (any->class == ValuatorClass) { + XValuatorStatus *val = (XValuatorStatus *) any; + register deviceValuator *vev; + + sev->classes_reported |= (1 << ValuatorClass); + sev->num_valuators = val->num_valuators < 3 ? + val->num_valuators : 3; + switch (sev->num_valuators) { + case 3: + sev->valuator2 = val->valuators[2]; + case 2: + sev->valuator1 = val->valuators[1]; + case 1: + sev->valuator0 = val->valuators[0]; } - - sev = (deviceStateNotify *) Xmalloc (*count * sizeof (xEvent)); - if (!sev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) sev; - tev = (xEvent *) (sev+1); - - sev->type = ev->type; - sev->deviceid = ev->deviceid; - sav_id = &(sev->deviceid); - sev->time = ev->time; - sev->classes_reported = 0; - - any = (XInputClass *) &ev->data[0]; - for (i=0; i<ev->num_classes; i++) - { - if (any->class == KeyClass) - { - XKeyStatus *k = (XKeyStatus *) any; - register deviceKeyStateNotify *kev; - - sev->classes_reported |= (1 << KeyClass); - sev->num_keys = k->num_keys; - memcpy ((char *) (sev->keys), (char *) (k->keys), 4); - if (k->num_keys > 32) - { - kev = (deviceKeyStateNotify *) tev++; - kev->type = info->codes->first_event + - XI_DeviceKeystateNotify; - kev->deviceid = ev->deviceid; - *sav_id |= MORE_EVENTS; - sav_id = &(kev->deviceid); - memcpy ((char *) (kev->keys), (char *) (&k->keys[4]), - 28); - } - } - else if (any->class == ButtonClass) - { - XButtonStatus *b = (XButtonStatus *) any; - register deviceButtonStateNotify *bev; - - sev->classes_reported |= (1 << ButtonClass); - sev->num_buttons = b->num_buttons; - memcpy ((char *) (sev->buttons), (char *) (b->buttons), 4); - if (b->num_buttons > 32) - { - bev = (deviceButtonStateNotify *) tev++; - bev->type = info->codes->first_event + - XI_DeviceButtonstateNotify; - bev->deviceid = ev->deviceid; - *sav_id |= MORE_EVENTS; - sav_id = &(bev->deviceid); - memcpy ((char *)(bev->buttons), (char *)(&b->buttons[4]), - 28); - } - } - else if (any->class == ValuatorClass) - { - XValuatorStatus *val = (XValuatorStatus *) any; - register deviceValuator *vev; - - sev->classes_reported |= (1 << ValuatorClass); - sev->num_valuators = val->num_valuators < 3 ? - val->num_valuators : 3; - switch (sev->num_valuators) - { - case 3: sev->valuator2 = val->valuators[2]; - case 2: sev->valuator1 = val->valuators[1]; - case 1: sev->valuator0 = val->valuators[0]; - } - if (val->num_valuators > 3) - { - vev = (deviceValuator *) tev++; - vev->type = info->codes->first_event + - XI_DeviceValuator; - vev->deviceid = ev->deviceid; - vev->first_valuator = 3; - vev->num_valuators = val->num_valuators - 3; - *sav_id |= MORE_EVENTS; - sav_id = &(vev->deviceid); - i = val->num_valuators; - if (i > 6) i = 6; - switch (i) - { - case 6: vev->valuator2 = val->valuators[5]; - case 5: vev->valuator1 = val->valuators[4]; - case 4: vev->valuator0 = val->valuators[3]; - } - } + if (val->num_valuators > 3) { + vev = (deviceValuator *) tev++; + vev->type = info->codes->first_event + XI_DeviceValuator; + vev->deviceid = ev->deviceid; + vev->first_valuator = 3; + vev->num_valuators = val->num_valuators - 3; + *sav_id |= MORE_EVENTS; + sav_id = &(vev->deviceid); + i = val->num_valuators; + if (i > 6) + i = 6; + switch (i) { + case 6: + vev->valuator2 = val->valuators[5]; + case 5: + vev->valuator1 = val->valuators[4]; + case 4: + vev->valuator0 = val->valuators[3]; } - any = (XInputClass *) ((char *) any + any->length); } - break; } - case XI_ChangeDeviceNotify: - { - register XChangeDeviceNotifyEvent *ev = - (XChangeDeviceNotifyEvent *) re; - register changeDeviceNotify *cev; - - *count = 1; - cev = (changeDeviceNotify *) Xmalloc (*count * sizeof (xEvent)); - if (!cev) - return(_XUnknownNativeEvent(dpy, re, *event)); - *event = (xEvent *) cev; - - cev->type = ev->type; - cev->request = ev->request; - cev->time = ev->time; - cev->deviceid = ev->deviceid; - break; - } - default: - return(_XUnknownNativeEvent(dpy, re, *event)); + any = (XInputClass *) ((char *)any + any->length); } - return(1); + break; + } + case XI_ChangeDeviceNotify: + { + register XChangeDeviceNotifyEvent *ev = (XChangeDeviceNotifyEvent *) re; + register changeDeviceNotify *cev; + + *count = 1; + cev = (changeDeviceNotify *) Xmalloc(*count * sizeof(xEvent)); + if (!cev) + return (_XUnknownNativeEvent(dpy, re, *event)); + *event = (xEvent *) cev; + + cev->type = ev->type; + cev->request = ev->request; + cev->time = ev->time; + cev->deviceid = ev->deviceid; + break; + } + default: + return (_XUnknownNativeEvent(dpy, re, *event)); } + return (1); +} diff --git a/src/XFreeLst.c b/src/XFreeLst.c index 3966f3f..1805c30 100644 --- a/src/XFreeLst.c +++ b/src/XFreeLst.c @@ -62,12 +62,11 @@ SOFTWARE. * */ -XFreeDeviceList (list) +XFreeDeviceList(list) XDeviceList *list; - { - if (list != NULL) - { - XFree ((list->name) - sizeof(XDeviceList)); - XFree ((XDeviceList *) list); - } +{ + if (list != NULL) { + XFree((list->name) - sizeof(XDeviceList)); + XFree((XDeviceList *) list); } +} diff --git a/src/XGMotion.c b/src/XGMotion.c index 4ce41bf..077bd88 100644 --- a/src/XGMotion.c +++ b/src/XGMotion.c @@ -61,82 +61,86 @@ SOFTWARE. #include "XIint.h" XDeviceTimeCoord -*XGetDeviceMotionEvents (dpy, dev, start, stop, nEvents, mode, axis_count) - register Display *dpy; - XDevice *dev; - Time start; - Time stop; - int *nEvents; - int *mode; - int *axis_count; - { - xGetDeviceMotionEventsReq *req; - xGetDeviceMotionEventsReply rep; + * XGetDeviceMotionEvents(dpy, dev, start, stop, nEvents, mode, axis_count) + register Display * + dpy; + XDevice * + dev; + Time + start; + Time + stop; + int * + nEvents; + int * + mode; + int * + axis_count; +{ + xGetDeviceMotionEventsReq *req; + xGetDeviceMotionEventsReply rep; XDeviceTimeCoord *tc; int *data, *bufp, *readp, *savp; long size, size2; - int i, j; - XExtDisplayInfo *info = XInput_find_display (dpy); + int i, j; + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((XDeviceTimeCoord *) NoSuchExtension); - GetReq(GetDeviceMotionEvents,req); + GetReq(GetDeviceMotionEvents, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetDeviceMotionEvents; req->start = start; req->stop = stop; req->deviceid = dev->device_id; - if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); - SyncHandle(); + SyncHandle(); *nEvents = 0; return (NULL); - } + } *mode = rep.mode; *axis_count = rep.axes; *nEvents = rep.nEvents; - if (!rep.nEvents) - { + if (!rep.nEvents) { UnlockDisplay(dpy); - SyncHandle(); + SyncHandle(); return (NULL); - } + } size = rep.length << 2; - size2 = rep.nEvents * - (sizeof (XDeviceTimeCoord) + (rep.axes * sizeof (int))); - savp = readp = (int *) Xmalloc (size); - bufp = (int *) Xmalloc (size2); - if (!bufp || !savp) - { + size2 = rep.nEvents * (sizeof(XDeviceTimeCoord) + (rep.axes * sizeof(int))); + savp = readp = (int *)Xmalloc(size); + bufp = (int *)Xmalloc(size2); + if (!bufp || !savp) { *nEvents = 0; - _XEatData (dpy, (unsigned long) size); + _XEatData(dpy, (unsigned long)size); UnlockDisplay(dpy); SyncHandle(); return (NULL); - } - _XRead (dpy, (char *) readp, size); + } + _XRead(dpy, (char *)readp, size); tc = (XDeviceTimeCoord *) bufp; - data = (int *) (tc + rep.nEvents); - for (i=0; i<*nEvents; i++,tc++) - { + data = (int *)(tc + rep.nEvents); + for (i = 0; i < *nEvents; i++, tc++) { tc->time = *readp++; tc->data = data; - for (j=0; j<*axis_count; j++) + for (j = 0; j < *axis_count; j++) *data++ = *readp++; - } - XFree ((char *)savp); + } + XFree((char *)savp); UnlockDisplay(dpy); SyncHandle(); return ((XDeviceTimeCoord *) bufp); - } +} -void XFreeDeviceMotionEvents (events) +void +XFreeDeviceMotionEvents(events) XDeviceTimeCoord *events; - { - XFree ((char *)events); - } +{ + XFree((char *)events); +} diff --git a/src/XGetBMap.c b/src/XGetBMap.c index 1c1658f..1eaaa23 100644 --- a/src/XGetBMap.c +++ b/src/XGetBMap.c @@ -60,22 +60,22 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -#ifdef MIN /* some systems define this in <sys/param.h> */ +#ifdef MIN /* some systems define this in <sys/param.h> */ #undef MIN #endif #define MIN(a, b) ((a) < (b) ? (a) : (b)) int -XGetDeviceButtonMapping (dpy, device, map, nmap) - register Display *dpy; - XDevice *device; - unsigned char map[]; - unsigned int nmap; - { - int status = 0; - unsigned char mapping[256]; /* known fixed size */ +XGetDeviceButtonMapping(dpy, device, map, nmap) + register Display *dpy; + XDevice *device; + unsigned char map[]; + unsigned int nmap; +{ + int status = 0; + unsigned char mapping[256]; /* known fixed size */ long nbytes; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); register xGetDeviceButtonMappingReq *req; xGetDeviceButtonMappingReply rep; @@ -89,20 +89,18 @@ XGetDeviceButtonMapping (dpy, device, map, nmap) req->ReqType = X_GetDeviceButtonMapping; req->deviceid = device->device_id; - status = _XReply (dpy, (xReply *)&rep, 0, xFalse); - if (status == 1) - { + status = _XReply(dpy, (xReply *) & rep, 0, xFalse); + if (status == 1) { nbytes = (long)rep.length << 2; - _XRead (dpy, (char *)mapping, nbytes); + _XRead(dpy, (char *)mapping, nbytes); /* don't return more data than the user asked for. */ - if (rep.nElts) - memcpy ((char *) map, (char *) mapping, MIN((int)rep.nElts, nmap)); + if (rep.nElts) + memcpy((char *)map, (char *)mapping, MIN((int)rep.nElts, nmap)); status = rep.nElts; - } - else + } else status = 0; UnlockDisplay(dpy); SyncHandle(); return (status); - } +} diff --git a/src/XGetDCtl.c b/src/XGetDCtl.c index 66b3525..9862dcc 100644 --- a/src/XGetDCtl.c +++ b/src/XGetDCtl.c @@ -61,113 +61,111 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -XDeviceControl -*XGetDeviceControl (dpy, dev, control) - register Display *dpy; - XDevice *dev; - int control; - { - int size = 0; - int nbytes, i; +XDeviceControl * XGetDeviceControl(dpy, dev, control) + register Display * + dpy; + XDevice * + dev; + int + control; +{ + int size = 0; + int nbytes, i; XDeviceControl *Device = NULL; XDeviceControl *Sav = NULL; xDeviceState *d = NULL; xDeviceState *sav = NULL; xGetDeviceControlReq *req; xGetDeviceControlReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Add_XChangeDeviceControl) == -1) return ((XDeviceControl *) NoSuchExtension); - GetReq(GetDeviceControl,req); + GetReq(GetDeviceControl, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetDeviceControl; req->deviceid = dev->device_id; req->control = control; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (XDeviceControl *) NULL; - } - if (rep.length > 0) - { + } + if (rep.length > 0) { nbytes = (long)rep.length << 2; - d = (xDeviceState *) Xmalloc((unsigned) nbytes); - if (!d) - { - _XEatData (dpy, (unsigned long) nbytes); + d = (xDeviceState *) Xmalloc((unsigned)nbytes); + if (!d) { + _XEatData(dpy, (unsigned long)nbytes); UnlockDisplay(dpy); SyncHandle(); return (XDeviceControl *) NULL; - } + } sav = d; - _XRead (dpy, (char *) d, nbytes); - - switch (d->control) - { - case DEVICE_RESOLUTION: - { - xDeviceResolutionState *r; - - r = (xDeviceResolutionState *) d; - size += sizeof (XDeviceResolutionState) + - (3 * sizeof(int) * r->num_valuators); - break; - } - default: - size += d->length; - break; - } - - Device = (XDeviceControl *) Xmalloc((unsigned) size); - if (!Device) - { + _XRead(dpy, (char *)d, nbytes); + + switch (d->control) { + case DEVICE_RESOLUTION: + { + xDeviceResolutionState *r; + + r = (xDeviceResolutionState *) d; + size += sizeof(XDeviceResolutionState) + + (3 * sizeof(int) * r->num_valuators); + break; + } + default: + size += d->length; + break; + } + + Device = (XDeviceControl *) Xmalloc((unsigned)size); + if (!Device) { UnlockDisplay(dpy); SyncHandle(); return (XDeviceControl *) NULL; - } + } Sav = Device; d = sav; - switch (control) - { - case DEVICE_RESOLUTION: - { - int *iptr, *iptr2; - xDeviceResolutionState *r; - XDeviceResolutionState *R; - r = (xDeviceResolutionState *) d; - R = (XDeviceResolutionState *) Device; - - R->control = DEVICE_RESOLUTION; - R->length = sizeof (XDeviceResolutionState); - R->num_valuators = r->num_valuators; - iptr = (int *) (R+1); - iptr2 = (int *) (r+1); - R->resolutions = iptr; - R->min_resolutions = iptr + R->num_valuators; - R->max_resolutions = iptr + (2 * R->num_valuators); - for (i=0; i < (3 * R->num_valuators); i++) - *iptr++ = *iptr2++; - break; - } - default: - break; - } - XFree (sav); + switch (control) { + case DEVICE_RESOLUTION: + { + int *iptr, *iptr2; + xDeviceResolutionState *r; + XDeviceResolutionState *R; + + r = (xDeviceResolutionState *) d; + R = (XDeviceResolutionState *) Device; + + R->control = DEVICE_RESOLUTION; + R->length = sizeof(XDeviceResolutionState); + R->num_valuators = r->num_valuators; + iptr = (int *)(R + 1); + iptr2 = (int *)(r + 1); + R->resolutions = iptr; + R->min_resolutions = iptr + R->num_valuators; + R->max_resolutions = iptr + (2 * R->num_valuators); + for (i = 0; i < (3 * R->num_valuators); i++) + *iptr++ = *iptr2++; + break; } + default: + break; + } + XFree(sav); + } UnlockDisplay(dpy); SyncHandle(); return (Sav); - } +} -void XFreeDeviceControl (control) +void +XFreeDeviceControl(control) XDeviceControl *control; - { - XFree (control); - } +{ + XFree(control); +} diff --git a/src/XGetFCtl.c b/src/XGetFCtl.c index e34c7ce..1e90633 100644 --- a/src/XGetFCtl.c +++ b/src/XGetFCtl.c @@ -61,213 +61,214 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -XFeedbackState -*XGetFeedbackControl (dpy, dev, num_feedbacks) - register Display *dpy; - XDevice *dev; - int *num_feedbacks; - { - int size = 0; - int nbytes, i; +XFeedbackState * XGetFeedbackControl(dpy, dev, num_feedbacks) + register Display * + dpy; + XDevice * + dev; + int * + num_feedbacks; +{ + int size = 0; + int nbytes, i; XFeedbackState *Feedback = NULL; XFeedbackState *Sav = NULL; xFeedbackState *f = NULL; xFeedbackState *sav = NULL; xGetFeedbackControlReq *req; xGetFeedbackControlReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((XFeedbackState *) NoSuchExtension); - GetReq(GetFeedbackControl,req); + GetReq(GetFeedbackControl, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetFeedbackControl; req->deviceid = dev->device_id; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (XFeedbackState *) NULL; - } - if (rep.length > 0) - { + } + if (rep.length > 0) { *num_feedbacks = rep.num_feedbacks; nbytes = (long)rep.length << 2; - f = (xFeedbackState *) Xmalloc((unsigned) nbytes); - if (!f) - { - _XEatData (dpy, (unsigned long) nbytes); + f = (xFeedbackState *) Xmalloc((unsigned)nbytes); + if (!f) { + _XEatData(dpy, (unsigned long)nbytes); UnlockDisplay(dpy); SyncHandle(); return (XFeedbackState *) NULL; - } + } sav = f; - _XRead (dpy, (char *) f, nbytes); + _XRead(dpy, (char *)f, nbytes); - for (i=0; i<*num_feedbacks; i++) + for (i = 0; i < *num_feedbacks; i++) { + switch (f->class) { + case KbdFeedbackClass: + size += sizeof(XKbdFeedbackState); + break; + case PtrFeedbackClass: + size += sizeof(XPtrFeedbackState); + break; + case IntegerFeedbackClass: + size += sizeof(XIntegerFeedbackState); + break; + case StringFeedbackClass: { - switch (f->class) - { - case KbdFeedbackClass: - size += sizeof (XKbdFeedbackState); - break; - case PtrFeedbackClass: - size += sizeof (XPtrFeedbackState); - break; - case IntegerFeedbackClass: - size += sizeof (XIntegerFeedbackState); - break; - case StringFeedbackClass: - { - xStringFeedbackState *strf = (xStringFeedbackState *) f; - - size += sizeof (XStringFeedbackState) + - (strf->num_syms_supported * sizeof (KeySym)); - } - break; - case LedFeedbackClass: - size += sizeof (XLedFeedbackState); - break; - case BellFeedbackClass: - size += sizeof (XBellFeedbackState); - break; - default: - size += f->length; - break; - } - f = (xFeedbackState *) ((char *) f + f->length); + xStringFeedbackState *strf = (xStringFeedbackState *) f; + + size += sizeof(XStringFeedbackState) + + (strf->num_syms_supported * sizeof(KeySym)); + } + break; + case LedFeedbackClass: + size += sizeof(XLedFeedbackState); + break; + case BellFeedbackClass: + size += sizeof(XBellFeedbackState); + break; + default: + size += f->length; + break; } + f = (xFeedbackState *) ((char *)f + f->length); + } - Feedback = (XFeedbackState *) Xmalloc((unsigned) size); - if (!Feedback) - { + Feedback = (XFeedbackState *) Xmalloc((unsigned)size); + if (!Feedback) { UnlockDisplay(dpy); SyncHandle(); return (XFeedbackState *) NULL; - } + } Sav = Feedback; f = sav; - for (i=0; i<*num_feedbacks; i++) + for (i = 0; i < *num_feedbacks; i++) { + switch (f->class) { + case KbdFeedbackClass: { - switch (f->class) - { - case KbdFeedbackClass: - { - xKbdFeedbackState *k; - XKbdFeedbackState *K; - k = (xKbdFeedbackState *) f; - K = (XKbdFeedbackState *) Feedback; - - K->class = k->class; - K->length = sizeof (XKbdFeedbackState); - K->id = k->id; - K->click = k->click; - K->percent = k->percent; - K->pitch = k->pitch; - K->duration = k->duration; - K->led_mask = k->led_mask; - K->global_auto_repeat = k->global_auto_repeat; - memcpy ((char *) &K->auto_repeats[0], - (char *) &k->auto_repeats[0], 32); - break; - } - case PtrFeedbackClass: - { - xPtrFeedbackState *p; - XPtrFeedbackState *P; - p = (xPtrFeedbackState *) f; - P = (XPtrFeedbackState *) Feedback; - - P->class = p->class; - P->length = sizeof (XPtrFeedbackState); - P->id = p->id; - P->accelNum = p->accelNum; - P->accelDenom = p->accelDenom; - P->threshold = p->threshold; - break; - } - case IntegerFeedbackClass: - { - xIntegerFeedbackState *i; - XIntegerFeedbackState *I; - i = (xIntegerFeedbackState *) f; - I = (XIntegerFeedbackState *) Feedback; - - I->class = i->class; - I->length = sizeof (XIntegerFeedbackState); - I->id = i->id; - I->resolution = i->resolution; - I->minVal = i->min_value; - I->maxVal = i->max_value; - break; - } - case StringFeedbackClass: - { - xStringFeedbackState *s; - XStringFeedbackState *S; - s = (xStringFeedbackState *) f; - S = (XStringFeedbackState *) Feedback; - - S->class = s->class; - S->length = sizeof (XStringFeedbackState) + - (s->num_syms_supported * sizeof (KeySym)); - S->id = s->id; - S->max_symbols = s->max_symbols; - S->num_syms_supported = s->num_syms_supported; - S->syms_supported = (KeySym *) (S+1); - memcpy ((char *) S->syms_supported, (char *) (s+1), - (S->num_syms_supported * sizeof (KeySym))); - break; - } - case LedFeedbackClass: - { - xLedFeedbackState *l; - XLedFeedbackState *L; - l = (xLedFeedbackState *) f; - L = (XLedFeedbackState *) Feedback; - - L->class = l->class; - L->length = sizeof (XLedFeedbackState); - L->id = l->id; - L->led_values = l->led_values; - L->led_mask = l->led_mask; - break; - } - case BellFeedbackClass: - { - xBellFeedbackState *b; - XBellFeedbackState *B; - b = (xBellFeedbackState *) f; - B = (XBellFeedbackState *) Feedback; - - B->class = b->class; - B->length = sizeof (XBellFeedbackState); - B->id = b->id; - B->percent = b->percent; - B->pitch = b->pitch; - B->duration = b->duration; - break; - } - default: - break; - } - f = (xFeedbackState *) ((char *) f + f->length); - Feedback = (XFeedbackState *) ((char *) Feedback+Feedback->length); + xKbdFeedbackState *k; + XKbdFeedbackState *K; + + k = (xKbdFeedbackState *) f; + K = (XKbdFeedbackState *) Feedback; + + K->class = k->class; + K->length = sizeof(XKbdFeedbackState); + K->id = k->id; + K->click = k->click; + K->percent = k->percent; + K->pitch = k->pitch; + K->duration = k->duration; + K->led_mask = k->led_mask; + K->global_auto_repeat = k->global_auto_repeat; + memcpy((char *)&K->auto_repeats[0], + (char *)&k->auto_repeats[0], 32); + break; } - XFree ((char *)sav); + case PtrFeedbackClass: + { + xPtrFeedbackState *p; + XPtrFeedbackState *P; + + p = (xPtrFeedbackState *) f; + P = (XPtrFeedbackState *) Feedback; + + P->class = p->class; + P->length = sizeof(XPtrFeedbackState); + P->id = p->id; + P->accelNum = p->accelNum; + P->accelDenom = p->accelDenom; + P->threshold = p->threshold; + break; + } + case IntegerFeedbackClass: + { + xIntegerFeedbackState *i; + XIntegerFeedbackState *I; + + i = (xIntegerFeedbackState *) f; + I = (XIntegerFeedbackState *) Feedback; + + I->class = i->class; + I->length = sizeof(XIntegerFeedbackState); + I->id = i->id; + I->resolution = i->resolution; + I->minVal = i->min_value; + I->maxVal = i->max_value; + break; + } + case StringFeedbackClass: + { + xStringFeedbackState *s; + XStringFeedbackState *S; + + s = (xStringFeedbackState *) f; + S = (XStringFeedbackState *) Feedback; + + S->class = s->class; + S->length = sizeof(XStringFeedbackState) + + (s->num_syms_supported * sizeof(KeySym)); + S->id = s->id; + S->max_symbols = s->max_symbols; + S->num_syms_supported = s->num_syms_supported; + S->syms_supported = (KeySym *) (S + 1); + memcpy((char *)S->syms_supported, (char *)(s + 1), + (S->num_syms_supported * sizeof(KeySym))); + break; + } + case LedFeedbackClass: + { + xLedFeedbackState *l; + XLedFeedbackState *L; + + l = (xLedFeedbackState *) f; + L = (XLedFeedbackState *) Feedback; + + L->class = l->class; + L->length = sizeof(XLedFeedbackState); + L->id = l->id; + L->led_values = l->led_values; + L->led_mask = l->led_mask; + break; + } + case BellFeedbackClass: + { + xBellFeedbackState *b; + XBellFeedbackState *B; + + b = (xBellFeedbackState *) f; + B = (XBellFeedbackState *) Feedback; + + B->class = b->class; + B->length = sizeof(XBellFeedbackState); + B->id = b->id; + B->percent = b->percent; + B->pitch = b->pitch; + B->duration = b->duration; + break; + } + default: + break; + } + f = (xFeedbackState *) ((char *)f + f->length); + Feedback = (XFeedbackState *) ((char *)Feedback + Feedback->length); } + XFree((char *)sav); + } UnlockDisplay(dpy); SyncHandle(); return (Sav); - } +} -void XFreeFeedbackList (list) +void +XFreeFeedbackList(list) XFeedbackState *list; - { - XFree ((char *)list); - } +{ + XFree((char *)list); +} diff --git a/src/XGetKMap.c b/src/XGetKMap.c index c794006..59f6f93 100644 --- a/src/XGetKMap.c +++ b/src/XGetKMap.c @@ -61,51 +61,47 @@ SOFTWARE. #include "XIint.h" KeySym * -XGetDeviceKeyMapping ( - register Display *dpy, - XDevice *dev, +XGetDeviceKeyMapping(register Display * dpy, XDevice * dev, #if NeedWidePrototypes - unsigned int first, + unsigned int first, #else - KeyCode first, + KeyCode first, #endif - int keycount, - int *syms_per_code) - { + int keycount, int *syms_per_code) +{ long nbytes; register KeySym *mapping = NULL; xGetDeviceKeyMappingReq *req; xGetDeviceKeyMappingReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((KeySym *) NoSuchExtension); - GetReq(GetDeviceKeyMapping,req); + GetReq(GetDeviceKeyMapping, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetDeviceKeyMapping; req->deviceid = dev->device_id; req->firstKeyCode = first; req->count = keycount; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (KeySym *) NULL; - } + } if (rep.length > 0) { - *syms_per_code = rep.keySymsPerKeyCode; + *syms_per_code = rep.keySymsPerKeyCode; nbytes = (long)rep.length << 2; - mapping = (KeySym *) Xmalloc((unsigned) nbytes); + mapping = (KeySym *) Xmalloc((unsigned)nbytes); if (mapping) - _XRead (dpy, (char *)mapping, nbytes); + _XRead(dpy, (char *)mapping, nbytes); else - _XEatData (dpy, (unsigned long) nbytes); - } + _XEatData(dpy, (unsigned long)nbytes); + } UnlockDisplay(dpy); SyncHandle(); return (mapping); - } +} diff --git a/src/XGetMMap.c b/src/XGetMMap.c index 04e89d8..b952a2f 100644 --- a/src/XGetMMap.c +++ b/src/XGetMMap.c @@ -60,45 +60,44 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -XModifierKeymap -*XGetDeviceModifierMapping (dpy, dev) - register Display *dpy; - XDevice *dev; - { +XModifierKeymap * XGetDeviceModifierMapping(dpy, dev) + register Display * + dpy; + XDevice * + dev; +{ unsigned long nbytes; XModifierKeymap *res; xGetDeviceModifierMappingReq *req; xGetDeviceModifierMappingReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((XModifierKeymap *) NoSuchExtension); - GetReq(GetDeviceModifierMapping,req); + GetReq(GetDeviceModifierMapping, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetDeviceModifierMapping; req->deviceid = dev->device_id; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (XModifierKeymap *) NULL; - } + } nbytes = (unsigned long)rep.length << 2; - res = (XModifierKeymap *) Xmalloc(sizeof (XModifierKeymap)); - if (res) - { - res->modifiermap = (KeyCode *) Xmalloc (nbytes); + res = (XModifierKeymap *) Xmalloc(sizeof(XModifierKeymap)); + if (res) { + res->modifiermap = (KeyCode *) Xmalloc(nbytes); if (res->modifiermap) - _XReadPad(dpy, (char *) res->modifiermap, nbytes); + _XReadPad(dpy, (char *)res->modifiermap, nbytes); else - _XEatData (dpy, (unsigned long) nbytes); + _XEatData(dpy, (unsigned long)nbytes); res->max_keypermod = rep.numKeyPerModifier; - } + } UnlockDisplay(dpy); SyncHandle(); return (res); - } +} diff --git a/src/XGetProp.c b/src/XGetProp.c index ed5a2d1..59b8b87 100644 --- a/src/XGetProp.c +++ b/src/XGetProp.c @@ -61,60 +61,56 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -XEventClass -*XGetDeviceDontPropagateList (dpy, window, count) - register Display *dpy; - Window window; - int *count; - { - XEventClass *list = NULL; - int rlen; - xGetDeviceDontPropagateListReq *req; - xGetDeviceDontPropagateListReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XEventClass * XGetDeviceDontPropagateList(dpy, window, count) + register Display * + dpy; + Window + window; + int * + count; +{ + XEventClass *list = NULL; + int rlen; + xGetDeviceDontPropagateListReq *req; + xGetDeviceDontPropagateListReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((XEventClass *) NoSuchExtension); - GetReq(GetDeviceDontPropagateList,req); + GetReq(GetDeviceDontPropagateList, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetDeviceDontPropagateList; req->window = window; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (XEventClass *) NULL; - } + } *count = rep.count; - if (*count) - { + if (*count) { rlen = rep.length << 2; - list = (XEventClass *) Xmalloc (rep.length * sizeof(XEventClass)); - if (list) - { - int i; - CARD32 ec; - - /* read and assign each XEventClass separately because - * the library representation may not be the same size - * as the wire representation (64 bit machines) - */ - for (i = 0; i < rep.length; i++) - { - _XRead (dpy, (char *)(&ec), sizeof(CARD32)); - list[i] = (XEventClass)ec; - } + list = (XEventClass *) Xmalloc(rep.length * sizeof(XEventClass)); + if (list) { + int i; + CARD32 ec; + + /* read and assign each XEventClass separately because + * the library representation may not be the same size + * as the wire representation (64 bit machines) + */ + for (i = 0; i < rep.length; i++) { + _XRead(dpy, (char *)(&ec), sizeof(CARD32)); + list[i] = (XEventClass) ec; } - else - _XEatData (dpy, (unsigned long) rlen); - } + } else + _XEatData(dpy, (unsigned long)rlen); + } UnlockDisplay(dpy); SyncHandle(); return (list); - } - +} diff --git a/src/XGetVers.c b/src/XGetVers.c index 3180837..1f4fd7a 100644 --- a/src/XGetVers.c +++ b/src/XGetVers.c @@ -61,55 +61,47 @@ SOFTWARE. #include "XIint.h" XExtensionVersion * -XGetExtensionVersion ( - register Display *dpy, - _Xconst char *name) - { - XExtensionVersion *ext; - - LockDisplay (dpy); - ext = _XiGetExtensionVersion (dpy, name); +XGetExtensionVersion(register Display * dpy, _Xconst char *name) +{ + XExtensionVersion *ext; + + LockDisplay(dpy); + ext = _XiGetExtensionVersion(dpy, name); if (ext != (XExtensionVersion *) NoSuchExtension) { - UnlockDisplay (dpy); + UnlockDisplay(dpy); SyncHandle(); } return (ext); - } +} XExtensionVersion * -_XiGetExtensionVersion ( - register Display *dpy, - _Xconst char *name) - { - xGetExtensionVersionReq *req; - xGetExtensionVersionReply rep; - XExtensionVersion *ext; - XExtDisplayInfo *info = XInput_find_display (dpy); +_XiGetExtensionVersion(register Display * dpy, _Xconst char *name) +{ + xGetExtensionVersionReq *req; + xGetExtensionVersionReply rep; + XExtensionVersion *ext; + XExtDisplayInfo *info = XInput_find_display(dpy); if (_XiCheckExtInit(dpy, Dont_Check) == -1) return ((XExtensionVersion *) NoSuchExtension); - GetReq(GetExtensionVersion,req); + GetReq(GetExtensionVersion, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetExtensionVersion; req->nbytes = name ? strlen(name) : 0; - req->length += (unsigned)(req->nbytes+3)>>2; + req->length += (unsigned)(req->nbytes + 3) >> 2; _XSend(dpy, name, (long)req->nbytes); - if (! _XReply (dpy, (xReply *) &rep, 0, xTrue)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { return (XExtensionVersion *) NULL; - } - ext = (XExtensionVersion *) Xmalloc (sizeof (XExtensionVersion)); - if (ext) - { + } + ext = (XExtensionVersion *) Xmalloc(sizeof(XExtensionVersion)); + if (ext) { ext->present = rep.present; - if (ext->present) - { + if (ext->present) { ext->major_version = rep.major_version; ext->minor_version = rep.minor_version; - } } - return (ext); } - + return (ext); +} diff --git a/src/XGrDvBut.c b/src/XGrDvBut.c index 48381f8..fbc26ba 100644 --- a/src/XGrDvBut.c +++ b/src/XGrDvBut.c @@ -61,25 +61,25 @@ SOFTWARE. #include "XIint.h" int -XGrabDeviceButton (dpy, dev, button, modifiers, modifier_device, - grab_window, owner_events, event_count, event_list, this_device_mode, - other_devices_mode) - register Display *dpy; - XDevice *dev; - unsigned int button; /* CARD8 */ - unsigned int modifiers; /* CARD16 */ - XDevice *modifier_device; - Window grab_window; - Bool owner_events; - unsigned int event_count; - XEventClass *event_list; - int this_device_mode; - int other_devices_mode; - { +XGrabDeviceButton(dpy, dev, button, modifiers, modifier_device, + grab_window, owner_events, event_count, event_list, + this_device_mode, other_devices_mode) + register Display *dpy; + XDevice *dev; + unsigned int button; /* CARD8 */ + unsigned int modifiers; /* CARD16 */ + XDevice *modifier_device; + Window grab_window; + Bool owner_events; + unsigned int event_count; + XEventClass *event_list; + int this_device_mode; + int other_devices_mode; +{ register xGrabDeviceButtonReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); @@ -102,13 +102,13 @@ XGrabDeviceButton (dpy, dev, button, modifiers, modifier_device, req->length += event_count; /* note: Data is a macro that uses its arguments multiple - times, so "nvalues" is changed in a separate assignment - statement */ + * times, so "nvalues" is changed in a separate assignment + * statement */ event_count <<= 2; - Data32 (dpy, (long *) event_list, event_count); + Data32(dpy, (long *)event_list, event_count); UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XGrDvKey.c b/src/XGrDvKey.c index 94e9ba4..6731e2c 100644 --- a/src/XGrDvKey.c +++ b/src/XGrDvKey.c @@ -61,25 +61,25 @@ SOFTWARE. #include "XIint.h" int -XGrabDeviceKey (dpy, dev, key, modifiers, modifier_device, - grab_window, owner_events, event_count, event_list, this_device_mode, - other_devices_mode) - register Display *dpy; - XDevice *dev; - unsigned int key; /* CARD8 */ - unsigned int modifiers; /* CARD16 */ - XDevice *modifier_device; - Window grab_window; - Bool owner_events; - unsigned int event_count; - XEventClass *event_list; - int this_device_mode; - int other_devices_mode; - { +XGrabDeviceKey(dpy, dev, key, modifiers, modifier_device, + grab_window, owner_events, event_count, event_list, + this_device_mode, other_devices_mode) + register Display *dpy; + XDevice *dev; + unsigned int key; /* CARD8 */ + unsigned int modifiers; /* CARD16 */ + XDevice *modifier_device; + Window grab_window; + Bool owner_events; + unsigned int event_count; + XEventClass *event_list; + int this_device_mode; + int other_devices_mode; +{ register xGrabDeviceKeyReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); @@ -102,16 +102,15 @@ XGrabDeviceKey (dpy, dev, key, modifiers, modifier_device, req->length += event_count; /* note: Data is a macro that uses its arguments multiple - times, so "nvalues" is changed in a separate assignment - statement */ + * times, so "nvalues" is changed in a separate assignment + * statement */ - if (event_count) - { + if (event_count) { event_count <<= 2; - Data32 (dpy, (long *) event_list, event_count); - } + Data32(dpy, (long *)event_list, event_count); + } UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XGrabDev.c b/src/XGrabDev.c index f49a6bd..536e369 100644 --- a/src/XGrabDev.c +++ b/src/XGrabDev.c @@ -60,31 +60,31 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -int -XGrabDevice (dpy, dev, grab_window, ownerEvents, event_count, event_list, - this_device_mode, other_devices_mode, time) - register Display *dpy; - XDevice *dev; - Window grab_window; - Bool ownerEvents; - int event_count; - XEventClass *event_list; - int this_device_mode; - int other_devices_mode; - Time time; - { +int +XGrabDevice(dpy, dev, grab_window, ownerEvents, event_count, event_list, + this_device_mode, other_devices_mode, time) + register Display *dpy; + XDevice *dev; + Window grab_window; + Bool ownerEvents; + int event_count; + XEventClass *event_list; + int this_device_mode; + int other_devices_mode; + Time time; +{ xGrabDeviceReply rep; register xGrabDeviceReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(GrabDevice,req); + GetReq(GrabDevice, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GrabDevice; - + req->deviceid = dev->device_id; req->grabWindow = grab_window; req->ownerEvents = ownerEvents; @@ -95,15 +95,15 @@ XGrabDevice (dpy, dev, grab_window, ownerEvents, event_count, event_list, req->length += event_count; /* note: Data is a macro that uses its arguments multiple - times, so "nvalues" is changed in a separate assignment - statement */ + * times, so "nvalues" is changed in a separate assignment + * statement */ event_count <<= 2; - Data32 (dpy, (long *) event_list, event_count); + Data32(dpy, (long *)event_list, event_count); - if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0) + if (_XReply(dpy, (xReply *) & rep, 0, xTrue) == 0) rep.status = GrabSuccess; UnlockDisplay(dpy); SyncHandle(); return (rep.status); - } +} diff --git a/src/XGtFocus.c b/src/XGtFocus.c index 29e8de7..08cebd9 100644 --- a/src/XGtFocus.c +++ b/src/XGtFocus.c @@ -61,32 +61,31 @@ SOFTWARE. #include "XIint.h" int -XGetDeviceFocus (dpy, dev, focus, revert_to, time) +XGetDeviceFocus(dpy, dev, focus, revert_to, time) register Display *dpy; XDevice *dev; Window *focus; int *revert_to; Time *time; - { - xGetDeviceFocusReq *req; - xGetDeviceFocusReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + xGetDeviceFocusReq *req; + xGetDeviceFocusReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(GetDeviceFocus,req); + GetReq(GetDeviceFocus, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetDeviceFocus; req->deviceid = dev->device_id; - (void) _XReply (dpy, (xReply *) &rep, 0, xTrue); + (void)_XReply(dpy, (xReply *) & rep, 0, xTrue); *focus = rep.focus; *revert_to = rep.revertTo; *time = rep.time; UnlockDisplay(dpy); SyncHandle(); return (Success); - } - +} diff --git a/src/XGtSelect.c b/src/XGtSelect.c index 9663653..0f63caf 100644 --- a/src/XGtSelect.c +++ b/src/XGtSelect.c @@ -61,86 +61,79 @@ SOFTWARE. #include "XIint.h" int -XGetSelectedExtensionEvents (dpy, w, this_client_count, this_client_list, - all_clients_count, all_clients_list) - register Display *dpy; - Window w; - int *this_client_count; - XEventClass **this_client_list; - int *all_clients_count; - XEventClass **all_clients_list; - { - int tlen, alen; - register xGetSelectedExtensionEventsReq *req; +XGetSelectedExtensionEvents(dpy, w, this_client_count, this_client_list, + all_clients_count, all_clients_list) + register Display *dpy; + Window w; + int *this_client_count; + XEventClass **this_client_list; + int *all_clients_count; + XEventClass **all_clients_list; +{ + int tlen, alen; + register xGetSelectedExtensionEventsReq *req; xGetSelectedExtensionEventsReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(GetSelectedExtensionEvents,req); + GetReq(GetSelectedExtensionEvents, req); req->reqType = info->codes->major_opcode; req->ReqType = X_GetSelectedExtensionEvents; req->window = w; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return Success; - } + } *this_client_count = rep.this_client_count; *all_clients_count = rep.all_clients_count; - if (rep.length) - { + if (rep.length) { int i; CARD32 ec; + tlen = (*this_client_count) * sizeof(CARD32); alen = (rep.length << 2) - tlen; - if (tlen) - { - *this_client_list = (XEventClass *) Xmalloc ( - *this_client_count * sizeof(XEventClass)); - if (!*this_client_list) - { - _XEatData (dpy, (unsigned long) tlen+alen); + if (tlen) { + *this_client_list = + (XEventClass *) Xmalloc(*this_client_count * + sizeof(XEventClass)); + if (!*this_client_list) { + _XEatData(dpy, (unsigned long)tlen + alen); return (Success); - } - for (i = 0; i < *this_client_count; i++) - { - _XRead (dpy, (char *)(&ec), sizeof(CARD32)); - (*this_client_list)[i] = (XEventClass)ec; - } } - else + for (i = 0; i < *this_client_count; i++) { + _XRead(dpy, (char *)(&ec), sizeof(CARD32)); + (*this_client_list)[i] = (XEventClass) ec; + } + } else *this_client_list = (XEventClass *) NULL; - if (alen) - { - *all_clients_list = (XEventClass *) Xmalloc ( - *all_clients_count * sizeof(XEventClass)); - if (!*all_clients_list) - { + if (alen) { + *all_clients_list = + (XEventClass *) Xmalloc(*all_clients_count * + sizeof(XEventClass)); + if (!*all_clients_list) { Xfree((char *)*this_client_list); *this_client_list = NULL; - _XEatData (dpy, (unsigned long) alen); + _XEatData(dpy, (unsigned long)alen); return (Success); - } - for (i = 0; i < *all_clients_count; i++) - { - _XRead (dpy, (char *)(&ec), sizeof(CARD32)); - (*all_clients_list)[i] = (XEventClass)ec; - } } - else + for (i = 0; i < *all_clients_count; i++) { + _XRead(dpy, (char *)(&ec), sizeof(CARD32)); + (*all_clients_list)[i] = (XEventClass) ec; + } + } else *all_clients_list = (XEventClass *) NULL; - } + } UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XIint.h b/src/XIint.h index fdca57d..ba965a6 100644 --- a/src/XIint.h +++ b/src/XIint.h @@ -8,18 +8,10 @@ #ifndef _XIINT_H_ #define _XIINT_H_ -extern XExtDisplayInfo * XInput_find_display( - Display* -); +extern XExtDisplayInfo *XInput_find_display(Display *); -extern int _XiCheckExtInit( - Display*, - int -); +extern int _XiCheckExtInit(Display *, int); -extern XExtensionVersion * _XiGetExtensionVersion( - Display*, - _Xconst char* -); +extern XExtensionVersion *_XiGetExtensionVersion(Display *, _Xconst char *); #endif diff --git a/src/XListDev.c b/src/XListDev.c index 279bede..e834e6a 100644 --- a/src/XListDev.c +++ b/src/XListDev.c @@ -63,185 +63,174 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -XDeviceInfo -*XListInputDevices(dpy, ndevices) - register Display *dpy; - int *ndevices; - { - int size; - xListInputDevicesReq *req; - xListInputDevicesReply rep; - xDeviceInfo *list, *slist = NULL; - XDeviceInfo *sclist = NULL; - XDeviceInfo *clist = NULL; - xAnyClassPtr any, sav_any; - XAnyClassPtr Any; - char *nptr, *Nptr; - register int i,j,k; - register long rlen; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XDeviceInfo * XListInputDevices(dpy, ndevices) + register Display * + dpy; + int * + ndevices; +{ + int size; + xListInputDevicesReq *req; + xListInputDevicesReply rep; + xDeviceInfo *list, *slist = NULL; + XDeviceInfo *sclist = NULL; + XDeviceInfo *clist = NULL; + xAnyClassPtr any, sav_any; + XAnyClassPtr Any; + char *nptr, *Nptr; + register int i, j, k; + register long rlen; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((XDeviceInfo *) NULL); - GetReq(ListInputDevices,req); + GetReq(ListInputDevices, req); req->reqType = info->codes->major_opcode; req->ReqType = X_ListInputDevices; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (XDeviceInfo *) NULL; - } + } - if ((*ndevices = rep.ndevices)) /* at least 1 input device */ - { - size = *ndevices * sizeof (XDeviceInfo); - rlen = rep.length << 2; /* multiply length by 4 */ - list = (xDeviceInfo *) Xmalloc (rlen); + if ((*ndevices = rep.ndevices)) { /* at least 1 input device */ + size = *ndevices * sizeof(XDeviceInfo); + rlen = rep.length << 2; /* multiply length by 4 */ + list = (xDeviceInfo *) Xmalloc(rlen); slist = list; - if (!slist) - { - _XEatData (dpy, (unsigned long) rlen); + if (!slist) { + _XEatData(dpy, (unsigned long)rlen); UnlockDisplay(dpy); SyncHandle(); return (XDeviceInfo *) NULL; - } - _XRead (dpy, (char *)list, rlen); + } + _XRead(dpy, (char *)list, rlen); - any = (xAnyClassPtr) ((char *) list + - (*ndevices * sizeof(xDeviceInfo))); + any = (xAnyClassPtr) ((char *)list + (*ndevices * sizeof(xDeviceInfo))); sav_any = any; - for (i=0; i<*ndevices; i++, list++) - { - for (j=0; j<(int)list->num_classes; j++) + for (i = 0; i < *ndevices; i++, list++) { + for (j = 0; j < (int)list->num_classes; j++) { + switch (any->class) { + case KeyClass: + size += sizeof(XKeyInfo); + break; + case ButtonClass: + size += sizeof(XButtonInfo); + break; + case ValuatorClass: { - switch (any->class) - { - case KeyClass: - size += sizeof (XKeyInfo); - break; - case ButtonClass: - size += sizeof (XButtonInfo); - break; - case ValuatorClass: - { - xValuatorInfoPtr v; - v = (xValuatorInfoPtr) any; - size += sizeof (XValuatorInfo) + - (v->num_axes * sizeof (XAxisInfo)); - break; - } - default: - break; - } - any = (xAnyClassPtr) ((char *) any + any->length); + xValuatorInfoPtr v; + + v = (xValuatorInfoPtr) any; + size += sizeof(XValuatorInfo) + + (v->num_axes * sizeof(XAxisInfo)); + break; + } + default: + break; } + any = (xAnyClassPtr) ((char *)any + any->length); } + } - for (i=0, nptr = (char *) any; i<*ndevices; i++) - { - size += *nptr +1; + for (i = 0, nptr = (char *)any; i < *ndevices; i++) { + size += *nptr + 1; nptr += (*nptr + 1); - } + } - clist = (XDeviceInfoPtr) Xmalloc (size); - if (!clist) - { - XFree ((char *)slist); + clist = (XDeviceInfoPtr) Xmalloc(size); + if (!clist) { + XFree((char *)slist); UnlockDisplay(dpy); SyncHandle(); return (XDeviceInfo *) NULL; - } + } sclist = clist; - Any = (XAnyClassPtr) ((char *) clist + - (*ndevices * sizeof (XDeviceInfo))); + Any = (XAnyClassPtr) ((char *)clist + + (*ndevices * sizeof(XDeviceInfo))); list = slist; any = sav_any; - for (i=0; i<*ndevices; i++, list++, clist++) - { - clist->type = list->type; + for (i = 0; i < *ndevices; i++, list++, clist++) { + clist->type = list->type; clist->id = list->id; clist->use = list->use; clist->num_classes = list->num_classes; clist->inputclassinfo = Any; - for (j=0; j<(int)list->num_classes; j++) + for (j = 0; j < (int)list->num_classes; j++) { + switch (any->class) { + case KeyClass: + { + XKeyInfoPtr K = (XKeyInfoPtr) Any; + xKeyInfoPtr k = (xKeyInfoPtr) any; + + K->class = KeyClass; + K->length = sizeof(XKeyInfo); + K->min_keycode = k->min_keycode; + K->max_keycode = k->max_keycode; + K->num_keys = k->num_keys; + break; + } + case ButtonClass: { - switch (any->class) - { - case KeyClass: - { - XKeyInfoPtr K = (XKeyInfoPtr) Any; - xKeyInfoPtr k = (xKeyInfoPtr) any; - K->class = KeyClass; - K->length = sizeof (XKeyInfo); - K->min_keycode = k->min_keycode; - K->max_keycode = k->max_keycode; - K->num_keys = k->num_keys; - break; - } - case ButtonClass: - { - XButtonInfoPtr B = (XButtonInfoPtr) Any; - xButtonInfoPtr b = (xButtonInfoPtr) any; - B->class = ButtonClass; - B->length = sizeof (XButtonInfo); - B->num_buttons = b->num_buttons; - break; - } - case ValuatorClass: - { - XValuatorInfoPtr V = (XValuatorInfoPtr) Any; - xValuatorInfoPtr v = (xValuatorInfoPtr) any; - XAxisInfoPtr A; - xAxisInfoPtr a; + XButtonInfoPtr B = (XButtonInfoPtr) Any; + xButtonInfoPtr b = (xButtonInfoPtr) any; - V->class = ValuatorClass; - V->length = sizeof (XValuatorInfo) + - (v->num_axes * sizeof (XAxisInfo)); - V->num_axes = v->num_axes; - V->motion_buffer = v->motion_buffer_size; - V->mode = v->mode; - A = (XAxisInfoPtr) ((char *) V + sizeof(XValuatorInfo)); - V->axes = A; - a = (xAxisInfoPtr) ((char *) any + - sizeof (xValuatorInfo)); - for (k=0; k<(int)v->num_axes; k++,a++,A++) - { - A->min_value = a->min_value; - A->max_value = a->max_value; - A->resolution = a->resolution; - } - break; - } - default: - break; + B->class = ButtonClass; + B->length = sizeof(XButtonInfo); + B->num_buttons = b->num_buttons; + break; + } + case ValuatorClass: + { + XValuatorInfoPtr V = (XValuatorInfoPtr) Any; + xValuatorInfoPtr v = (xValuatorInfoPtr) any; + XAxisInfoPtr A; + xAxisInfoPtr a; + + V->class = ValuatorClass; + V->length = sizeof(XValuatorInfo) + + (v->num_axes * sizeof(XAxisInfo)); + V->num_axes = v->num_axes; + V->motion_buffer = v->motion_buffer_size; + V->mode = v->mode; + A = (XAxisInfoPtr) ((char *)V + sizeof(XValuatorInfo)); + V->axes = A; + a = (xAxisInfoPtr) ((char *)any + sizeof(xValuatorInfo)); + for (k = 0; k < (int)v->num_axes; k++, a++, A++) { + A->min_value = a->min_value; + A->max_value = a->max_value; + A->resolution = a->resolution; } - any = (xAnyClassPtr) ((char *) any + any->length); - Any = (XAnyClassPtr) ((char *) Any + Any->length); + break; } + default: + break; + } + any = (xAnyClassPtr) ((char *)any + any->length); + Any = (XAnyClassPtr) ((char *)Any + Any->length); } + } clist = sclist; - nptr = (char *) any; - Nptr = (char *) Any; - for (i=0; i<*ndevices; i++,clist++) - { - clist->name = (char *) Nptr; - memcpy (Nptr, nptr+1, *nptr); + nptr = (char *)any; + Nptr = (char *)Any; + for (i = 0; i < *ndevices; i++, clist++) { + clist->name = (char *)Nptr; + memcpy(Nptr, nptr + 1, *nptr); Nptr += (*nptr); *Nptr++ = '\0'; nptr += (*nptr + 1); - } } + } - XFree ((char *)slist); + XFree((char *)slist); UnlockDisplay(dpy); SyncHandle(); return (sclist); - } +} /*********************************************************************** * @@ -249,11 +238,11 @@ XDeviceInfo * */ -void XFreeDeviceList (list) +void +XFreeDeviceList(list) XDeviceInfo *list; - { - if (list != NULL) - { - XFree ((char *) list); - } +{ + if (list != NULL) { + XFree((char *)list); } +} diff --git a/src/XOpenDev.c b/src/XOpenDev.c index 7930a9a..c98204d 100644 --- a/src/XOpenDev.c +++ b/src/XOpenDev.c @@ -60,54 +60,51 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -XDevice -*XOpenDevice(dpy, id) - register Display *dpy; - register XID id; - { - register long rlen; /* raw length */ - xOpenDeviceReq *req; - xOpenDeviceReply rep; - XDevice *dev; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XDevice * XOpenDevice(dpy, id) + register Display * + dpy; + register XID + id; +{ + register long rlen; /* raw length */ + xOpenDeviceReq *req; + xOpenDeviceReply rep; + XDevice *dev; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((XDevice *) NoSuchExtension); - GetReq(OpenDevice,req); + GetReq(OpenDevice, req); req->reqType = info->codes->major_opcode; req->ReqType = X_OpenDevice; req->deviceid = id; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (XDevice *) NULL; - } + } rlen = rep.length << 2; - dev = (XDevice *) Xmalloc (sizeof(XDevice) + rep.num_classes * - sizeof (XInputClassInfo)); - if (dev) - { - int dlen; /* data length */ + dev = (XDevice *) Xmalloc(sizeof(XDevice) + rep.num_classes * + sizeof(XInputClassInfo)); + if (dev) { + int dlen; /* data length */ dev->device_id = req->deviceid; dev->num_classes = rep.num_classes; - dev->classes = (XInputClassInfo *) ((char *) dev + sizeof (XDevice)); + dev->classes = (XInputClassInfo *) ((char *)dev + sizeof(XDevice)); dlen = rep.num_classes * sizeof(xInputClassInfo); - _XRead (dpy, (char *)dev->classes, dlen); + _XRead(dpy, (char *)dev->classes, dlen); /* could be padding that we still need to eat (yummy!) */ - if(rlen - dlen > 0) - _XEatData (dpy, (unsigned long) rlen - dlen); - } - else - _XEatData (dpy, (unsigned long) rlen); + if (rlen - dlen > 0) + _XEatData(dpy, (unsigned long)rlen - dlen); + } else + _XEatData(dpy, (unsigned long)rlen); - UnlockDisplay (dpy); + UnlockDisplay(dpy); SyncHandle(); return (dev); - } - +} diff --git a/src/XQueryDv.c b/src/XQueryDv.c index 1450c15..94d0f9a 100644 --- a/src/XQueryDv.c +++ b/src/XQueryDv.c @@ -60,139 +60,135 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -XDeviceState -*XQueryDeviceState (dpy, dev) - register Display *dpy; - XDevice *dev; - { - int i,j; - int rlen; - int size = 0; - xQueryDeviceStateReq *req; - xQueryDeviceStateReply rep; - XDeviceState *state = NULL; - XInputClass *any, *Any; - char *data; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XDeviceState * XQueryDeviceState(dpy, dev) + register Display * + dpy; + XDevice * + dev; +{ + int i, j; + int rlen; + int size = 0; + xQueryDeviceStateReq *req; + xQueryDeviceStateReply rep; + XDeviceState *state = NULL; + XInputClass *any, *Any; + char *data; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return ((XDeviceState *) NoSuchExtension); - GetReq(QueryDeviceState,req); + GetReq(QueryDeviceState, req); req->reqType = info->codes->major_opcode; req->ReqType = X_QueryDeviceState; req->deviceid = dev->device_id; - if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) - { + if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { UnlockDisplay(dpy); SyncHandle(); return (XDeviceState *) NULL; - } + } rlen = rep.length << 2; - if (rlen > 0) - { - data = Xmalloc (rlen); - if (!data) - { - _XEatData (dpy, (unsigned long) rlen); - UnlockDisplay(dpy); - SyncHandle(); - return ((XDeviceState *) NULL); - } - _XRead (dpy, data, rlen); - - for (i=0, any=(XInputClass *) data; i<(int)rep.num_classes; i++) + if (rlen > 0) { + data = Xmalloc(rlen); + if (!data) { + _XEatData(dpy, (unsigned long)rlen); + UnlockDisplay(dpy); + SyncHandle(); + return ((XDeviceState *) NULL); + } + _XRead(dpy, data, rlen); + + for (i = 0, any = (XInputClass *) data; i < (int)rep.num_classes; i++) { + switch (any->class) { + case KeyClass: + size += sizeof(XKeyState); + break; + case ButtonClass: + size += sizeof(XButtonState); + break; + case ValuatorClass: { - switch (any->class) - { - case KeyClass: - size += sizeof (XKeyState); - break; - case ButtonClass: - size += sizeof (XButtonState); - break; - case ValuatorClass: - { - xValuatorState *v = (xValuatorState *) any; - size += (sizeof (XValuatorState) + - (v->num_valuators * sizeof(int))); - } - break; - } - any = (XInputClass *) ((char *) any + any->length); + xValuatorState *v = (xValuatorState *) any; + size += (sizeof(XValuatorState) + + (v->num_valuators * sizeof(int))); } - state = (XDeviceState *) Xmalloc (size + sizeof(XDeviceState)); - if (!state) - { - UnlockDisplay(dpy); - SyncHandle(); - return ((XDeviceState *) NULL); + break; } + any = (XInputClass *) ((char *)any + any->length); + } + state = (XDeviceState *) Xmalloc(size + sizeof(XDeviceState)); + if (!state) { + UnlockDisplay(dpy); + SyncHandle(); + return ((XDeviceState *) NULL); + } state->device_id = dev->device_id; state->num_classes = rep.num_classes; state->data = (XInputClass *) (state + 1); - Any = state->data; - for (i=0, any=(XInputClass *) data; i<(int)rep.num_classes; i++) + Any = state->data; + for (i = 0, any = (XInputClass *) data; i < (int)rep.num_classes; i++) { + switch (any->class) { + case KeyClass: { - switch (any->class) - { - case KeyClass: - { - xKeyState *k = (xKeyState *) any; - XKeyState *K = (XKeyState *) Any; - K->class = k->class; - K->length = sizeof (XKeyState); - K->num_keys = k->num_keys; - memcpy ((char *) &K->keys[0], (char *) &k->keys[0], 32); - Any = (XInputClass *) (K+1); - } - break; - case ButtonClass: - { - xButtonState *b = (xButtonState *) any; - XButtonState *B = (XButtonState *) Any; - B->class = b->class; - B->length = sizeof (XButtonState); - B->num_buttons = b->num_buttons; - memcpy ((char *) &B->buttons[0], (char *) &b->buttons[0], - 32); - Any = (XInputClass *) (B+1); - } - break; - case ValuatorClass: - { - xValuatorState *v = (xValuatorState *) any; - XValuatorState *V = (XValuatorState *) Any; - CARD32 *valuators = (CARD32 *) (v+1); - V->class = v->class; - V->length = sizeof (XValuatorState); - V->num_valuators = v->num_valuators; - V->mode = v->mode; - Any = (XInputClass *) (V+1); - V->valuators = (int *) Any; - for (j=0; j<(int)V->num_valuators; j++) - *(V->valuators + j) = *valuators++; - Any = (XInputClass *)((char *) Any + - V->num_valuators * sizeof (int)); - } - break; - } - any = (XInputClass *) ((char *) any + any->length); + xKeyState *k = (xKeyState *) any; + XKeyState *K = (XKeyState *) Any; + + K->class = k->class; + K->length = sizeof(XKeyState); + K->num_keys = k->num_keys; + memcpy((char *)&K->keys[0], (char *)&k->keys[0], 32); + Any = (XInputClass *) (K + 1); } - Xfree(data); + break; + case ButtonClass: + { + xButtonState *b = (xButtonState *) any; + XButtonState *B = (XButtonState *) Any; + + B->class = b->class; + B->length = sizeof(XButtonState); + B->num_buttons = b->num_buttons; + memcpy((char *)&B->buttons[0], (char *)&b->buttons[0], 32); + Any = (XInputClass *) (B + 1); + } + break; + case ValuatorClass: + { + xValuatorState *v = (xValuatorState *) any; + XValuatorState *V = (XValuatorState *) Any; + CARD32 *valuators = (CARD32 *) (v + 1); + + V->class = v->class; + V->length = sizeof(XValuatorState); + V->num_valuators = v->num_valuators; + V->mode = v->mode; + Any = (XInputClass *) (V + 1); + V->valuators = (int *)Any; + for (j = 0; j < (int)V->num_valuators; j++) + *(V->valuators + j) = *valuators++; + Any = (XInputClass *) ((char *)Any + + V->num_valuators * sizeof(int)); + } + break; + } + any = (XInputClass *) ((char *)any + any->length); } + Xfree(data); + } UnlockDisplay(dpy); SyncHandle(); return (state); - } +} -void XFreeDeviceState (list) +void +XFreeDeviceState(list) XDeviceState *list; - { - XFree ((char *)list); - } +{ + XFree((char *)list); +} diff --git a/src/XSelect.c b/src/XSelect.c index c0a8dc8..b23829a 100644 --- a/src/XSelect.c +++ b/src/XSelect.c @@ -61,19 +61,19 @@ SOFTWARE. #include "XIint.h" int -XSelectExtensionEvent (dpy, w, event_list, count) - register Display *dpy; - Window w; - XEventClass *event_list; - int count; - { - register xSelectExtensionEventReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); - if (_XiCheckExtInit(dpy,XInput_Initial_Release) == -1) +XSelectExtensionEvent(dpy, w, event_list, count) + register Display *dpy; + Window w; + XEventClass *event_list; + int count; +{ + register xSelectExtensionEventReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); + if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(SelectExtensionEvent,req); + GetReq(SelectExtensionEvent, req); req->reqType = info->codes->major_opcode; req->ReqType = X_SelectExtensionEvent; @@ -82,13 +82,13 @@ XSelectExtensionEvent (dpy, w, event_list, count) req->length += count; /* note: Data is a macro that uses its arguments multiple - times, so "nvalues" is changed in a separate assignment - statement */ + * times, so "nvalues" is changed in a separate assignment + * statement */ count <<= 2; - Data32 (dpy, (long *) event_list, count); + Data32(dpy, (long *)event_list, count); UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XSetBMap.c b/src/XSetBMap.c index 716d8c5..bdfe501 100644 --- a/src/XSetBMap.c +++ b/src/XSetBMap.c @@ -63,31 +63,31 @@ SOFTWARE. /* returns either DeviceMappingSuccess or DeviceMappingBusy */ -int -XSetDeviceButtonMapping (dpy, device, map, nmap) - register Display *dpy; - XDevice *device; - unsigned char map[]; - int nmap; - { +int +XSetDeviceButtonMapping(dpy, device, map, nmap) + register Display *dpy; + XDevice *device; + unsigned char map[]; + int nmap; +{ register xSetDeviceButtonMappingReq *req; xSetDeviceButtonMappingReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); + XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq (SetDeviceButtonMapping, req); + GetReq(SetDeviceButtonMapping, req); req->reqType = info->codes->major_opcode; req->ReqType = X_SetDeviceButtonMapping; req->map_length = nmap; - req->length += (nmap + 3)>>2; + req->length += (nmap + 3) >> 2; req->deviceid = device->device_id; - Data (dpy, (char *)map, (long) nmap); /* note that map is char[] */ - if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0) /* suppress error */ + Data(dpy, (char *)map, (long)nmap); /* note that map is char[] */ + if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) /* suppress error */ rep.status = MappingSuccess; UnlockDisplay(dpy); SyncHandle(); - return ((int) rep.status); - } + return ((int)rep.status); +} diff --git a/src/XSetDVal.c b/src/XSetDVal.c index 3cee1a9..6b382f1 100644 --- a/src/XSetDVal.c +++ b/src/XSetDVal.c @@ -62,22 +62,22 @@ SOFTWARE. #include "XIint.h" int -XSetDeviceValuators (dpy, dev, valuators, first_valuator, num_valuators) - register Display *dpy; - XDevice *dev; - int *valuators; - int first_valuator; - int num_valuators; - { - xSetDeviceValuatorsReq *req; - xSetDeviceValuatorsReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XSetDeviceValuators(dpy, dev, valuators, first_valuator, num_valuators) + register Display *dpy; + XDevice *dev; + int *valuators; + int first_valuator; + int num_valuators; +{ + xSetDeviceValuatorsReq *req; + xSetDeviceValuatorsReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Add_XSetDeviceValuators) == -1) return (NoSuchExtension); - GetReq(SetDeviceValuators,req); + GetReq(SetDeviceValuators, req); req->reqType = info->codes->major_opcode; req->ReqType = X_SetDeviceValuators; req->deviceid = dev->device_id; @@ -86,15 +86,14 @@ XSetDeviceValuators (dpy, dev, valuators, first_valuator, num_valuators) req->length += num_valuators; /* note: Data is a macro that uses its arguments multiple - times, so "nvalues" is changed in a separate assignment - statement */ + * times, so "nvalues" is changed in a separate assignment + * statement */ num_valuators <<= 2; - Data (dpy, (char *) valuators, num_valuators); + Data(dpy, (char *)valuators, num_valuators); - (void) _XReply (dpy, (xReply *) &rep, 0, xTrue); + (void)_XReply(dpy, (xReply *) & rep, 0, xTrue); UnlockDisplay(dpy); SyncHandle(); return (rep.status); - } - +} diff --git a/src/XSetMMap.c b/src/XSetMMap.c index d31197c..b0838f6 100644 --- a/src/XSetMMap.c +++ b/src/XSetMMap.c @@ -60,18 +60,18 @@ SOFTWARE. #include <X11/extensions/extutil.h> #include "XIint.h" -int -XSetDeviceModifierMapping (dpy, dev, modmap) - register Display *dpy; - XDevice *dev; - XModifierKeymap *modmap; - { - int mapSize = modmap->max_keypermod << 3; /* 8 modifiers */ - xSetDeviceModifierMappingReq *req; - xSetDeviceModifierMappingReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +int +XSetDeviceModifierMapping(dpy, dev, modmap) + register Display *dpy; + XDevice *dev; + XModifierKeymap *modmap; +{ + int mapSize = modmap->max_keypermod << 3; /* 8 modifiers */ + xSetDeviceModifierMappingReq *req; + xSetDeviceModifierMappingReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); @@ -82,10 +82,11 @@ XSetDeviceModifierMapping (dpy, dev, modmap) req->numKeyPerModifier = modmap->max_keypermod; memcpy((char *)&req[1], modmap->modifiermap, mapSize); - (void) _XReply(dpy, (xReply *) &rep, - (sizeof(xSetDeviceModifierMappingReply) - sizeof(xReply)) >> 2, xTrue); + (void)_XReply(dpy, (xReply *) & rep, + (sizeof(xSetDeviceModifierMappingReply) - + sizeof(xReply)) >> 2, xTrue); UnlockDisplay(dpy); SyncHandle(); return (rep.success); - } +} diff --git a/src/XSetMode.c b/src/XSetMode.c index 5f62fb1..278c4ff 100644 --- a/src/XSetMode.c +++ b/src/XSetMode.c @@ -61,28 +61,27 @@ SOFTWARE. #include "XIint.h" int -XSetDeviceMode (dpy, dev, mode) - register Display *dpy; - XDevice *dev; - int mode; - { - xSetDeviceModeReq *req; - xSetDeviceModeReply rep; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XSetDeviceMode(dpy, dev, mode) + register Display *dpy; + XDevice *dev; + int mode; +{ + xSetDeviceModeReq *req; + xSetDeviceModeReply rep; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(SetDeviceMode,req); + GetReq(SetDeviceMode, req); req->reqType = info->codes->major_opcode; req->ReqType = X_SetDeviceMode; req->deviceid = dev->device_id; req->mode = mode; - (void) _XReply (dpy, (xReply *) &rep, 0, xTrue); + (void)_XReply(dpy, (xReply *) & rep, 0, xTrue); UnlockDisplay(dpy); SyncHandle(); return (rep.status); - } - +} diff --git a/src/XSndExEv.c b/src/XSndExEv.c index 28b654b..6d65745 100644 --- a/src/XSndExEv.c +++ b/src/XSndExEv.c @@ -63,61 +63,59 @@ SOFTWARE. extern Status _XiEventToWire(); Status -XSendExtensionEvent (dpy, dev, dest, prop, count, list, event) - register Display *dpy; - XDevice *dev; - Window dest; - Bool prop; - int count; - XEventClass *list; - XEvent *event; - { - int num_events; - int ev_size; - xSendExtensionEventReq *req; - xEvent *ev; - register Status (**fp)(); - Status status; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); +XSendExtensionEvent(dpy, dev, dest, prop, count, list, event) + register Display *dpy; + XDevice *dev; + Window dest; + Bool prop; + int count; + XEventClass *list; + XEvent *event; +{ + int num_events; + int ev_size; + xSendExtensionEventReq *req; + xEvent *ev; + register Status(**fp) (); + Status status; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); /* call through display to find proper conversion routine */ fp = &dpy->wire_vec[event->type & 0177]; - if (*fp == NULL) + if (*fp == NULL) *fp = _XiEventToWire; - status = (**fp)(dpy, event, &ev, &num_events); + status = (**fp) (dpy, event, &ev, &num_events); - if (status) - { - GetReq(SendExtensionEvent,req); - req->reqType = info->codes->major_opcode; + if (status) { + GetReq(SendExtensionEvent, req); + req->reqType = info->codes->major_opcode; req->ReqType = X_SendExtensionEvent; req->deviceid = dev->device_id; req->destination = dest; req->propagate = prop; req->count = count; req->num_events = num_events; - ev_size = num_events * sizeof (xEvent); + ev_size = num_events * sizeof(xEvent); req->length += (count + (ev_size >> 2)); /* note: Data is a macro that uses its arguments multiple - times, so "count" is changed in a separate assignment - statement. Any extra events must be sent before the event - list, in order to ensure quad alignment. */ + * times, so "count" is changed in a separate assignment + * statement. Any extra events must be sent before the event + * list, in order to ensure quad alignment. */ - Data (dpy, (char *) ev, ev_size); + Data(dpy, (char *)ev, ev_size); count <<= 2; - Data32 (dpy, (long *) list, count); - XFree ((char *)ev); - } + Data32(dpy, (long *)list, count); + XFree((char *)ev); + } UnlockDisplay(dpy); SyncHandle(); return (status); - } - +} diff --git a/src/XStFocus.c b/src/XStFocus.c index fc61896..08578c8 100644 --- a/src/XStFocus.c +++ b/src/XStFocus.c @@ -62,18 +62,18 @@ SOFTWARE. int XSetDeviceFocus(dpy, dev, focus, revert_to, time) - register Display *dpy; - XDevice *dev; - Window focus; - int revert_to; - Time time; - { - xSetDeviceFocusReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); - - LockDisplay (dpy); - - GetReq(SetDeviceFocus,req); + register Display *dpy; + XDevice *dev; + Window focus; + int revert_to; + Time time; +{ + xSetDeviceFocusReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); + + LockDisplay(dpy); + + GetReq(SetDeviceFocus, req); req->reqType = info->codes->major_opcode; req->ReqType = X_SetDeviceFocus; req->device = dev->device_id; @@ -84,4 +84,4 @@ XSetDeviceFocus(dpy, dev, focus, revert_to, time) UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XUngrDev.c b/src/XUngrDev.c index e3aec36..ecc8887 100644 --- a/src/XUngrDev.c +++ b/src/XUngrDev.c @@ -61,26 +61,26 @@ SOFTWARE. #include "XIint.h" int -XUngrabDevice (dpy, dev, time) +XUngrabDevice(dpy, dev, time) register Display *dpy; XDevice *dev; Time time; - { - register xUngrabDeviceReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); +{ + register xUngrabDeviceReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); - LockDisplay (dpy); + LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) return (NoSuchExtension); - GetReq(UngrabDevice,req); + GetReq(UngrabDevice, req); req->reqType = info->codes->major_opcode; req->ReqType = X_UngrabDevice; - + req->deviceid = dev->device_id; req->time = time; UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XUngrDvB.c b/src/XUngrDvB.c index 7e96665..07f2c3f 100644 --- a/src/XUngrDvB.c +++ b/src/XUngrDvB.c @@ -62,15 +62,15 @@ SOFTWARE. int XUngrabDeviceButton(dpy, dev, button, modifiers, modifier_dev, grab_window) - register Display *dpy; - XDevice *dev; - unsigned int button; /* CARD8 */ - unsigned int modifiers; /* CARD16 */ - XDevice *modifier_dev; - Window grab_window; - { - register xUngrabDeviceButtonReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); + register Display *dpy; + XDevice *dev; + unsigned int button; /* CARD8 */ + unsigned int modifiers; /* CARD16 */ + XDevice *modifier_dev; + Window grab_window; +{ + register xUngrabDeviceButtonReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) @@ -90,4 +90,4 @@ XUngrabDeviceButton(dpy, dev, button, modifiers, modifier_dev, grab_window) UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} diff --git a/src/XUngrDvK.c b/src/XUngrDvK.c index 26a5841..e9e4cdf 100644 --- a/src/XUngrDvK.c +++ b/src/XUngrDvK.c @@ -61,16 +61,16 @@ SOFTWARE. #include "XIint.h" int -XUngrabDeviceKey (dpy, dev, key, modifiers, modifier_dev, grab_window) - register Display *dpy; - XDevice *dev; - unsigned int key; /* CARD8 */ - unsigned int modifiers; /* CARD16 */ - XDevice *modifier_dev; - Window grab_window; - { - register xUngrabDeviceKeyReq *req; - XExtDisplayInfo *info = XInput_find_display (dpy); +XUngrabDeviceKey(dpy, dev, key, modifiers, modifier_dev, grab_window) + register Display *dpy; + XDevice *dev; + unsigned int key; /* CARD8 */ + unsigned int modifiers; /* CARD16 */ + XDevice *modifier_dev; + Window grab_window; +{ + register xUngrabDeviceKeyReq *req; + XExtDisplayInfo *info = XInput_find_display(dpy); LockDisplay(dpy); if (_XiCheckExtInit(dpy, XInput_Initial_Release) == -1) @@ -90,4 +90,4 @@ XUngrabDeviceKey (dpy, dev, key, modifiers, modifier_dev, grab_window) UnlockDisplay(dpy); SyncHandle(); return (Success); - } +} |