diff options
Diffstat (limited to 'xorg-server/Xi')
36 files changed, 2985 insertions, 3118 deletions
diff --git a/xorg-server/Xi/chgdctl.c b/xorg-server/Xi/chgdctl.c index ca697d9d8..ff5d69aef 100644 --- a/xorg-server/Xi/chgdctl.c +++ b/xorg-server/Xi/chgdctl.c @@ -54,9 +54,9 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> /* control constants */ +#include <X11/extensions/XIproto.h> /* control constants */ #include "XIstubs.h" #include "exglobals.h" @@ -80,17 +80,17 @@ SProcXChangeDeviceControl(ClientPtr client) swaps(&stuff->length); REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq); swaps(&stuff->control); - ctl = (xDeviceCtl*)&stuff[1]; + ctl = (xDeviceCtl *) &stuff[1]; swaps(&ctl->control); swaps(&ctl->length); - switch(stuff->control) { - case DEVICE_ABS_CALIB: - case DEVICE_ABS_AREA: - case DEVICE_CORE: - case DEVICE_ENABLE: - case DEVICE_RESOLUTION: - /* hmm. beer. *drool* */ - break; + switch (stuff->control) { + case DEVICE_ABS_CALIB: + case DEVICE_ABS_AREA: + case DEVICE_CORE: + case DEVICE_ENABLE: + case DEVICE_RESOLUTION: + /* hmm. beer. *drool* */ + break; } return (ProcXChangeDeviceControl(client)); @@ -130,44 +130,47 @@ ProcXChangeDeviceControl(ClientPtr client) switch (stuff->control) { case DEVICE_RESOLUTION: - r = (xDeviceResolutionCtl *) & stuff[1]; - if ((len < bytes_to_int32(sizeof(xDeviceResolutionCtl))) || - (len != bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) { + r = (xDeviceResolutionCtl *) &stuff[1]; + if ((len < bytes_to_int32(sizeof(xDeviceResolutionCtl))) || + (len != + bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) { ret = BadLength; goto out; - } - if (!dev->valuator) { + } + if (!dev->valuator) { ret = BadMatch; goto out; - } - if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) { - rep.status = AlreadyGrabbed; + } + if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) { + rep.status = AlreadyGrabbed; ret = Success; goto out; - } - resolution = (CARD32 *) (r + 1); - if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) { + } + resolution = (CARD32 *) (r + 1); + if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) { ret = BadValue; goto out; - } - status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r); - if (status == Success) { - a = &dev->valuator->axes[r->first_valuator]; - for (i = 0; i < r->num_valuators; i++) - if (*(resolution + i) < (a + i)->min_resolution || - *(resolution + i) > (a + i)->max_resolution) - return BadValue; - for (i = 0; i < r->num_valuators; i++) - (a++)->resolution = *resolution++; + } + status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r); + if (status == Success) { + a = &dev->valuator->axes[r->first_valuator]; + for (i = 0; i < r->num_valuators; i++) + if (*(resolution + i) < (a + i)->min_resolution || + *(resolution + i) > (a + i)->max_resolution) + return BadValue; + for (i = 0; i < r->num_valuators; i++) + (a++)->resolution = *resolution++; ret = Success; - } else if (status == DeviceBusy) { - rep.status = DeviceBusy; + } + else if (status == DeviceBusy) { + rep.status = DeviceBusy; ret = Success; - } else { + } + else { ret = BadMatch; - } - break; + } + break; case DEVICE_ABS_CALIB: case DEVICE_ABS_AREA: /* Calibration is now done through properties, and never had any effect @@ -180,7 +183,7 @@ ProcXChangeDeviceControl(ClientPtr client) ret = BadMatch; break; case DEVICE_ENABLE: - e = (xDeviceEnableCtl *)&stuff[1]; + e = (xDeviceEnableCtl *) &stuff[1]; status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e); @@ -190,10 +193,12 @@ ProcXChangeDeviceControl(ClientPtr client) else DisableDevice(dev, TRUE); ret = Success; - } else if (status == DeviceBusy) { + } + else if (status == DeviceBusy) { rep.status = DeviceBusy; ret = Success; - } else { + } + else { ret = BadMatch; } @@ -202,7 +207,7 @@ ProcXChangeDeviceControl(ClientPtr client) ret = BadValue; } -out: + out: if (ret == Success) { dpn.type = DevicePresenceNotify; dpn.time = currentTime.milliseconds; @@ -227,9 +232,9 @@ out: void SRepXChangeDeviceControl(ClientPtr client, int size, - xChangeDeviceControlReply * rep) + xChangeDeviceControlReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/chgfctl.c b/xorg-server/Xi/chgfctl.c index f818cd0ce..6dcf60c66 100644 --- a/xorg-server/Xi/chgfctl.c +++ b/xorg-server/Xi/chgfctl.c @@ -54,9 +54,9 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> -#include <X11/extensions/XIproto.h> /* control constants */ +#include <X11/extensions/XIproto.h> /* control constants */ #include "exglobals.h" @@ -89,107 +89,110 @@ SProcXChangeFeedbackControl(ClientPtr client) static int ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, - KbdFeedbackPtr k, xKbdFeedbackCtl * f) + KbdFeedbackPtr k, xKbdFeedbackCtl * f) { KeybdCtrl kctrl; int t; int key = DO_ALL; if (client->swapped) { - swaps(&f->length); - swaps(&f->pitch); - swaps(&f->duration); - swapl(&f->led_mask); - swapl(&f->led_values); + swaps(&f->length); + swaps(&f->pitch); + swaps(&f->duration); + swapl(&f->led_mask); + swapl(&f->led_values); } kctrl = k->ctrl; if (mask & DvKeyClickPercent) { - t = f->click; - if (t == -1) - t = defaultKeyboardControl.click; - else if (t < 0 || t > 100) { - client->errorValue = t; - return BadValue; - } - kctrl.click = t; + t = f->click; + if (t == -1) + t = defaultKeyboardControl.click; + else if (t < 0 || t > 100) { + client->errorValue = t; + return BadValue; + } + kctrl.click = t; } if (mask & DvPercent) { - t = f->percent; - if (t == -1) - t = defaultKeyboardControl.bell; - else if (t < 0 || t > 100) { - client->errorValue = t; - return BadValue; - } - kctrl.bell = t; + t = f->percent; + if (t == -1) + t = defaultKeyboardControl.bell; + else if (t < 0 || t > 100) { + client->errorValue = t; + return BadValue; + } + kctrl.bell = t; } if (mask & DvPitch) { - t = f->pitch; - if (t == -1) - t = defaultKeyboardControl.bell_pitch; - else if (t < 0) { - client->errorValue = t; - return BadValue; - } - kctrl.bell_pitch = t; + t = f->pitch; + if (t == -1) + t = defaultKeyboardControl.bell_pitch; + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + kctrl.bell_pitch = t; } if (mask & DvDuration) { - t = f->duration; - if (t == -1) - t = defaultKeyboardControl.bell_duration; - else if (t < 0) { - client->errorValue = t; - return BadValue; - } - kctrl.bell_duration = t; + t = f->duration; + if (t == -1) + t = defaultKeyboardControl.bell_duration; + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + kctrl.bell_duration = t; } if (mask & DvLed) { - kctrl.leds &= ~(f->led_mask); - kctrl.leds |= (f->led_mask & f->led_values); + kctrl.leds &= ~(f->led_mask); + kctrl.leds |= (f->led_mask & f->led_values); } if (mask & DvKey) { - key = (KeyCode) f->key; - if (key < 8 || key > 255) { - client->errorValue = key; - return BadValue; - } - if (!(mask & DvAutoRepeatMode)) - return BadMatch; + key = (KeyCode) f->key; + if (key < 8 || key > 255) { + client->errorValue = key; + return BadValue; + } + if (!(mask & DvAutoRepeatMode)) + return BadMatch; } if (mask & DvAutoRepeatMode) { - int inx = (key >> 3); - int kmask = (1 << (key & 7)); - - t = (CARD8) f->auto_repeat_mode; - if (t == AutoRepeatModeOff) { - if (key == DO_ALL) - kctrl.autoRepeat = FALSE; - else - kctrl.autoRepeats[inx] &= ~kmask; - } else if (t == AutoRepeatModeOn) { - if (key == DO_ALL) - kctrl.autoRepeat = TRUE; - else - kctrl.autoRepeats[inx] |= kmask; - } else if (t == AutoRepeatModeDefault) { - if (key == DO_ALL) - kctrl.autoRepeat = defaultKeyboardControl.autoRepeat; - else - kctrl.autoRepeats[inx] &= ~kmask; - kctrl.autoRepeats[inx] = - (kctrl.autoRepeats[inx] & ~kmask) | - (defaultKeyboardControl.autoRepeats[inx] & kmask); - } else { - client->errorValue = t; - return BadValue; - } + int inx = (key >> 3); + int kmask = (1 << (key & 7)); + + t = (CARD8) f->auto_repeat_mode; + if (t == AutoRepeatModeOff) { + if (key == DO_ALL) + kctrl.autoRepeat = FALSE; + else + kctrl.autoRepeats[inx] &= ~kmask; + } + else if (t == AutoRepeatModeOn) { + if (key == DO_ALL) + kctrl.autoRepeat = TRUE; + else + kctrl.autoRepeats[inx] |= kmask; + } + else if (t == AutoRepeatModeDefault) { + if (key == DO_ALL) + kctrl.autoRepeat = defaultKeyboardControl.autoRepeat; + else + kctrl.autoRepeats[inx] &= ~kmask; + kctrl.autoRepeats[inx] = + (kctrl.autoRepeats[inx] & ~kmask) | + (defaultKeyboardControl.autoRepeats[inx] & kmask); + } + else { + client->errorValue = t; + return BadValue; + } } k->ctrl = kctrl; @@ -205,55 +208,58 @@ ChangeKbdFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, static int ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, - PtrFeedbackPtr p, xPtrFeedbackCtl * f) + PtrFeedbackPtr p, xPtrFeedbackCtl * f) { - PtrCtrl pctrl; /* might get BadValue part way through */ + PtrCtrl pctrl; /* might get BadValue part way through */ if (client->swapped) { - swaps(&f->length); - swaps(&f->num); - swaps(&f->denom); - swaps(&f->thresh); + swaps(&f->length); + swaps(&f->num); + swaps(&f->denom); + swaps(&f->thresh); } pctrl = p->ctrl; if (mask & DvAccelNum) { - int accelNum; - - accelNum = f->num; - if (accelNum == -1) - pctrl.num = defaultPointerControl.num; - else if (accelNum < 0) { - client->errorValue = accelNum; - return BadValue; - } else - pctrl.num = accelNum; + int accelNum; + + accelNum = f->num; + if (accelNum == -1) + pctrl.num = defaultPointerControl.num; + else if (accelNum < 0) { + client->errorValue = accelNum; + return BadValue; + } + else + pctrl.num = accelNum; } if (mask & DvAccelDenom) { - int accelDenom; - - accelDenom = f->denom; - if (accelDenom == -1) - pctrl.den = defaultPointerControl.den; - else if (accelDenom <= 0) { - client->errorValue = accelDenom; - return BadValue; - } else - pctrl.den = accelDenom; + int accelDenom; + + accelDenom = f->denom; + if (accelDenom == -1) + pctrl.den = defaultPointerControl.den; + else if (accelDenom <= 0) { + client->errorValue = accelDenom; + return BadValue; + } + else + pctrl.den = accelDenom; } if (mask & DvThreshold) { - int threshold; - - threshold = f->thresh; - if (threshold == -1) - pctrl.threshold = defaultPointerControl.threshold; - else if (threshold < 0) { - client->errorValue = threshold; - return BadValue; - } else - pctrl.threshold = threshold; + int threshold; + + threshold = f->thresh; + if (threshold == -1) + pctrl.threshold = defaultPointerControl.threshold; + else if (threshold < 0) { + client->errorValue = threshold; + return BadValue; + } + else + pctrl.threshold = threshold; } p->ctrl = pctrl; @@ -269,12 +275,12 @@ ChangePtrFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, static int ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev, - long unsigned int mask, IntegerFeedbackPtr i, - xIntegerFeedbackCtl * f) + long unsigned int mask, IntegerFeedbackPtr i, + xIntegerFeedbackCtl * f) { if (client->swapped) { - swaps(&f->length); - swapl(&f->int_to_display); + swaps(&f->length); + swapl(&f->int_to_display); } i->ctrl.integer_displayed = f->int_to_display; @@ -290,33 +296,33 @@ ChangeIntegerFeedback(ClientPtr client, DeviceIntPtr dev, static int ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, - long unsigned int mask, StringFeedbackPtr s, - xStringFeedbackCtl * f) + long unsigned int mask, StringFeedbackPtr s, + xStringFeedbackCtl * f) { int i, j; KeySym *syms, *sup_syms; syms = (KeySym *) (f + 1); if (client->swapped) { - swaps(&f->length); /* swapped num_keysyms in calling proc */ - SwapLongs((CARD32 *) syms, f->num_keysyms); + swaps(&f->length); /* swapped num_keysyms in calling proc */ + SwapLongs((CARD32 *) syms, f->num_keysyms); } if (f->num_keysyms > s->ctrl.max_symbols) - return BadValue; + return BadValue; sup_syms = s->ctrl.symbols_supported; for (i = 0; i < f->num_keysyms; i++) { - for (j = 0; j < s->ctrl.num_symbols_supported; j++) - if (*(syms + i) == *(sup_syms + j)) - break; - if (j == s->ctrl.num_symbols_supported) - return BadMatch; + for (j = 0; j < s->ctrl.num_symbols_supported; j++) + if (*(syms + i) == *(sup_syms + j)) + break; + if (j == s->ctrl.num_symbols_supported) + return BadMatch; } s->ctrl.num_symbols_displayed = f->num_keysyms; for (i = 0; i < f->num_keysyms; i++) - *(s->ctrl.symbols_displayed + i) = *(syms + i); + *(s->ctrl.symbols_displayed + i) = *(syms + i); (*s->CtrlProc) (dev, &s->ctrl); return Success; } @@ -329,50 +335,50 @@ ChangeStringFeedback(ClientPtr client, DeviceIntPtr dev, static int ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, - long unsigned int mask, BellFeedbackPtr b, - xBellFeedbackCtl * f) + long unsigned int mask, BellFeedbackPtr b, + xBellFeedbackCtl * f) { int t; - BellCtrl bctrl; /* might get BadValue part way through */ + BellCtrl bctrl; /* might get BadValue part way through */ if (client->swapped) { - swaps(&f->length); - swaps(&f->pitch); - swaps(&f->duration); + swaps(&f->length); + swaps(&f->pitch); + swaps(&f->duration); } bctrl = b->ctrl; if (mask & DvPercent) { - t = f->percent; - if (t == -1) - t = defaultKeyboardControl.bell; - else if (t < 0 || t > 100) { - client->errorValue = t; - return BadValue; - } - bctrl.percent = t; + t = f->percent; + if (t == -1) + t = defaultKeyboardControl.bell; + else if (t < 0 || t > 100) { + client->errorValue = t; + return BadValue; + } + bctrl.percent = t; } if (mask & DvPitch) { - t = f->pitch; - if (t == -1) - t = defaultKeyboardControl.bell_pitch; - else if (t < 0) { - client->errorValue = t; - return BadValue; - } - bctrl.pitch = t; + t = f->pitch; + if (t == -1) + t = defaultKeyboardControl.bell_pitch; + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + bctrl.pitch = t; } if (mask & DvDuration) { - t = f->duration; - if (t == -1) - t = defaultKeyboardControl.bell_duration; - else if (t < 0) { - client->errorValue = t; - return BadValue; - } - bctrl.duration = t; + t = f->duration; + if (t == -1) + t = defaultKeyboardControl.bell_duration; + else if (t < 0) { + client->errorValue = t; + return BadValue; + } + bctrl.duration = t; } b->ctrl = bctrl; (*b->CtrlProc) (dev, &b->ctrl); @@ -387,24 +393,24 @@ ChangeBellFeedback(ClientPtr client, DeviceIntPtr dev, static int ChangeLedFeedback(ClientPtr client, DeviceIntPtr dev, long unsigned int mask, - LedFeedbackPtr l, xLedFeedbackCtl * f) + LedFeedbackPtr l, xLedFeedbackCtl * f) { - LedCtrl lctrl; /* might get BadValue part way through */ + LedCtrl lctrl; /* might get BadValue part way through */ if (client->swapped) { - swaps(&f->length); - swapl(&f->led_values); - swapl(&f->led_mask); + swaps(&f->length); + swapl(&f->led_values); + swapl(&f->led_mask); } - f->led_mask &= l->ctrl.led_mask; /* set only supported leds */ - f->led_values &= l->ctrl.led_mask; /* set only supported leds */ + f->led_mask &= l->ctrl.led_mask; /* set only supported leds */ + f->led_values &= l->ctrl.led_mask; /* set only supported leds */ if (mask & DvLed) { - lctrl.led_mask = f->led_mask; - lctrl.led_values = f->led_values; - (*l->CtrlProc) (dev, &lctrl); - l->ctrl.led_values &= ~(f->led_mask); /* zero changed leds */ - l->ctrl.led_values |= (f->led_mask & f->led_values); /* OR in set leds */ + lctrl.led_mask = f->led_mask; + lctrl.led_values = f->led_values; + (*l->CtrlProc) (dev, &lctrl); + l->ctrl.led_values &= ~(f->led_mask); /* zero changed leds */ + l->ctrl.led_values |= (f->led_mask & f->led_values); /* OR in set leds */ } return Success; @@ -435,74 +441,75 @@ ProcXChangeFeedbackControl(ClientPtr client) len = stuff->length - bytes_to_int32(sizeof(xChangeFeedbackControlReq)); rc = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); if (rc != Success) - return rc; + return rc; switch (stuff->feedbackid) { case KbdFeedbackClass: - if (len != bytes_to_int32(sizeof(xKbdFeedbackCtl))) - return BadLength; - - for (k = dev->kbdfeed; k; k = k->next) - if (k->ctrl.id == ((xKbdFeedbackCtl *) & stuff[1])->id) - return ChangeKbdFeedback(client, dev, stuff->mask, k, - (xKbdFeedbackCtl *) & stuff[1]); - break; + if (len != bytes_to_int32(sizeof(xKbdFeedbackCtl))) + return BadLength; + + for (k = dev->kbdfeed; k; k = k->next) + if (k->ctrl.id == ((xKbdFeedbackCtl *) &stuff[1])->id) + return ChangeKbdFeedback(client, dev, stuff->mask, k, + (xKbdFeedbackCtl *) &stuff[1]); + break; case PtrFeedbackClass: - if (len != bytes_to_int32(sizeof(xPtrFeedbackCtl))) - return BadLength; - - for (p = dev->ptrfeed; p; p = p->next) - if (p->ctrl.id == ((xPtrFeedbackCtl *) & stuff[1])->id) - return ChangePtrFeedback(client, dev, stuff->mask, p, - (xPtrFeedbackCtl *) & stuff[1]); - break; + if (len != bytes_to_int32(sizeof(xPtrFeedbackCtl))) + return BadLength; + + for (p = dev->ptrfeed; p; p = p->next) + if (p->ctrl.id == ((xPtrFeedbackCtl *) &stuff[1])->id) + return ChangePtrFeedback(client, dev, stuff->mask, p, + (xPtrFeedbackCtl *) &stuff[1]); + break; case StringFeedbackClass: { - xStringFeedbackCtl *f = ((xStringFeedbackCtl *) & stuff[1]); - - if (client->swapped) { - swaps(&f->num_keysyms); - } - if (len != (bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms)) - return BadLength; - - for (s = dev->stringfeed; s; s = s->next) - if (s->ctrl.id == ((xStringFeedbackCtl *) & stuff[1])->id) - return ChangeStringFeedback(client, dev, stuff->mask, s, - (xStringFeedbackCtl *) & stuff[1]); - break; + xStringFeedbackCtl *f = ((xStringFeedbackCtl *) &stuff[1]); + + if (client->swapped) { + swaps(&f->num_keysyms); + } + if (len != + (bytes_to_int32(sizeof(xStringFeedbackCtl)) + f->num_keysyms)) + return BadLength; + + for (s = dev->stringfeed; s; s = s->next) + if (s->ctrl.id == ((xStringFeedbackCtl *) &stuff[1])->id) + return ChangeStringFeedback(client, dev, stuff->mask, s, + (xStringFeedbackCtl *) &stuff[1]); + break; } case IntegerFeedbackClass: - if (len != bytes_to_int32(sizeof(xIntegerFeedbackCtl))) - return BadLength; - - for (i = dev->intfeed; i; i = i->next) - if (i->ctrl.id == ((xIntegerFeedbackCtl *) & stuff[1])->id) - return ChangeIntegerFeedback(client, dev, stuff->mask, i, - (xIntegerFeedbackCtl *)&stuff[1]); - break; + if (len != bytes_to_int32(sizeof(xIntegerFeedbackCtl))) + return BadLength; + + for (i = dev->intfeed; i; i = i->next) + if (i->ctrl.id == ((xIntegerFeedbackCtl *) &stuff[1])->id) + return ChangeIntegerFeedback(client, dev, stuff->mask, i, + (xIntegerFeedbackCtl *) & + stuff[1]); + break; case LedFeedbackClass: - if (len != bytes_to_int32(sizeof(xLedFeedbackCtl))) - return BadLength; - - for (l = dev->leds; l; l = l->next) - if (l->ctrl.id == ((xLedFeedbackCtl *) & stuff[1])->id) - return ChangeLedFeedback(client, dev, stuff->mask, l, - (xLedFeedbackCtl *) & stuff[1]); - break; + if (len != bytes_to_int32(sizeof(xLedFeedbackCtl))) + return BadLength; + + for (l = dev->leds; l; l = l->next) + if (l->ctrl.id == ((xLedFeedbackCtl *) &stuff[1])->id) + return ChangeLedFeedback(client, dev, stuff->mask, l, + (xLedFeedbackCtl *) &stuff[1]); + break; case BellFeedbackClass: - if (len != bytes_to_int32(sizeof(xBellFeedbackCtl))) - return BadLength; - - for (b = dev->bell; b; b = b->next) - if (b->ctrl.id == ((xBellFeedbackCtl *) & stuff[1])->id) - return ChangeBellFeedback(client, dev, stuff->mask, b, - (xBellFeedbackCtl *) & stuff[1]); - break; + if (len != bytes_to_int32(sizeof(xBellFeedbackCtl))) + return BadLength; + + for (b = dev->bell; b; b = b->next) + if (b->ctrl.id == ((xBellFeedbackCtl *) &stuff[1])->id) + return ChangeBellFeedback(client, dev, stuff->mask, b, + (xBellFeedbackCtl *) &stuff[1]); + break; default: - break; + break; } return BadMatch; } - diff --git a/xorg-server/Xi/chgprop.c b/xorg-server/Xi/chgprop.c index a9f833c25..84fb51dcb 100644 --- a/xorg-server/Xi/chgprop.c +++ b/xorg-server/Xi/chgprop.c @@ -54,7 +54,7 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include "windowstr.h" #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> @@ -80,7 +80,7 @@ SProcXChangeDeviceDontPropagateList(ClientPtr client) swapl(&stuff->window); swaps(&stuff->count); REQUEST_FIXED_SIZE(xChangeDeviceDontPropagateListReq, - stuff->count * sizeof(CARD32)); + stuff->count * sizeof(CARD32)); SwapLongs((CARD32 *) (&stuff[1]), stuff->count); return (ProcXChangeDeviceDontPropagateList(client)); } @@ -102,39 +102,40 @@ ProcXChangeDeviceDontPropagateList(ClientPtr client) REQUEST(xChangeDeviceDontPropagateListReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceDontPropagateListReq); - if (stuff->length != bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) + - stuff->count) - return BadLength; + if (stuff->length != + bytes_to_int32(sizeof(xChangeDeviceDontPropagateListReq)) + + stuff->count) + return BadLength; rc = dixLookupWindow(&pWin, stuff->window, client, DixSetAttrAccess); if (rc != Success) - return rc; + return rc; if (stuff->mode != AddToList && stuff->mode != DeleteFromList) { - client->errorValue = stuff->window; - return BadMode; + client->errorValue = stuff->window; + return BadMode; } - if ((rc = CreateMaskFromList(client, (XEventClass *) & stuff[1], - stuff->count, tmp, NULL, - X_ChangeDeviceDontPropagateList)) != Success) - return rc; + if ((rc = CreateMaskFromList(client, (XEventClass *) &stuff[1], + stuff->count, tmp, NULL, + X_ChangeDeviceDontPropagateList)) != Success) + return rc; others = wOtherInputMasks(pWin); if (!others && stuff->mode == DeleteFromList) - return Success; + return Success; for (i = 0; i < EMASKSIZE; i++) { - if (tmp[i].mask == 0) - continue; + if (tmp[i].mask == 0) + continue; - if (stuff->mode == DeleteFromList) - tmp[i].mask = (others->dontPropagateMask[i] & ~tmp[i].mask); - else if (others) - tmp[i].mask |= others->dontPropagateMask[i]; + if (stuff->mode == DeleteFromList) + tmp[i].mask = (others->dontPropagateMask[i] & ~tmp[i].mask); + else if (others) + tmp[i].mask |= others->dontPropagateMask[i]; - if (DeviceEventSuppressForWindow(pWin, client, tmp[i].mask, i) != - Success) - return BadClass; + if (DeviceEventSuppressForWindow(pWin, client, tmp[i].mask, i) != + Success) + return BadClass; } return Success; diff --git a/xorg-server/Xi/devbell.c b/xorg-server/Xi/devbell.c index 881524260..c75b94dee 100644 --- a/xorg-server/Xi/devbell.c +++ b/xorg-server/Xi/devbell.c @@ -54,7 +54,7 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exglobals.h" @@ -99,47 +99,49 @@ ProcXDeviceBell(ClientPtr client) rc = dixLookupDevice(&dev, stuff->deviceid, client, DixBellAccess); if (rc != Success) { - client->errorValue = stuff->deviceid; - return rc; + client->errorValue = stuff->deviceid; + return rc; } if (stuff->percent < -100 || stuff->percent > 100) { - client->errorValue = stuff->percent; - return BadValue; + client->errorValue = stuff->percent; + return BadValue; } if (stuff->feedbackclass == KbdFeedbackClass) { - for (k = dev->kbdfeed; k; k = k->next) - if (k->ctrl.id == stuff->feedbackid) - break; - if (!k) { - client->errorValue = stuff->feedbackid; - return BadValue; - } - base = k->ctrl.bell; - proc = k->BellProc; - ctrl = (pointer) & (k->ctrl); - class = KbdFeedbackClass; - } else if (stuff->feedbackclass == BellFeedbackClass) { - for (b = dev->bell; b; b = b->next) - if (b->ctrl.id == stuff->feedbackid) - break; - if (!b) { - client->errorValue = stuff->feedbackid; - return BadValue; - } - base = b->ctrl.percent; - proc = b->BellProc; - ctrl = (pointer) & (b->ctrl); - class = BellFeedbackClass; - } else { - client->errorValue = stuff->feedbackclass; - return BadValue; + for (k = dev->kbdfeed; k; k = k->next) + if (k->ctrl.id == stuff->feedbackid) + break; + if (!k) { + client->errorValue = stuff->feedbackid; + return BadValue; + } + base = k->ctrl.bell; + proc = k->BellProc; + ctrl = (pointer) &(k->ctrl); + class = KbdFeedbackClass; + } + else if (stuff->feedbackclass == BellFeedbackClass) { + for (b = dev->bell; b; b = b->next) + if (b->ctrl.id == stuff->feedbackid) + break; + if (!b) { + client->errorValue = stuff->feedbackid; + return BadValue; + } + base = b->ctrl.percent; + proc = b->BellProc; + ctrl = (pointer) &(b->ctrl); + class = BellFeedbackClass; + } + else { + client->errorValue = stuff->feedbackclass; + return BadValue; } newpercent = (base * stuff->percent) / 100; if (stuff->percent < 0) - newpercent = base + newpercent; + newpercent = base + newpercent; else - newpercent = base - newpercent + stuff->percent; + newpercent = base - newpercent + stuff->percent; (*proc) (newpercent, dev, ctrl, class); return Success; diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c index f390f6739..ff2224094 100644 --- a/xorg-server/Xi/exevents.c +++ b/xorg-server/Xi/exevents.c @@ -95,12 +95,12 @@ SOFTWARE. #include "exevents.h" #include "extnsionst.h" #include "exglobals.h" -#include "dixevents.h" /* DeliverFocusedEvent */ -#include "dixgrabs.h" /* CreateGrab() */ +#include "dixevents.h" /* DeliverFocusedEvent */ +#include "dixgrabs.h" /* CreateGrab() */ #include "scrnintstr.h" -#include "listdev.h" /* for CopySwapXXXClass */ +#include "listdev.h" /* for CopySwapXXXClass */ #include "xace.h" -#include "xiquerydevice.h" /* For List*Info */ +#include "xiquerydevice.h" /* For List*Info */ #include "eventconvert.h" #include "eventstr.h" #include "inpututils.h" @@ -117,9 +117,9 @@ SOFTWARE. Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask ) Bool ShouldFreeInputMasks(WindowPtr /* pWin */ , - Bool /* ignoreSelectedEvents */ + Bool /* ignoreSelectedEvents */ ); -static Bool MakeInputMasks(WindowPtr /* pWin */ +static Bool MakeInputMasks(WindowPtr /* pWin */ ); /* @@ -140,32 +140,30 @@ XIShouldNotify(ClientPtr client, DeviceIntPtr dev) } Bool -IsPointerEvent(InternalEvent* event) -{ - switch(event->any.type) - { - case ET_ButtonPress: - case ET_ButtonRelease: - case ET_Motion: - /* XXX: enter/leave ?? */ - return TRUE; - default: - break; +IsPointerEvent(InternalEvent *event) +{ + switch (event->any.type) { + case ET_ButtonPress: + case ET_ButtonRelease: + case ET_Motion: + /* XXX: enter/leave ?? */ + return TRUE; + default: + break; } return FALSE; } Bool -IsTouchEvent(InternalEvent* event) -{ - switch(event->any.type) - { - case ET_TouchBegin: - case ET_TouchUpdate: - case ET_TouchEnd: - return TRUE; - default: - break; +IsTouchEvent(InternalEvent *event) +{ + switch (event->any.type) { + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: + return TRUE; + default: + break; } return FALSE; } @@ -175,7 +173,7 @@ IsTouchEvent(InternalEvent* event) * NULL if the event is not an XInput event. */ DeviceIntPtr -XIGetDevice(xEvent* xE) +XIGetDevice(xEvent *xE) { DeviceIntPtr pDev = NULL; @@ -183,13 +181,11 @@ XIGetDevice(xEvent* xE) xE->u.u.type == DeviceButtonRelease || xE->u.u.type == DeviceMotionNotify || xE->u.u.type == ProximityIn || - xE->u.u.type == ProximityOut || - xE->u.u.type == DevicePropertyNotify) - { + xE->u.u.type == ProximityOut || xE->u.u.type == DevicePropertyNotify) { int rc; int id; - id = ((deviceKeyButtonPointer*)xE)->deviceid & ~MORE_EVENTS; + id = ((deviceKeyButtonPointer *) xE)->deviceid & ~MORE_EVENTS; rc = dixLookupDevice(&pDev, id, serverClient, DixUnknownAccess); if (rc != Success) @@ -198,7 +194,6 @@ XIGetDevice(xEvent* xE) return pDev; } - /** * Copy the device->key into master->key and send a mapping notify to the * clients if appropriate. @@ -235,7 +230,6 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master) mk->sourceid = device->id; - if (!XkbCopyDeviceKeymap(master, device)) FatalError("Couldn't pivot keymap from device to core!\n"); } @@ -250,153 +244,136 @@ DeepCopyFeedbackClasses(DeviceIntPtr from, DeviceIntPtr to) { ClassesPtr classes; - - if (from->intfeed) - { + if (from->intfeed) { IntegerFeedbackPtr *i, it; - if (!to->intfeed) - { + if (!to->intfeed) { classes = to->unused_classes; to->intfeed = classes->intfeed; classes->intfeed = NULL; } i = &to->intfeed; - for (it = from->intfeed; it; it = it->next) - { - if (!(*i)) - { + for (it = from->intfeed; it; it = it->next) { + if (!(*i)) { *i = calloc(1, sizeof(IntegerFeedbackClassRec)); - if (!(*i)) - { + if (!(*i)) { ErrorF("[Xi] Cannot alloc memory for class copy."); return; } } (*i)->CtrlProc = it->CtrlProc; - (*i)->ctrl = it->ctrl; + (*i)->ctrl = it->ctrl; i = &(*i)->next; } - } else if (to->intfeed && !from->intfeed) - { + } + else if (to->intfeed && !from->intfeed) { ClassesPtr classes; + classes = to->unused_classes; classes->intfeed = to->intfeed; - to->intfeed = NULL; + to->intfeed = NULL; } - if (from->stringfeed) - { + if (from->stringfeed) { StringFeedbackPtr *s, it; - if (!to->stringfeed) - { + if (!to->stringfeed) { classes = to->unused_classes; to->stringfeed = classes->stringfeed; classes->stringfeed = NULL; } s = &to->stringfeed; - for (it = from->stringfeed; it; it = it->next) - { - if (!(*s)) - { + for (it = from->stringfeed; it; it = it->next) { + if (!(*s)) { *s = calloc(1, sizeof(StringFeedbackClassRec)); - if (!(*s)) - { + if (!(*s)) { ErrorF("[Xi] Cannot alloc memory for class copy."); return; } } (*s)->CtrlProc = it->CtrlProc; - (*s)->ctrl = it->ctrl; + (*s)->ctrl = it->ctrl; s = &(*s)->next; } - } else if (to->stringfeed && !from->stringfeed) - { + } + else if (to->stringfeed && !from->stringfeed) { ClassesPtr classes; + classes = to->unused_classes; classes->stringfeed = to->stringfeed; - to->stringfeed = NULL; + to->stringfeed = NULL; } - if (from->bell) - { + if (from->bell) { BellFeedbackPtr *b, it; - if (!to->bell) - { + if (!to->bell) { classes = to->unused_classes; to->bell = classes->bell; classes->bell = NULL; } b = &to->bell; - for (it = from->bell; it; it = it->next) - { - if (!(*b)) - { + for (it = from->bell; it; it = it->next) { + if (!(*b)) { *b = calloc(1, sizeof(BellFeedbackClassRec)); - if (!(*b)) - { + if (!(*b)) { ErrorF("[Xi] Cannot alloc memory for class copy."); return; } } (*b)->BellProc = it->BellProc; (*b)->CtrlProc = it->CtrlProc; - (*b)->ctrl = it->ctrl; + (*b)->ctrl = it->ctrl; b = &(*b)->next; } - } else if (to->bell && !from->bell) - { + } + else if (to->bell && !from->bell) { ClassesPtr classes; + classes = to->unused_classes; classes->bell = to->bell; - to->bell = NULL; + to->bell = NULL; } - if (from->leds) - { + if (from->leds) { LedFeedbackPtr *l, it; - if (!to->leds) - { + if (!to->leds) { classes = to->unused_classes; to->leds = classes->leds; classes->leds = NULL; } l = &to->leds; - for (it = from->leds; it; it = it->next) - { - if (!(*l)) - { + for (it = from->leds; it; it = it->next) { + if (!(*l)) { *l = calloc(1, sizeof(LedFeedbackClassRec)); - if (!(*l)) - { + if (!(*l)) { ErrorF("[Xi] Cannot alloc memory for class copy."); return; } } (*l)->CtrlProc = it->CtrlProc; - (*l)->ctrl = it->ctrl; + (*l)->ctrl = it->ctrl; if ((*l)->xkb_sli) XkbFreeSrvLedInfo((*l)->xkb_sli); (*l)->xkb_sli = XkbCopySrvLedInfo(from, it->xkb_sli, NULL, *l); l = &(*l)->next; } - } else if (to->leds && !from->leds) - { + } + else if (to->leds && !from->leds) { ClassesPtr classes; + classes = to->unused_classes; classes->leds = to->leds; - to->leds = NULL; + to->leds = NULL; } } @@ -408,12 +385,10 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) /* XkbInitDevice (->XkbInitIndicatorMap->XkbFindSrvLedInfo) relies on the * kbdfeed to be set up properly, so let's do the feedback classes first. */ - if (from->kbdfeed) - { + if (from->kbdfeed) { KbdFeedbackPtr *k, it; - if (!to->kbdfeed) - { + if (!to->kbdfeed) { classes = to->unused_classes; to->kbdfeed = classes->kbdfeed; @@ -423,38 +398,34 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) } k = &to->kbdfeed; - for(it = from->kbdfeed; it; it = it->next) - { - if (!(*k)) - { + for (it = from->kbdfeed; it; it = it->next) { + if (!(*k)) { *k = calloc(1, sizeof(KbdFeedbackClassRec)); - if (!*k) - { + if (!*k) { ErrorF("[Xi] Cannot alloc memory for class copy."); return; } } (*k)->BellProc = it->BellProc; (*k)->CtrlProc = it->CtrlProc; - (*k)->ctrl = it->ctrl; + (*k)->ctrl = it->ctrl; if ((*k)->xkb_sli) XkbFreeSrvLedInfo((*k)->xkb_sli); (*k)->xkb_sli = XkbCopySrvLedInfo(from, it->xkb_sli, *k, NULL); k = &(*k)->next; } - } else if (to->kbdfeed && !from->kbdfeed) - { + } + else if (to->kbdfeed && !from->kbdfeed) { ClassesPtr classes; + classes = to->unused_classes; classes->kbdfeed = to->kbdfeed; - to->kbdfeed = NULL; + to->kbdfeed = NULL; } - if (from->key) - { - if (!to->key) - { + if (from->key) { + if (!to->key) { classes = to->unused_classes; to->key = classes->key; if (!to->key) @@ -464,28 +435,26 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) } CopyKeyClass(from, to); - } else if (to->key && !from->key) - { + } + else if (to->key && !from->key) { ClassesPtr classes; + classes = to->unused_classes; classes->key = to->key; - to->key = NULL; + to->key = NULL; } /* If a SrvLedInfoPtr's flags are XkbSLI_IsDefault, the names and maps * pointer point into the xkbInfo->desc struct. XkbCopySrvLedInfo * didn't update the pointers so we need to do it manually here. */ - if (to->kbdfeed) - { + if (to->kbdfeed) { KbdFeedbackPtr k; - for (k = to->kbdfeed; k; k = k->next) - { + for (k = to->kbdfeed; k; k = k->next) { if (!k->xkb_sli) continue; - if (k->xkb_sli->flags & XkbSLI_IsDefault) - { + if (k->xkb_sli->flags & XkbSLI_IsDefault) { k->xkb_sli->names = to->key->xkbInfo->desc->names->indicators; k->xkb_sli->maps = to->key->xkbInfo->desc->indicators->maps; } @@ -498,38 +467,38 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to) * So we only copy the focus class if the device didn't have one, * otherwise we leave it as it is. */ - if (from->focus) - { - if (!to->focus) - { + if (from->focus) { + if (!to->focus) { WindowPtr *oldTrace; classes = to->unused_classes; to->focus = classes->focus; - if (!to->focus) - { + if (!to->focus) { to->focus = calloc(1, sizeof(FocusClassRec)); if (!to->focus) FatalError("[Xi] no memory for class shift.\n"); - } else + } + else classes->focus = NULL; oldTrace = to->focus->trace; memcpy(to->focus, from->focus, sizeof(FocusClassRec)); to->focus->trace = realloc(oldTrace, - to->focus->traceSize * sizeof(WindowPtr)); + to->focus->traceSize * + sizeof(WindowPtr)); if (!to->focus->trace && to->focus->traceSize) FatalError("[Xi] no memory for trace.\n"); memcpy(to->focus->trace, from->focus->trace, - from->focus->traceSize * sizeof(WindowPtr)); + from->focus->traceSize * sizeof(WindowPtr)); to->focus->sourceid = from->id; } - } else if (to->focus) - { + } + else if (to->focus) { ClassesPtr classes; + classes = to->unused_classes; classes->focus = to->focus; - to->focus = NULL; + to->focus = NULL; } } @@ -542,47 +511,42 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) ClassesPtr classes; /* Feedback classes must be copied first */ - if (from->ptrfeed) - { + if (from->ptrfeed) { PtrFeedbackPtr *p, it; - if (!to->ptrfeed) - { + + if (!to->ptrfeed) { classes = to->unused_classes; to->ptrfeed = classes->ptrfeed; classes->ptrfeed = NULL; } p = &to->ptrfeed; - for (it = from->ptrfeed; it; it = it->next) - { - if (!(*p)) - { + for (it = from->ptrfeed; it; it = it->next) { + if (!(*p)) { *p = calloc(1, sizeof(PtrFeedbackClassRec)); - if (!*p) - { + if (!*p) { ErrorF("[Xi] Cannot alloc memory for class copy."); return; } } (*p)->CtrlProc = it->CtrlProc; - (*p)->ctrl = it->ctrl; + (*p)->ctrl = it->ctrl; p = &(*p)->next; } - } else if (to->ptrfeed && !from->ptrfeed) - { + } + else if (to->ptrfeed && !from->ptrfeed) { ClassesPtr classes; + classes = to->unused_classes; classes->ptrfeed = to->ptrfeed; - to->ptrfeed = NULL; + to->ptrfeed = NULL; } - if (from->valuator) - { + if (from->valuator) { ValuatorClassPtr v; - if (!to->valuator) - { + if (!to->valuator) { classes = to->unused_classes; to->valuator = classes->valuator; if (to->valuator) @@ -598,87 +562,84 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) memcpy(v->axes, from->valuator->axes, v->numAxes * sizeof(AxisInfo)); v->sourceid = from->id; - } else if (to->valuator && !from->valuator) - { + } + else if (to->valuator && !from->valuator) { ClassesPtr classes; + classes = to->unused_classes; classes->valuator = to->valuator; - to->valuator = NULL; + to->valuator = NULL; } - if (from->button) - { - if (!to->button) - { + if (from->button) { + if (!to->button) { classes = to->unused_classes; to->button = classes->button; - if (!to->button) - { + if (!to->button) { to->button = calloc(1, sizeof(ButtonClassRec)); if (!to->button) FatalError("[Xi] no memory for class shift.\n"); - } else + } + else classes->button = NULL; } - if (from->button->xkb_acts) - { - if (!to->button->xkb_acts) - { + if (from->button->xkb_acts) { + if (!to->button->xkb_acts) { to->button->xkb_acts = calloc(1, sizeof(XkbAction)); if (!to->button->xkb_acts) FatalError("[Xi] not enough memory for xkb_acts.\n"); } memcpy(to->button->xkb_acts, from->button->xkb_acts, - sizeof(XkbAction)); - } else + sizeof(XkbAction)); + } + else free(to->button->xkb_acts); - memcpy(to->button->labels, from->button->labels, - from->button->numButtons * sizeof(Atom)); + memcpy(to->button->labels, from->button->labels, + from->button->numButtons * sizeof(Atom)); to->button->sourceid = from->id; - } else if (to->button && !from->button) - { + } + else if (to->button && !from->button) { ClassesPtr classes; + classes = to->unused_classes; classes->button = to->button; - to->button = NULL; + to->button = NULL; } - if (from->proximity) - { - if (!to->proximity) - { + if (from->proximity) { + if (!to->proximity) { classes = to->unused_classes; to->proximity = classes->proximity; - if (!to->proximity) - { + if (!to->proximity) { to->proximity = calloc(1, sizeof(ProximityClassRec)); if (!to->proximity) FatalError("[Xi] no memory for class shift.\n"); - } else + } + else classes->proximity = NULL; } memcpy(to->proximity, from->proximity, sizeof(ProximityClassRec)); to->proximity->sourceid = from->id; - } else if (to->proximity) - { + } + else if (to->proximity) { ClassesPtr classes; + classes = to->unused_classes; classes->proximity = to->proximity; - to->proximity = NULL; + to->proximity = NULL; } - if (from->touch) - { + if (from->touch) { TouchClassPtr t, f; - if (!to->touch) - { + + if (!to->touch) { classes = to->unused_classes; to->touch = classes->touch; - if (!to->touch) - { + if (!to->touch) { int i; + to->touch = calloc(1, sizeof(TouchClassRec)); if (!to->touch) FatalError("[Xi] no memory for class shift.\n"); @@ -689,11 +650,11 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) TouchInitTouchPoint(to->touch, to->valuator, i); if (!to->touch) FatalError("[Xi] no memory for class shift.\n"); - } else + } + else classes->touch = NULL; } - t = to->touch; f = from->touch; t->sourceid = f->sourceid; @@ -719,7 +680,8 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) * Saves a few memory allocations. */ void -DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dce) +DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, + DeviceChangedEvent *dce) { /* generic feedback classes, not tied to pointer and/or keyboard */ DeepCopyFeedbackClasses(from, to); @@ -730,7 +692,6 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dc DeepCopyPointerClasses(from, to); } - /** * Send an XI2 DeviceChangedEvent to all interested clients. */ @@ -740,16 +701,15 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceChangedEvent *dce) xXIDeviceChangedEvent *dcce; int rc; - rc = EventToXI2((InternalEvent*)dce, (xEvent**)&dcce); - if (rc != Success) - { + rc = EventToXI2((InternalEvent *) dce, (xEvent **) &dcce); + if (rc != Success) { ErrorF("[Xi] event conversion from DCE failed with code %d\n", rc); return; } /* we don't actually swap if there's a NullClient, swapping is done * later when event is delivered. */ - SendEventToAllWindows(device, XI_DeviceChangedMask, (xEvent*)dcce, 1); + SendEventToAllWindows(device, XI_DeviceChangedMask, (xEvent *) dcce, 1); free(dcce); } @@ -766,16 +726,16 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce) rc = dixLookupDevice(&slave, dce->sourceid, serverClient, DixReadAccess); if (rc != Success) - return; /* Device has disappeared */ + return; /* Device has disappeared */ if (IsMaster(slave)) return; if (IsFloating(slave)) - return; /* set floating since the event */ + return; /* set floating since the event */ if (GetMaster(slave, MASTER_ATTACHED)->id != dce->masterid) - return; /* not our slave anymore, don't care */ + return; /* not our slave anymore, don't care */ /* FIXME: we probably need to send a DCE for the new slave now */ @@ -846,40 +806,38 @@ DecreaseButtonCount(DeviceIntPtr dev, int key, CARD8 *buttons_down, #define DEFAULT 0 #define DONT_PROCESS 1 int -UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) +UpdateDeviceState(DeviceIntPtr device, DeviceEvent *event) { int i; - int key = 0, - last_valuator; + int key = 0, last_valuator; - KeyClassPtr k = NULL; - ButtonClassPtr b = NULL; - ValuatorClassPtr v = NULL; - TouchClassPtr t = NULL; + KeyClassPtr k = NULL; + ButtonClassPtr b = NULL; + ValuatorClassPtr v = NULL; + TouchClassPtr t = NULL; /* This event is always the first we get, before the actual events with * the data. However, the way how the DDX is set up, "device" will * actually be the slave device that caused the event. */ - switch(event->type) - { - case ET_DeviceChanged: - ChangeMasterDeviceClasses(device, (DeviceChangedEvent*)event); - return DONT_PROCESS; /* event has been sent already */ - case ET_Motion: - case ET_ButtonPress: - case ET_ButtonRelease: - case ET_KeyPress: - case ET_KeyRelease: - case ET_ProximityIn: - case ET_ProximityOut: - case ET_TouchBegin: - case ET_TouchUpdate: - case ET_TouchEnd: - break; - default: - /* other events don't update the device */ - return DEFAULT; + switch (event->type) { + case ET_DeviceChanged: + ChangeMasterDeviceClasses(device, (DeviceChangedEvent *) event); + return DONT_PROCESS; /* event has been sent already */ + case ET_Motion: + case ET_ButtonPress: + case ET_ButtonRelease: + case ET_KeyPress: + case ET_KeyRelease: + case ET_ProximityIn: + case ET_ProximityOut: + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchEnd: + break; + default: + /* other events don't update the device */ + return DEFAULT; } k = device->key; @@ -892,27 +850,23 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) /* Update device axis */ /* Check valuators first */ last_valuator = -1; - for (i = 0; i < MAX_VALUATORS; i++) - { - if (BitIsOn(&event->valuators.mask, i)) - { - if (!v) - { + for (i = 0; i < MAX_VALUATORS; i++) { + if (BitIsOn(&event->valuators.mask, i)) { + if (!v) { ErrorF("[Xi] Valuators reported for non-valuator device '%s'. " - "Ignoring event.\n", device->name); + "Ignoring event.\n", device->name); return DONT_PROCESS; - } else if (v->numAxes < i) - { + } + else if (v->numAxes < i) { ErrorF("[Xi] Too many valuators reported for device '%s'. " - "Ignoring event.\n", device->name); + "Ignoring event.\n", device->name); return DONT_PROCESS; } last_valuator = i; } } - for (i = 0; i <= last_valuator && i < v->numAxes; i++) - { + for (i = 0; i <= last_valuator && i < v->numAxes; i++) { /* XXX: Relative/Absolute mode */ if (BitIsOn(&event->valuators.mask, i)) v->axisVal[i] = event->valuators.data[i]; @@ -922,23 +876,25 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) if (!k) return DONT_PROCESS; - /* don't allow ddx to generate multiple downs, but repeats are okay */ - if (key_is_down(device, key, KEY_PROCESSED) && !event->key_repeat) - return DONT_PROCESS; + /* don't allow ddx to generate multiple downs, but repeats are okay */ + if (key_is_down(device, key, KEY_PROCESSED) && !event->key_repeat) + return DONT_PROCESS; - if (device->valuator) - device->valuator->motionHintWindow = NullWindow; - set_key_down(device, key, KEY_PROCESSED); - } else if (event->type == ET_KeyRelease) { + if (device->valuator) + device->valuator->motionHintWindow = NullWindow; + set_key_down(device, key, KEY_PROCESSED); + } + else if (event->type == ET_KeyRelease) { if (!k) return DONT_PROCESS; - if (!key_is_down(device, key, KEY_PROCESSED)) /* guard against duplicates */ - return DONT_PROCESS; - if (device->valuator) - device->valuator->motionHintWindow = NullWindow; - set_key_up(device, key, KEY_PROCESSED); - } else if (event->type == ET_ButtonPress) { + if (!key_is_down(device, key, KEY_PROCESSED)) /* guard against duplicates */ + return DONT_PROCESS; + if (device->valuator) + device->valuator->motionHintWindow = NullWindow; + set_key_up(device, key, KEY_PROCESSED); + } + else if (event->type == ET_ButtonPress) { if (!b) return DONT_PROCESS; @@ -950,9 +906,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) if (!b->map[key]) return DONT_PROCESS; - IncreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state); + IncreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, + &b->state); UpdateDeviceMotionMask(device, b->state, b->motionMask); - } else if (event->type == ET_ButtonRelease) { + } + else if (event->type == ET_ButtonRelease) { if (!b) return DONT_PROCESS; @@ -981,12 +939,14 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) if (!b->map[key]) return DONT_PROCESS; - DecreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state); - UpdateDeviceMotionMask(device, b->state, b->motionMask); - } else if (event->type == ET_ProximityIn) - device->proximity->in_proximity = TRUE; + DecreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, + &b->state); + UpdateDeviceMotionMask(device, b->state, b->motionMask); + } + else if (event->type == ET_ProximityIn) + device->proximity->in_proximity = TRUE; else if (event->type == ET_ProximityOut) - device->proximity->in_proximity = FALSE; + device->proximity->in_proximity = FALSE; else if (event->type == ET_TouchBegin) { BUG_WARN(!b || !v); BUG_WARN(!t); @@ -998,9 +958,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) (event->flags & TOUCH_REPLAYING)) return DONT_PROCESS; - IncreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask, &t->state); + IncreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask, + &t->state); UpdateDeviceMotionMask(device, t->state, DeviceButtonMotionMask); - } else if (event->type == ET_TouchEnd) { + } + else if (event->type == ET_TouchEnd) { BUG_WARN(!b || !v); BUG_WARN(!t); @@ -1012,7 +974,8 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) if (!(event->flags & TOUCH_END)) return DONT_PROCESS; - DecreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask, &t->state); + DecreaseButtonCount(device, key, &t->buttonsDown, &t->motionMask, + &t->state); UpdateDeviceMotionMask(device, t->state, DeviceButtonMotionMask); } @@ -1027,12 +990,12 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event) * window for this device, FALSE otherwise */ static inline Bool -TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev, WindowPtr win) +TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev, + WindowPtr win) { InputClients *iclient; - nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next) - { + nt_list_for_each_entry(iclient, wOtherInputMasks(win)->inputClients, next) { if (rClient(iclient) != client) continue; @@ -1043,7 +1006,8 @@ TouchClientWantsOwnershipEvents(ClientPtr client, DeviceIntPtr dev, WindowPtr wi } static void -TouchSendOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, int reason, XID resource) +TouchSendOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, int reason, + XID resource) { int nev, i; InternalEvent *tel = InitEventList(GetMaximumEventsNum()); @@ -1072,8 +1036,8 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti, /* If the client does not have the ownership mask set and is not * the current owner of the touch, only pretend we delivered */ if (!grab && ti->num_grabs != 0 && - !TouchClientWantsOwnershipEvents(client, dev,win)) - return TRUE; + !TouchClientWantsOwnershipEvents(client, dev, win)) + return TRUE; /* If we fail here, we're going to leave a client hanging. */ err = EventToXI2(ev, &xi2); @@ -1102,8 +1066,7 @@ ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti) rc = dixLookupClient(&client, ti->listeners[0].listener, serverClient, DixSendAccess); - if (rc != Success) - { + if (rc != Success) { ErrorF("[Xi] Failed to lookup early accepting client.\n"); return; } @@ -1158,15 +1121,14 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti, /* Deliver the ownership */ if (ti->listeners[0].state == LISTENER_AWAITING_OWNER || ti->listeners[0].state == LISTENER_EARLY_ACCEPT) - DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ti->listeners[0].listener); + DeliverTouchEvents(dev, ti, (InternalEvent *) ev, + ti->listeners[0].listener); else if (ti->listeners[0].state == LISTENER_AWAITING_BEGIN) TouchEventHistoryReplay(ti, dev, ti->listeners[0].listener); /* If we've just removed the last grab and the touch has physically * ended, send a TouchEnd event too and finalise the touch. */ - if (ti->num_listeners == 1 && ti->num_grabs == 0 && - ti->pending_finish) - { + if (ti->num_listeners == 1 && ti->num_grabs == 0 && ti->pending_finish) { EmitTouchEnd(dev, ti, 0, 0); TouchEndTouch(dev, ti); return; @@ -1195,10 +1157,8 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource, /* Send a TouchEnd event to the resource being removed, but only if they * haven't received one yet already */ - for (i = 0; i < ti->num_listeners; i++) - { - if (ti->listeners[i].listener == resource) - { + for (i = 0; i < ti->num_listeners; i++) { + if (ti->listeners[i].listener == resource) { if (ti->listeners[i].state != LISTENER_HAS_END) EmitTouchEnd(sourcedev, ti, TOUCH_REJECT, resource); break; @@ -1207,16 +1167,14 @@ TouchRejected(DeviceIntPtr sourcedev, TouchPointInfoPtr ti, XID resource, /* If there are no other listeners left, and the touchpoint is pending * finish, then we can just kill it now. */ - if (ti->num_listeners == 1 && ti->pending_finish) - { + if (ti->num_listeners == 1 && ti->pending_finish) { TouchEndTouch(sourcedev, ti); return; } /* Remove the resource from the listener list, updating * ti->num_listeners, as well as ti->num_grabs if it was a grab. */ - if (TouchRemoveListener(ti, resource)) - { + if (TouchRemoveListener(ti, resource)) { if (dixLookupResourceByType(&grab, resource, RT_PASSIVEGRAB, serverClient, DixGetAttrAccess) == Success) ti->num_grabs--; @@ -1252,8 +1210,11 @@ ProcessTouchOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, /* Owner accepted after receiving end */ if (ti->listeners[0].state == LISTENER_HAS_END) TouchEndTouch(dev, ti); - } else { /* this is the very first ownership event for a grab */ - DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ev->resource); + else + ti->listeners[0].state = LISTENER_HAS_ACCEPTED; + } + else { /* this is the very first ownership event for a grab */ + DeliverTouchEvents(dev, ti, (InternalEvent *) ev, ev->resource); } } @@ -1265,6 +1226,7 @@ static void TouchCopyValuatorData(DeviceEvent *ev, TouchPointInfoPtr ti) { int i; + for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++) if (BitIsOn(ev->valuators.mask, i)) valuator_mask_set_double(ti->valuators, i, ev->valuators.data[i]); @@ -1287,24 +1249,23 @@ TouchCopyValuatorData(DeviceEvent *ev, TouchPointInfoPtr ti) */ static Bool RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti, - InternalEvent *ev, TouchListener *listener, + InternalEvent *ev, TouchListener * listener, ClientPtr *client, WindowPtr *win, GrabPtr *grab, XI2Mask **mask) { - int rc; - InputClients *iclients = NULL; + int rc; + InputClients *iclients = NULL; if (listener->type == LISTENER_GRAB || - listener->type == LISTENER_POINTER_GRAB) - { - rc = dixLookupResourceByType((pointer*)grab, listener->listener, - RT_PASSIVEGRAB, - serverClient, DixSendAccess); - if (rc != Success) - { + listener->type == LISTENER_POINTER_GRAB) { + rc = dixLookupResourceByType((pointer *) grab, listener->listener, + RT_PASSIVEGRAB, + serverClient, DixSendAccess); + if (rc != Success) { /* the grab doesn't exist but we have a grabbing listener - this * is an implicit/active grab */ - rc = dixLookupClient(client, listener->listener, serverClient, DixSendAccess); + rc = dixLookupClient(client, listener->listener, serverClient, + DixSendAccess); if (rc != Success) return FALSE; @@ -1316,51 +1277,56 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti, *client = rClient(*grab); *win = (*grab)->window; *mask = (*grab)->xi2mask; - } else { + } + else { if (listener->level == CORE) rc = dixLookupWindow(win, listener->listener, serverClient, DixSendAccess); else - rc = dixLookupResourceByType((pointer*)win, listener->listener, + rc = dixLookupResourceByType((pointer *) win, listener->listener, RT_INPUTCLIENT, serverClient, DixSendAccess); if (rc != Success) return FALSE; - - if (listener->level == XI2) - { + if (listener->level == XI2) { int evtype; - if (ti->emulate_pointer && listener->type == LISTENER_POINTER_REGULAR) + + if (ti->emulate_pointer && + listener->type == LISTENER_POINTER_REGULAR) evtype = GetXI2Type(TouchGetPointerEventType(ev)); else evtype = GetXI2Type(ev->any.type); - nt_list_for_each_entry(iclients, wOtherInputMasks(*win)->inputClients, next) + nt_list_for_each_entry(iclients, + wOtherInputMasks(*win)->inputClients, next) if (xi2mask_isset(iclients->xi2mask, dev, evtype)) - break; + break; BUG_WARN(!iclients); if (!iclients) return FALSE; - } else if (listener->level == XI) - { + } + else if (listener->level == XI) { int xi_type = GetXIType(TouchGetPointerEventType(ev)); Mask xi_filter = event_get_filter_from_type(dev, xi_type); - nt_list_for_each_entry(iclients, wOtherInputMasks(*win)->inputClients, next) + + nt_list_for_each_entry(iclients, + wOtherInputMasks(*win)->inputClients, next) if (iclients->mask[dev->id] & xi_filter) - break; + break; BUG_WARN(!iclients); if (!iclients) return FALSE; - } else - { + } + else { int coretype = GetCoreType(TouchGetPointerEventType(ev)); Mask core_filter = event_get_filter_from_type(dev, coretype); /* all others */ - nt_list_for_each_entry(iclients, (InputClients*)wOtherClients(*win), next) + nt_list_for_each_entry(iclients, + (InputClients *) wOtherClients(*win), next) if (iclients->mask[XIAllDevices] & core_filter) - break; + break; /* if owner selected, iclients is NULL */ } @@ -1373,9 +1339,10 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti, } static int -DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev, - TouchListener *listener, ClientPtr client, - WindowPtr win, GrabPtr grab, XI2Mask *xi2mask) +DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, + InternalEvent *ev, TouchListener * listener, + ClientPtr client, WindowPtr win, GrabPtr grab, + XI2Mask *xi2mask) { InternalEvent motion, button; InternalEvent *ptrev = &motion; @@ -1398,22 +1365,22 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent event_set_state(dev, kbd, &ptrev->device_event); ptrev->device_event.corestate = event_get_corestate(dev, kbd); - if (grab) - { + if (grab) { /* this side-steps the usual activation mechansims, but... */ if (ev->any.type == ET_TouchBegin && !dev->deviceGrab.grab) - ActivatePassiveGrab(dev, grab, ptrev, ev); /* also delivers the event */ + ActivatePassiveGrab(dev, grab, ptrev, ev); /* also delivers the event */ else { int deliveries = 0; + /* 'grab' is the passive grab, but if the grab isn't active, * don't deliver */ if (!dev->deviceGrab.grab) return Success; - if (grab->ownerEvents) - { + if (grab->ownerEvents) { WindowPtr focus = NullWindow; WindowPtr win = dev->spriteInfo->sprite->win; + deliveries = DeliverDeviceEvents(win, ptrev, grab, focus, dev); } @@ -1422,12 +1389,11 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent if (ev->any.type == ET_TouchEnd && !dev->button->buttonsDown && - dev->deviceGrab.fromPassiveGrab && - GrabIsPointerGrab(grab)) - (*dev->deviceGrab.DeactivateGrab)(dev); + dev->deviceGrab.fromPassiveGrab && GrabIsPointerGrab(grab)) + (*dev->deviceGrab.DeactivateGrab) (dev); } - } else - { + } + else { GrabPtr devgrab = dev->deviceGrab.grab; DeliverDeviceEvents(win, ptrev, grab, win, dev); @@ -1435,8 +1401,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent * Implicit passive grab activated in response to this event. Store * the event. */ - if (!devgrab && dev->deviceGrab.grab && dev->deviceGrab.implicitGrab) - { + if (!devgrab && dev->deviceGrab.grab && dev->deviceGrab.implicitGrab) { TouchListener *listener; devgrab = dev->deviceGrab.grab; @@ -1450,8 +1415,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent listener = &ti->listeners[ti->num_listeners - 1]; listener->listener = devgrab->resource; - if (devgrab->grabtype != XI2 || - devgrab->type != XI_TouchBegin) + if (devgrab->grabtype != XI2 || devgrab->type != XI_TouchBegin) listener->type = LISTENER_POINTER_GRAB; else listener->type = LISTENER_GRAB; @@ -1466,17 +1430,13 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent return Success; } - - - static void DeliverEmulatedMotionEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev) { InternalEvent motion; - if (ti->num_listeners) - { + if (ti->num_listeners) { ClientPtr client; WindowPtr win; GrabPtr grab; @@ -1496,21 +1456,22 @@ DeliverEmulatedMotionEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, return; /* There may be a pointer grab on the device */ - if (!grab) - { + if (!grab) { grab = dev->deviceGrab.grab; - if (grab) - { + if (grab) { win = grab->window; mask = grab->xi2mask; client = rClient(grab); } } - DeliverTouchEmulatedEvent(dev, ti, &motion, &ti->listeners[0], client, win, grab, mask); - } else { + DeliverTouchEmulatedEvent(dev, ti, &motion, &ti->listeners[0], client, + win, grab, mask); + } + else { InternalEvent button; int converted; + converted = TouchConvertToPointerEvent(ev, &motion, &button); BUG_WARN(converted == 0); @@ -1534,7 +1495,7 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev) TouchPointInfoPtr ti; uint32_t touchid; int type = ev->any.type; - int emulate_pointer = !!(ev->device_event.flags & TOUCH_POINTER_EMULATED); + int emulate_pointer = ! !(ev->device_event.flags & TOUCH_POINTER_EMULATED); if (!t) return; @@ -1547,17 +1508,16 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev) if (type == ET_TouchBegin) { ti = TouchBeginTouch(dev, ev->device_event.sourceid, touchid, emulate_pointer); - } else + } + else ti = TouchFindByClientID(dev, touchid); - if (!ti) - { + if (!ti) { DebugF("[Xi] %s: Failed to get event %d for touchpoint %d\n", dev->name, type, touchid); return; } - /* if emulate_pointer is set, emulate the motion event right * here, so we can ignore it for button event emulation. TouchUpdate * events which _only_ emulate motion just work normally */ @@ -1576,8 +1536,7 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev) * have more complex semantics. */ if (ev->any.type == ET_TouchOwnership) ProcessTouchOwnershipEvent(dev, ti, &ev->touch_ownership_event); - else - { + else { TouchCopyValuatorData(&ev->device_event, ti); /* WARNING: the event type may change to TouchUpdate in * DeliverTouchEvents if a TouchEnd was delivered to a grabbing @@ -1588,7 +1547,6 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev) } } - /** * Process DeviceEvents and DeviceChangedEvents. */ @@ -1604,14 +1562,13 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device) DeviceIntPtr mouse = NULL, kbd = NULL; DeviceEvent *event = &ev->device_event; - if (IsPointerDevice(device)) - { + if (IsPointerDevice(device)) { kbd = GetMaster(device, KEYBOARD_OR_FLOAT); mouse = device; - if (!kbd->key) /* can happen with floating SDs */ + if (!kbd->key) /* can happen with floating SDs */ kbd = NULL; - } else - { + } + else { mouse = GetMaster(device, POINTER_OR_FLOAT); kbd = device; if (!mouse->valuator || !mouse->button) /* may be float. SDs */ @@ -1630,88 +1587,85 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device) if (IsMaster(device) || IsFloating(device)) CheckMotion(event, device); - switch (event->type) - { - case ET_Motion: - case ET_ButtonPress: - case ET_ButtonRelease: - case ET_KeyPress: - case ET_KeyRelease: - case ET_ProximityIn: - case ET_ProximityOut: - GetSpritePosition(device, &rootX, &rootY); - event->root_x = rootX; - event->root_y = rootY; - NoticeEventTime((InternalEvent*)event); - event->corestate = corestate; - key = event->detail.key; - break; - default: - break; + switch (event->type) { + case ET_Motion: + case ET_ButtonPress: + case ET_ButtonRelease: + case ET_KeyPress: + case ET_KeyRelease: + case ET_ProximityIn: + case ET_ProximityOut: + GetSpritePosition(device, &rootX, &rootY); + event->root_x = rootX; + event->root_y = rootY; + NoticeEventTime((InternalEvent *) event, device); + event->corestate = corestate; + key = event->detail.key; + break; + default: + break; } if (DeviceEventCallback && !syncEvents.playingEvents) { - DeviceEventInfoRec eventinfo; - SpritePtr pSprite = device->spriteInfo->sprite; + DeviceEventInfoRec eventinfo; + SpritePtr pSprite = device->spriteInfo->sprite; - /* see comment in EnqueueEvents regarding the next three lines */ - if (ev->any.type == ET_Motion) - ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id; + /* see comment in EnqueueEvents regarding the next three lines */ + if (ev->any.type == ET_Motion) + ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id; - eventinfo.device = device; - eventinfo.event = ev; - CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo); + eventinfo.device = device; + eventinfo.event = ev; + CallCallbacks(&DeviceEventCallback, (pointer) &eventinfo); } grab = device->deviceGrab.grab; - switch(event->type) - { - case ET_KeyPress: - if (!grab && CheckDeviceGrabs(device, event, 0)) - return; - break; - case ET_KeyRelease: - if (grab && device->deviceGrab.fromPassiveGrab && - (key == device->deviceGrab.activatingKey) && - GrabIsKeyboardGrab(device->deviceGrab.grab)) - deactivateDeviceGrab = TRUE; - break; - case ET_ButtonPress: - if (b->map[key] == 0) /* there's no button 0 */ - return; - event->detail.button = b->map[key]; - if (!grab && CheckDeviceGrabs(device, event, 0)) - { - /* if a passive grab was activated, the event has been sent - * already */ - return; - } - break; - case ET_ButtonRelease: - if (b->map[key] == 0) /* there's no button 0 */ - return; - event->detail.button = b->map[key]; - if (grab && !b->buttonsDown && - device->deviceGrab.fromPassiveGrab && - GrabIsPointerGrab(device->deviceGrab.grab)) - deactivateDeviceGrab = TRUE; - default: - break; + switch (event->type) { + case ET_KeyPress: + if (!grab && CheckDeviceGrabs(device, event, 0)) + return; + break; + case ET_KeyRelease: + if (grab && device->deviceGrab.fromPassiveGrab && + (key == device->deviceGrab.activatingKey) && + GrabIsKeyboardGrab(device->deviceGrab.grab)) + deactivateDeviceGrab = TRUE; + break; + case ET_ButtonPress: + if (b->map[key] == 0) /* there's no button 0 */ + return; + event->detail.button = b->map[key]; + if (!grab && CheckDeviceGrabs(device, event, 0)) { + /* if a passive grab was activated, the event has been sent + * already */ + return; + } + break; + case ET_ButtonRelease: + if (b->map[key] == 0) /* there's no button 0 */ + return; + event->detail.button = b->map[key]; + if (grab && !b->buttonsDown && + device->deviceGrab.fromPassiveGrab && + GrabIsPointerGrab(device->deviceGrab.grab)) + deactivateDeviceGrab = TRUE; + default: + break; } - if (grab) - DeliverGrabbedEvent((InternalEvent*)event, device, deactivateDeviceGrab); + DeliverGrabbedEvent((InternalEvent *) event, device, + deactivateDeviceGrab); else if (device->focus && !IsPointerEvent(ev)) - DeliverFocusedEvent(device, (InternalEvent*)event, + DeliverFocusedEvent(device, (InternalEvent *) event, GetSpriteWindow(device)); else - DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent*)event, + DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent *) event, NullGrab, NullWindow, device); if (deactivateDeviceGrab == TRUE) - (*device->deviceGrab.DeactivateGrab) (device); + (*device->deviceGrab.DeactivateGrab) (device); event->detail.key = key; } @@ -1725,118 +1679,117 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) { verify_internal_event(ev); - switch(ev->any.type) - { - case ET_RawKeyPress: - case ET_RawKeyRelease: - case ET_RawButtonPress: - case ET_RawButtonRelease: - case ET_RawMotion: - case ET_RawTouchBegin: - case ET_RawTouchUpdate: - case ET_RawTouchEnd: - DeliverRawEvent(&ev->raw_event, device); - break; - case ET_TouchBegin: - case ET_TouchUpdate: - case ET_TouchOwnership: - case ET_TouchEnd: - ProcessTouchEvent(ev, device); - break; - default: - ProcessDeviceEvent(ev, device); - break; + switch (ev->any.type) { + case ET_RawKeyPress: + case ET_RawKeyRelease: + case ET_RawButtonPress: + case ET_RawButtonRelease: + case ET_RawMotion: + case ET_RawTouchBegin: + case ET_RawTouchUpdate: + case ET_RawTouchEnd: + DeliverRawEvent(&ev->raw_event, device); + break; + case ET_TouchBegin: + case ET_TouchUpdate: + case ET_TouchOwnership: + case ET_TouchEnd: + ProcessTouchEvent(ev, device); + break; + default: + ProcessDeviceEvent(ev, device); + break; } } static int -DeliverTouchBeginEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev, - TouchListener *listener, ClientPtr client, - WindowPtr win, GrabPtr grab, XI2Mask *xi2mask) +DeliverTouchBeginEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, + InternalEvent *ev, TouchListener * listener, + ClientPtr client, WindowPtr win, GrabPtr grab, + XI2Mask *xi2mask) { enum TouchListenerState state; int rc = Success; Bool has_ownershipmask; if (listener->type == LISTENER_POINTER_REGULAR || - listener->type == LISTENER_POINTER_GRAB) - { + listener->type == LISTENER_POINTER_GRAB) { rc = DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win, grab, xi2mask); goto out; } - has_ownershipmask = xi2mask_isset(xi2mask, dev, XI_TouchOwnership); if (TouchResourceIsOwner(ti, listener->listener) || has_ownershipmask) rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); - if (!TouchResourceIsOwner(ti, listener->listener)) - { + if (!TouchResourceIsOwner(ti, listener->listener)) { if (has_ownershipmask) state = LISTENER_AWAITING_OWNER; else state = LISTENER_AWAITING_BEGIN; - } else - { + } + else { if (has_ownershipmask) TouchSendOwnershipEvent(dev, ti, 0, listener->listener); - state = LISTENER_IS_OWNER; + + if (!has_ownershipmask || listener->type == LISTENER_REGULAR) + state = LISTENER_HAS_ACCEPTED; + else + state = LISTENER_IS_OWNER; } listener->state = state; -out: + out: return rc; } static int DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev, - TouchListener *listener, ClientPtr client, + TouchListener * listener, ClientPtr client, WindowPtr win, GrabPtr grab, XI2Mask *xi2mask) { int rc = Success; if (listener->type == LISTENER_POINTER_REGULAR || - listener->type == LISTENER_POINTER_GRAB) - { + listener->type == LISTENER_POINTER_GRAB) { rc = DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win, grab, xi2mask); goto out; } /* Event in response to reject */ - if (ev->device_event.flags & TOUCH_REJECT) - { + if (ev->device_event.flags & TOUCH_REJECT) { if (listener->state != LISTENER_HAS_END) rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); listener->state = LISTENER_HAS_END; - } else if (TouchResourceIsOwner(ti, listener->listener)) - { + } + else if (TouchResourceIsOwner(ti, listener->listener)) { + Bool normal_end = !(ev->device_event.flags & TOUCH_ACCEPT); + /* FIXME: what about early acceptance */ - if (!(ev->device_event.flags & TOUCH_ACCEPT)) - { - if (listener->state != LISTENER_HAS_END) - rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); - listener->state = LISTENER_HAS_END; - } + if (normal_end && listener->state != LISTENER_HAS_END) + rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); + if ((ti->num_listeners > 1 || - (listener->type == LISTENER_GRAB && - xi2mask_isset(xi2mask, dev, XI_TouchOwnership))) && - (ev->device_event.flags & (TOUCH_ACCEPT|TOUCH_REJECT)) == 0) - { + listener->state != LISTENER_HAS_ACCEPTED) && + (ev->device_event.flags & (TOUCH_ACCEPT | TOUCH_REJECT)) == 0) { ev->any.type = ET_TouchUpdate; ev->device_event.flags |= TOUCH_PENDING_END; ti->pending_finish = TRUE; } + + if (normal_end) + listener->state = LISTENER_HAS_END; } -out: + out: return rc; } static int DeliverTouchEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev, - TouchListener *listener, ClientPtr client, + TouchListener * listener, ClientPtr client, WindowPtr win, GrabPtr grab, XI2Mask *xi2mask) { Bool has_ownershipmask = FALSE; @@ -1845,30 +1798,34 @@ DeliverTouchEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev, if (xi2mask) has_ownershipmask = xi2mask_isset(xi2mask, dev, XI_TouchOwnership); - if (ev->any.type == ET_TouchOwnership) - { + if (ev->any.type == ET_TouchOwnership) { ev->touch_ownership_event.deviceid = dev->id; if (!TouchResourceIsOwner(ti, listener->listener)) goto out; rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); listener->state = LISTENER_IS_OWNER; - } else + } + else ev->device_event.deviceid = dev->id; - if (ev->any.type == ET_TouchBegin) - { - rc = DeliverTouchBeginEvent(dev, ti, ev, listener, client, win, grab, xi2mask); - } else if (ev->any.type == ET_TouchUpdate) - { + if (ev->any.type == ET_TouchBegin) { + rc = DeliverTouchBeginEvent(dev, ti, ev, listener, client, win, grab, + xi2mask); + } + else if (ev->any.type == ET_TouchUpdate) { if (listener->type == LISTENER_POINTER_REGULAR || listener->type == LISTENER_POINTER_GRAB) - DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win, grab, xi2mask); - else if (TouchResourceIsOwner(ti, listener->listener) || has_ownershipmask) + DeliverTouchEmulatedEvent(dev, ti, ev, listener, client, win, grab, + xi2mask); + else if (TouchResourceIsOwner(ti, listener->listener) || + has_ownershipmask) rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev); - } else if (ev->any.type == ET_TouchEnd) - rc = DeliverTouchEndEvent(dev, ti, ev, listener, client, win, grab, xi2mask); + } + else if (ev->any.type == ET_TouchEnd) + rc = DeliverTouchEndEvent(dev, ti, ev, listener, client, win, grab, + xi2mask); -out: + out: return rc; } @@ -1888,13 +1845,12 @@ DeliverTouchEvents(DeviceIntPtr dev, TouchPointInfoPtr ti, int i; if (ev->any.type == ET_TouchBegin && - !(ev->device_event.flags & (TOUCH_CLIENT_ID|TOUCH_REPLAYING))) + !(ev->device_event.flags & (TOUCH_CLIENT_ID | TOUCH_REPLAYING))) TouchSetupListeners(dev, ti, ev); TouchEventHistoryPush(ti, &ev->device_event); - for (i = 0; i < ti->num_listeners; i++) - { + for (i = 0; i < ti->num_listeners; i++) { GrabPtr grab = NULL; ClientPtr client; WindowPtr win; @@ -1922,7 +1878,7 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev) proxc = (ProximityClassPtr) malloc(sizeof(ProximityClassRec)); if (!proxc) - return FALSE; + return FALSE; proxc->sourceid = dev->id; proxc->in_proximity = TRUE; dev->proximity = proxc; @@ -1939,8 +1895,9 @@ InitProximityClassDeviceStruct(DeviceIntPtr dev) * @see InitValuatorClassDeviceStruct */ Bool -InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int maxval, - int resolution, int min_res, int max_res, int mode) +InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, + int maxval, int resolution, int min_res, int max_res, + int mode) { AxisInfoPtr ax; @@ -1969,7 +1926,8 @@ InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, Atom label, int minval, int * Set the given axis number as a scrolling valuator. */ Bool -SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double increment, int flags) +SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, + double increment, int flags) { AxisInfoPtr ax; int *current_ax; @@ -1979,30 +1937,29 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr if (!dev || !dev->valuator || axnum >= dev->valuator->numAxes) return FALSE; - switch (type) - { - case SCROLL_TYPE_VERTICAL: - current_ax = &dev->valuator->v_scroll_axis; - break; - case SCROLL_TYPE_HORIZONTAL: - current_ax = &dev->valuator->h_scroll_axis; - break; - case SCROLL_TYPE_NONE: - ax = &dev->valuator->axes[axnum]; - ax->scroll.type = type; - return TRUE; - default: - return FALSE; + switch (type) { + case SCROLL_TYPE_VERTICAL: + current_ax = &dev->valuator->v_scroll_axis; + break; + case SCROLL_TYPE_HORIZONTAL: + current_ax = &dev->valuator->h_scroll_axis; + break; + case SCROLL_TYPE_NONE: + ax = &dev->valuator->axes[axnum]; + ax->scroll.type = type; + return TRUE; + default: + return FALSE; } if (increment == 0.0) return FALSE; - if (*current_ax != -1 && axnum != *current_ax) - { + if (*current_ax != -1 && axnum != *current_ax) { ax = &dev->valuator->axes[*current_ax]; if (ax->scroll.type == type && - (flags & SCROLL_FLAG_PREFERRED) && (ax->scroll.flags & SCROLL_FLAG_PREFERRED)) + (flags & SCROLL_FLAG_PREFERRED) && + (ax->scroll.flags & SCROLL_FLAG_PREFERRED)) return FALSE; } *current_ax = axnum; @@ -2013,7 +1970,9 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr ax->scroll.flags = flags; master = GetMaster(dev, MASTER_ATTACHED); - CreateClassesChangedEvent(&dce, master, dev, DEVCHANGE_POINTER_EVENT | DEVCHANGE_DEVICE_CHANGE); + CreateClassesChangedEvent(&dce, master, dev, + DEVCHANGE_POINTER_EVENT | + DEVCHANGE_DEVICE_CHANGE); XISendDeviceChangedEvent(dev, &dce.changed_event); /* if the current slave is us, update the master. If not, we'll update @@ -2027,7 +1986,7 @@ SetScrollValuator(DeviceIntPtr dev, int axnum, enum ScrollType type, double incr static void FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k, - ButtonClassPtr b, ValuatorClassPtr v, int first) + ButtonClassPtr b, ValuatorClassPtr v, int first) { ev->type = DeviceStateNotify; ev->deviceid = dev->id; @@ -2038,36 +1997,37 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k, ev->num_valuators = 0; if (b) { - ev->classes_reported |= (1 << ButtonClass); - ev->num_buttons = b->numButtons; - memcpy((char*)ev->buttons, (char*)b->down, 4); - } else if (k) { - ev->classes_reported |= (1 << KeyClass); - ev->num_keys = k->xkbInfo->desc->max_key_code - - k->xkbInfo->desc->min_key_code; - memmove((char *)&ev->keys[0], (char *)k->down, 4); + ev->classes_reported |= (1 << ButtonClass); + ev->num_buttons = b->numButtons; + memcpy((char *) ev->buttons, (char *) b->down, 4); + } + else if (k) { + ev->classes_reported |= (1 << KeyClass); + ev->num_keys = k->xkbInfo->desc->max_key_code - + k->xkbInfo->desc->min_key_code; + memmove((char *) &ev->keys[0], (char *) k->down, 4); } if (v) { - int nval = v->numAxes - first; - - ev->classes_reported |= (1 << ValuatorClass); - ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift; - ev->num_valuators = nval < 3 ? nval : 3; - switch (ev->num_valuators) { - case 3: - ev->valuator2 = v->axisVal[first + 2]; - case 2: - ev->valuator1 = v->axisVal[first + 1]; - case 1: - ev->valuator0 = v->axisVal[first]; - break; - } + int nval = v->numAxes - first; + + ev->classes_reported |= (1 << ValuatorClass); + ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift; + ev->num_valuators = nval < 3 ? nval : 3; + switch (ev->num_valuators) { + case 3: + ev->valuator2 = v->axisVal[first + 2]; + case 2: + ev->valuator1 = v->axisVal[first + 1]; + case 1: + ev->valuator0 = v->axisVal[first]; + break; + } } } static void FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v, - int first) + int first) { int nval = v->numAxes - first; @@ -2077,12 +2037,12 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v, ev->first_valuator = first; switch (ev->num_valuators) { case 3: - ev->valuator2 = v->axisVal[first + 2]; + ev->valuator2 = v->axisVal[first + 2]; case 2: - ev->valuator1 = v->axisVal[first + 1]; + ev->valuator1 = v->axisVal[first + 1]; case 1: - ev->valuator0 = v->axisVal[first]; - break; + ev->valuator0 = v->axisVal[first]; + break; } first += ev->num_valuators; } @@ -2110,8 +2070,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win) evcount++; } if ((k = dev->key) != NULL) { - nkeys = k->xkbInfo->desc->max_key_code - - k->xkbInfo->desc->min_key_code; + nkeys = k->xkbInfo->desc->max_key_code - k->xkbInfo->desc->min_key_code; if (nkeys > 32) evcount++; if (nbuttons > 0) { @@ -2143,7 +2102,8 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win) bev = (deviceButtonStateNotify *) ev++; bev->type = DeviceButtonStateNotify; bev->deviceid = dev->id; - memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4); + memcpy((char *) &bev->buttons[4], (char *) &b->down[4], + DOWN_LENGTH - 4); } if (nval > 0) { (ev - 1)->deviceid |= MORE_EVENTS; @@ -2162,7 +2122,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win) kev = (deviceKeyStateNotify *) ev++; kev->type = DeviceKeyStateNotify; kev->deviceid = dev->id; - memmove((char *)&kev->keys[0], (char *)&k->down[4], 28); + memmove((char *) &kev->keys[0], (char *) &k->down[4], 28); } if (nval > 0) { (ev - 1)->deviceid |= MORE_EVENTS; @@ -2191,7 +2151,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win) void DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, - WindowPtr pWin) + WindowPtr pWin) { deviceFocus event; xXIFocusInEvent *xi2event; @@ -2206,25 +2166,24 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, len = sizeof(xXIFocusInEvent) + btlen * 4; xi2event = calloc(1, len); - xi2event->type = GenericEvent; - xi2event->extension = IReqCode; - xi2event->evtype = type; - xi2event->length = bytes_to_int32(len - sizeof(xEvent)); - xi2event->buttons_len = btlen; - xi2event->detail = detail; - xi2event->time = currentTime.milliseconds; - xi2event->deviceid = dev->id; - xi2event->sourceid = dev->id; /* a device doesn't change focus by itself */ - xi2event->mode = mode; - xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0); - xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0); + xi2event->type = GenericEvent; + xi2event->extension = IReqCode; + xi2event->evtype = type; + xi2event->length = bytes_to_int32(len - sizeof(xEvent)); + xi2event->buttons_len = btlen; + xi2event->detail = detail; + xi2event->time = currentTime.milliseconds; + xi2event->deviceid = dev->id; + xi2event->sourceid = dev->id; /* a device doesn't change focus by itself */ + xi2event->mode = mode; + xi2event->root_x = FP1616(mouse->spriteInfo->sprite->hot.x, 0); + xi2event->root_y = FP1616(mouse->spriteInfo->sprite->hot.y, 0); for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++) if (BitIsOn(mouse->button->down, i)) SetBit(&xi2event[1], mouse->button->map[i]); - if (dev->key) - { + if (dev->key) { xi2event->mods.base_mods = dev->key->xkbInfo->state.base_mods; xi2event->mods.latched_mods = dev->key->xkbInfo->state.latched_mods; xi2event->mods.locked_mods = dev->key->xkbInfo->state.locked_mods; @@ -2236,11 +2195,11 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, xi2event->group.effective_group = dev->key->xkbInfo->state.group; } - FixUpEventFromWindow(dev->spriteInfo->sprite, (xEvent*)xi2event, pWin, + FixUpEventFromWindow(dev->spriteInfo->sprite, (xEvent *) xi2event, pWin, None, FALSE); - DeliverEventsToWindow(dev, pWin, (xEvent*)xi2event, 1, - GetEventFilter(dev, (xEvent*)xi2event), NullGrab); + DeliverEventsToWindow(dev, pWin, (xEvent *) xi2event, 1, + GetEventFilter(dev, (xEvent *) xi2event), NullGrab); free(xi2event); @@ -2252,46 +2211,44 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, event.window = pWin->drawable.id; event.time = currentTime.milliseconds; - DeliverEventsToWindow(dev, pWin, (xEvent *) & event, 1, - DeviceFocusChangeMask, NullGrab); + DeliverEventsToWindow(dev, pWin, (xEvent *) &event, 1, + DeviceFocusChangeMask, NullGrab); if (event.type == DeviceFocusIn) DeliverStateNotifyEvent(dev, pWin); } int -CheckGrabValues(ClientPtr client, GrabParameters* param) +CheckGrabValues(ClientPtr client, GrabParameters *param) { if (param->grabtype != CORE && - param->grabtype != XI && - param->grabtype != XI2) - { + param->grabtype != XI && param->grabtype != XI2) { ErrorF("[Xi] grabtype is invalid. This is a bug.\n"); return BadImplementation; } if ((param->this_device_mode != GrabModeSync) && - (param->this_device_mode != GrabModeAsync) && + (param->this_device_mode != GrabModeAsync) && (param->this_device_mode != XIGrabModeTouch)) { - client->errorValue = param->this_device_mode; - return BadValue; + client->errorValue = param->this_device_mode; + return BadValue; } if ((param->other_devices_mode != GrabModeSync) && - (param->other_devices_mode != GrabModeAsync) && + (param->other_devices_mode != GrabModeAsync) && (param->other_devices_mode != XIGrabModeTouch)) { - client->errorValue = param->other_devices_mode; - return BadValue; + client->errorValue = param->other_devices_mode; + return BadValue; } if (param->grabtype != XI2 && (param->modifiers != AnyModifier) && (param->modifiers & ~AllModifiersMask)) { - client->errorValue = param->modifiers; - return BadValue; + client->errorValue = param->modifiers; + return BadValue; } if ((param->ownerEvents != xFalse) && (param->ownerEvents != xTrue)) { - client->errorValue = param->ownerEvents; - return BadValue; + client->errorValue = param->ownerEvents; + return BadValue; } return Success; } @@ -2299,7 +2256,7 @@ CheckGrabValues(ClientPtr client, GrabParameters* param) int GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, int button, GrabParameters *param, enum InputLevel grabtype, - GrabMask *mask) + GrabMask *mask) { WindowPtr pWin, confineTo; CursorPtr cursor; @@ -2309,34 +2266,35 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, rc = CheckGrabValues(client, param); if (rc != Success) - return rc; + return rc; if (param->confineTo == None) - confineTo = NullWindow; + confineTo = NullWindow; else { - rc = dixLookupWindow(&confineTo, param->confineTo, client, DixSetAttrAccess); - if (rc != Success) - return rc; + rc = dixLookupWindow(&confineTo, param->confineTo, client, + DixSetAttrAccess); + if (rc != Success) + return rc; } if (param->cursor == None) - cursor = NullCursor; + cursor = NullCursor; else { - rc = dixLookupResourceByType((pointer *)&cursor, param->cursor, - RT_CURSOR, client, DixUseAccess); - if (rc != Success) - { - client->errorValue = param->cursor; - return rc; - } - access_mode |= DixForceAccess; - } - if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync) - access_mode |= DixFreezeAccess; + rc = dixLookupResourceByType((pointer *) &cursor, param->cursor, + RT_CURSOR, client, DixUseAccess); + if (rc != Success) { + client->errorValue = param->cursor; + return rc; + } + access_mode |= DixForceAccess; + } + if (param->this_device_mode == GrabModeSync || + param->other_devices_mode == GrabModeSync) + access_mode |= DixFreezeAccess; rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); if (rc != Success) - return rc; + return rc; rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess); if (rc != Success) - return rc; + return rc; if (grabtype == XI) type = DeviceButtonPress; @@ -2346,7 +2304,7 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype, mask, param, type, button, confineTo, cursor); if (!grab) - return BadAlloc; + return BadAlloc; return AddPassiveGrabToList(client, grab); } @@ -2356,7 +2314,8 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, */ int GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, - int key, GrabParameters *param, enum InputLevel grabtype, GrabMask *mask) + int key, GrabParameters *param, enum InputLevel grabtype, + GrabMask *mask) { WindowPtr pWin; GrabPtr grab; @@ -2368,32 +2327,33 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, if (rc != Success) return rc; if ((dev->id != XIAllDevices && dev->id != XIAllMasterDevices) && k == NULL) - return BadMatch; - if (grabtype == XI) - { + return BadMatch; + if (grabtype == XI) { if ((key > k->xkbInfo->desc->max_key_code || - key < k->xkbInfo->desc->min_key_code) - && (key != AnyKey)) { + key < k->xkbInfo->desc->min_key_code) + && (key != AnyKey)) { client->errorValue = key; return BadValue; } type = DeviceKeyPress; - } else if (grabtype == XI2) + } + else if (grabtype == XI2) type = XI_KeyPress; rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess); if (rc != Success) - return rc; - if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync) - access_mode |= DixFreezeAccess; + return rc; + if (param->this_device_mode == GrabModeSync || + param->other_devices_mode == GrabModeSync) + access_mode |= DixFreezeAccess; rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); if (rc != Success) - return rc; + return rc; grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype, mask, param, type, key, NULL, NULL); if (!grab) - return BadAlloc; + return BadAlloc; return AddPassiveGrabToList(client, grab); } @@ -2414,28 +2374,29 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type, rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess); if (rc != Success) - return rc; + return rc; if (param->cursor == None) - cursor = NullCursor; + cursor = NullCursor; else { - rc = dixLookupResourceByType((pointer *)&cursor, param->cursor, - RT_CURSOR, client, DixUseAccess); - if (rc != Success) - { - client->errorValue = param->cursor; - return rc; - } - access_mode |= DixForceAccess; - } - if (param->this_device_mode == GrabModeSync || param->other_devices_mode == GrabModeSync) - access_mode |= DixFreezeAccess; + rc = dixLookupResourceByType((pointer *) &cursor, param->cursor, + RT_CURSOR, client, DixUseAccess); + if (rc != Success) { + client->errorValue = param->cursor; + return rc; + } + access_mode |= DixForceAccess; + } + if (param->this_device_mode == GrabModeSync || + param->other_devices_mode == GrabModeSync) + access_mode |= DixFreezeAccess; rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode); if (rc != Success) - return rc; + return rc; grab = CreateGrab(client->index, dev, dev, pWin, XI2, - mask, param, (type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn, - 0, NULL, cursor); + mask, param, + (type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn, 0, + NULL, cursor); if (!grab) return BadAlloc; @@ -2458,10 +2419,10 @@ GrabTouch(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev, rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess); if (rc != Success) - return rc; + return rc; rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGrabAccess); if (rc != Success) - return rc; + return rc; grab = CreateGrab(client->index, dev, mod_dev, pWin, XI2, mask, param, XI_TouchBegin, 0, NullWindow, NullCursor); @@ -2473,7 +2434,7 @@ GrabTouch(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev, int SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client, - Mask mask, Mask exclusivemasks) + Mask mask, Mask exclusivemasks) { int mskidx = dev->id; int i, ret; @@ -2482,54 +2443,54 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client, check = (mask & exclusivemasks); if (wOtherInputMasks(pWin)) { - if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different - * clients to select on any of the - * events for maskcheck. However, - * it is OK, for some client to - * continue selecting on one of those - * events. */ - for (others = wOtherInputMasks(pWin)->inputClients; others; - others = others->next) { - if (!SameClient(others, client) && (check & - others->mask[mskidx])) - return BadAccess; - } - } - for (others = wOtherInputMasks(pWin)->inputClients; others; - others = others->next) { - if (SameClient(others, client)) { - check = others->mask[mskidx]; - others->mask[mskidx] = mask; - if (mask == 0) { - for (i = 0; i < EMASKSIZE; i++) - if (i != mskidx && others->mask[i] != 0) - break; - if (i == EMASKSIZE) { - RecalculateDeviceDeliverableEvents(pWin); - if (ShouldFreeInputMasks(pWin, FALSE)) - FreeResource(others->resource, RT_NONE); - return Success; - } - } - goto maskSet; - } - } + if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different + * clients to select on any of the + * events for maskcheck. However, + * it is OK, for some client to + * continue selecting on one of those + * events. */ + for (others = wOtherInputMasks(pWin)->inputClients; others; + others = others->next) { + if (!SameClient(others, client) && (check & + others->mask[mskidx])) + return BadAccess; + } + } + for (others = wOtherInputMasks(pWin)->inputClients; others; + others = others->next) { + if (SameClient(others, client)) { + check = others->mask[mskidx]; + others->mask[mskidx] = mask; + if (mask == 0) { + for (i = 0; i < EMASKSIZE; i++) + if (i != mskidx && others->mask[i] != 0) + break; + if (i == EMASKSIZE) { + RecalculateDeviceDeliverableEvents(pWin); + if (ShouldFreeInputMasks(pWin, FALSE)) + FreeResource(others->resource, RT_NONE); + return Success; + } + } + goto maskSet; + } + } } check = 0; if ((ret = AddExtensionClient(pWin, client, mask, mskidx)) != Success) - return ret; - maskSet: + return ret; + maskSet: if (dev->valuator) - if ((dev->valuator->motionHintWindow == pWin) && - (mask & DevicePointerMotionHintMask) && - !(check & DevicePointerMotionHintMask) && !dev->deviceGrab.grab) - dev->valuator->motionHintWindow = NullWindow; + if ((dev->valuator->motionHintWindow == pWin) && + (mask & DevicePointerMotionHintMask) && + !(check & DevicePointerMotionHintMask) && !dev->deviceGrab.grab) + dev->valuator->motionHintWindow = NullWindow; RecalculateDeviceDeliverableEvents(pWin); return Success; } static void -FreeInputClient(InputClientsPtr *other) +FreeInputClient(InputClientsPtr * other) { xi2mask_free(&(*other)->xi2mask); free(*other); @@ -2548,12 +2509,12 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx) InputClientsPtr others; if (!pWin->optional && !MakeWindowOptional(pWin)) - return BadAlloc; + return BadAlloc; others = AllocInputClient(); if (!others) - return BadAlloc; + return BadAlloc; if (!pWin->optional->inputMasks && !MakeInputMasks(pWin)) - goto bail; + goto bail; others->xi2mask = xi2mask_new(); if (!others->xi2mask) goto bail; @@ -2562,10 +2523,10 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx) others->next = pWin->optional->inputMasks->inputClients; pWin->optional->inputMasks->inputClients = others; if (!AddResource(others->resource, RT_INPUTCLIENT, (pointer) pWin)) - goto bail; + goto bail; return Success; -bail: + bail: FreeInputClient(&others); return BadAlloc; } @@ -2577,10 +2538,9 @@ MakeInputMasks(WindowPtr pWin) imasks = calloc(1, sizeof(struct _OtherInputMasks)); if (!imasks) - return FALSE; + return FALSE; imasks->xi2mask = xi2mask_new(); - if (!imasks->xi2mask) - { + if (!imasks->xi2mask) { free(imasks); return FALSE; } @@ -2589,7 +2549,7 @@ MakeInputMasks(WindowPtr pWin) } static void -FreeInputMask(OtherInputMasks **imask) +FreeInputMask(OtherInputMasks ** imask) { xi2mask_free(&(*imask)->xi2mask); free(*imask); @@ -2600,39 +2560,39 @@ void RecalculateDeviceDeliverableEvents(WindowPtr pWin) { InputClientsPtr others; - struct _OtherInputMasks *inputMasks; /* default: NULL */ + struct _OtherInputMasks *inputMasks; /* default: NULL */ WindowPtr pChild, tmp; int i; pChild = pWin; while (1) { - if ((inputMasks = wOtherInputMasks(pChild)) != 0) { + if ((inputMasks = wOtherInputMasks(pChild)) != 0) { xi2mask_zero(inputMasks->xi2mask, -1); - for (others = inputMasks->inputClients; others; - others = others->next) { - for (i = 0; i < EMASKSIZE; i++) - inputMasks->inputEvents[i] |= others->mask[i]; + for (others = inputMasks->inputClients; others; + others = others->next) { + for (i = 0; i < EMASKSIZE; i++) + inputMasks->inputEvents[i] |= others->mask[i]; xi2mask_merge(inputMasks->xi2mask, others->xi2mask); - } - for (i = 0; i < EMASKSIZE; i++) - inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i]; - for (tmp = pChild->parent; tmp; tmp = tmp->parent) - if (wOtherInputMasks(tmp)) - for (i = 0; i < EMASKSIZE; i++) - inputMasks->deliverableEvents[i] |= - (wOtherInputMasks(tmp)->deliverableEvents[i] - & ~inputMasks-> - dontPropagateMask[i] & PropagateMask[i]); - } - if (pChild->firstChild) { - pChild = pChild->firstChild; - continue; - } - while (!pChild->nextSib && (pChild != pWin)) - pChild = pChild->parent; - if (pChild == pWin) - break; - pChild = pChild->nextSib; + } + for (i = 0; i < EMASKSIZE; i++) + inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i]; + for (tmp = pChild->parent; tmp; tmp = tmp->parent) + if (wOtherInputMasks(tmp)) + for (i = 0; i < EMASKSIZE; i++) + inputMasks->deliverableEvents[i] |= + (wOtherInputMasks(tmp)->deliverableEvents[i] + & ~inputMasks->dontPropagateMask[i] & + PropagateMask[i]); + } + if (pChild->firstChild) { + pChild = pChild->firstChild; + continue; + } + while (!pChild->nextSib && (pChild != pWin)) + pChild = pChild->parent; + if (pChild == pWin) + break; + pChild = pChild->nextSib; } } @@ -2642,36 +2602,40 @@ InputClientGone(WindowPtr pWin, XID id) InputClientsPtr other, prev; if (!wOtherInputMasks(pWin)) - return Success; + return Success; prev = 0; for (other = wOtherInputMasks(pWin)->inputClients; other; - other = other->next) { - if (other->resource == id) { - if (prev) { - prev->next = other->next; - FreeInputClient(&other); - } else if (!(other->next)) { - if (ShouldFreeInputMasks(pWin, TRUE)) { - OtherInputMasks *mask = wOtherInputMasks(pWin); - mask->inputClients = other->next; - FreeInputMask(&mask); - pWin->optional->inputMasks = (OtherInputMasks *) NULL; - CheckWindowOptionalNeed(pWin); - FreeInputClient(&other); - } else { - other->resource = FakeClientID(0); - if (!AddResource(other->resource, RT_INPUTCLIENT, - (pointer) pWin)) - return BadAlloc; - } - } else { - wOtherInputMasks(pWin)->inputClients = other->next; - FreeInputClient(&other); - } - RecalculateDeviceDeliverableEvents(pWin); - return Success; - } - prev = other; + other = other->next) { + if (other->resource == id) { + if (prev) { + prev->next = other->next; + FreeInputClient(&other); + } + else if (!(other->next)) { + if (ShouldFreeInputMasks(pWin, TRUE)) { + OtherInputMasks *mask = wOtherInputMasks(pWin); + + mask->inputClients = other->next; + FreeInputMask(&mask); + pWin->optional->inputMasks = (OtherInputMasks *) NULL; + CheckWindowOptionalNeed(pWin); + FreeInputClient(&other); + } + else { + other->resource = FakeClientID(0); + if (!AddResource(other->resource, RT_INPUTCLIENT, + (pointer) pWin)) + return BadAlloc; + } + } + else { + wOtherInputMasks(pWin)->inputClients = other->next; + FreeInputClient(&other); + } + RecalculateDeviceDeliverableEvents(pWin); + return Success; + } + prev = other; } FatalError("client not on device event list"); } @@ -2681,7 +2645,8 @@ InputClientGone(WindowPtr pWin, XID id) * and all its subwindows from the trace when found. The initial window * order is preserved. */ -void WindowGone(WindowPtr win) +void +WindowGone(WindowPtr win) { DeviceIntPtr dev; @@ -2708,60 +2673,63 @@ void WindowGone(WindowPtr win) int SendEvent(ClientPtr client, DeviceIntPtr d, Window dest, Bool propagate, - xEvent * ev, Mask mask, int count) + xEvent *ev, Mask mask, int count) { WindowPtr pWin; - WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */ + WindowPtr effectiveFocus = NullWindow; /* only set if dest==InputFocus */ WindowPtr spriteWin = GetSpriteWindow(d); if (dest == PointerWindow) - pWin = spriteWin; + pWin = spriteWin; else if (dest == InputFocus) { - WindowPtr inputFocus; - - if (!d->focus) - inputFocus = spriteWin; - else - inputFocus = d->focus->win; - - if (inputFocus == FollowKeyboardWin) - inputFocus = inputInfo.keyboard->focus->win; - - if (inputFocus == NoneWin) - return Success; - - /* If the input focus is PointerRootWin, send the event to where - * the pointer is if possible, then perhaps propogate up to root. */ - if (inputFocus == PointerRootWin) - inputFocus = GetCurrentRootWindow(d); - - if (IsParent(inputFocus, spriteWin)) { - effectiveFocus = inputFocus; - pWin = spriteWin; - } else - effectiveFocus = pWin = inputFocus; - } else - dixLookupWindow(&pWin, dest, client, DixSendAccess); + WindowPtr inputFocus; + + if (!d->focus) + inputFocus = spriteWin; + else + inputFocus = d->focus->win; + + if (inputFocus == FollowKeyboardWin) + inputFocus = inputInfo.keyboard->focus->win; + + if (inputFocus == NoneWin) + return Success; + + /* If the input focus is PointerRootWin, send the event to where + * the pointer is if possible, then perhaps propogate up to root. */ + if (inputFocus == PointerRootWin) + inputFocus = GetCurrentRootWindow(d); + + if (IsParent(inputFocus, spriteWin)) { + effectiveFocus = inputFocus; + pWin = spriteWin; + } + else + effectiveFocus = pWin = inputFocus; + } + else + dixLookupWindow(&pWin, dest, client, DixSendAccess); if (!pWin) - return BadWindow; + return BadWindow; if ((propagate != xFalse) && (propagate != xTrue)) { - client->errorValue = propagate; - return BadValue; + client->errorValue = propagate; + return BadValue; } ev->u.u.type |= 0x80; if (propagate) { - for (; pWin; pWin = pWin->parent) { - if (DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab)) - return Success; - if (pWin == effectiveFocus) - return Success; - if (wOtherInputMasks(pWin)) - mask &= ~wOtherInputMasks(pWin)->dontPropagateMask[d->id]; - if (!mask) - break; - } - } else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, ev, count)) - DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab); + for (; pWin; pWin = pWin->parent) { + if (DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab)) + return Success; + if (pWin == effectiveFocus) + return Success; + if (wOtherInputMasks(pWin)) + mask &= ~wOtherInputMasks(pWin)->dontPropagateMask[d->id]; + if (!mask) + break; + } + } + else if (!XaceHook(XACE_SEND_ACCESS, client, NULL, pWin, ev, count)) + DeliverEventsToWindow(d, pWin, ev, count, mask, NullGrab); return Success; } @@ -2772,47 +2740,47 @@ SetButtonMapping(ClientPtr client, DeviceIntPtr dev, int nElts, BYTE * map) ButtonClassPtr b = dev->button; if (b == NULL) - return BadMatch; + return BadMatch; if (nElts != b->numButtons) { - client->errorValue = nElts; - return BadValue; + client->errorValue = nElts; + return BadValue; } if (BadDeviceMap(&map[0], nElts, 1, 255, &client->errorValue)) - return BadValue; + return BadValue; for (i = 0; i < nElts; i++) - if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1)) - return MappingBusy; + if ((b->map[i + 1] != map[i]) && BitIsOn(b->down, i + 1)) + return MappingBusy; for (i = 0; i < nElts; i++) - b->map[i + 1] = map[i]; + b->map[i + 1] = map[i]; return Success; } int ChangeKeyMapping(ClientPtr client, - DeviceIntPtr dev, - unsigned len, - int type, - KeyCode firstKeyCode, - CARD8 keyCodes, CARD8 keySymsPerKeyCode, KeySym * map) + DeviceIntPtr dev, + unsigned len, + int type, + KeyCode firstKeyCode, + CARD8 keyCodes, CARD8 keySymsPerKeyCode, KeySym * map) { KeySymsRec keysyms; KeyClassPtr k = dev->key; if (k == NULL) - return BadMatch; + return BadMatch; if (len != (keyCodes * keySymsPerKeyCode)) - return BadLength; + return BadLength; if ((firstKeyCode < k->xkbInfo->desc->min_key_code) || - (firstKeyCode + keyCodes - 1 > k->xkbInfo->desc->max_key_code)) { - client->errorValue = firstKeyCode; - return BadValue; + (firstKeyCode + keyCodes - 1 > k->xkbInfo->desc->max_key_code)) { + client->errorValue = firstKeyCode; + return BadValue; } if (keySymsPerKeyCode == 0) { - client->errorValue = 0; - return BadValue; + client->errorValue = 0; + return BadValue; } keysyms.minKeyCode = firstKeyCode; keysyms.maxKeyCode = firstKeyCode + keyCodes - 1; @@ -2835,68 +2803,70 @@ DeleteDeviceFromAnyExtEvents(WindowPtr pWin, DeviceIntPtr dev) * Deactivating a device grab should cause focus events. */ if (dev->deviceGrab.grab && (dev->deviceGrab.grab->window == pWin)) - (*dev->deviceGrab.DeactivateGrab) (dev); + (*dev->deviceGrab.DeactivateGrab) (dev); /* If the focus window is a root window (ie. has no parent) * then don't delete the focus from it. */ if (dev->focus && (pWin == dev->focus->win) && (pWin->parent != NullWindow)) { - int focusEventMode = NotifyNormal; - - /* If a grab is in progress, then alter the mode of focus events. */ - - if (dev->deviceGrab.grab) - focusEventMode = NotifyWhileGrabbed; - - switch (dev->focus->revert) { - case RevertToNone: - if (!ActivateFocusInGrab(dev, pWin, NoneWin)) - DoFocusEvents(dev, pWin, NoneWin, focusEventMode); - dev->focus->win = NoneWin; - dev->focus->traceGood = 0; - break; - case RevertToParent: - parent = pWin; - do { - parent = parent->parent; - dev->focus->traceGood--; - } - while (!parent->realized); - if (!ActivateFocusInGrab(dev, pWin, parent)) - DoFocusEvents(dev, pWin, parent, focusEventMode); - dev->focus->win = parent; - dev->focus->revert = RevertToNone; - break; - case RevertToPointerRoot: - if (!ActivateFocusInGrab(dev, pWin, PointerRootWin)) - DoFocusEvents(dev, pWin, PointerRootWin, focusEventMode); - dev->focus->win = PointerRootWin; - dev->focus->traceGood = 0; - break; - case RevertToFollowKeyboard: - { - DeviceIntPtr kbd = GetMaster(dev, MASTER_KEYBOARD); - if (!kbd || (kbd == dev && kbd != inputInfo.keyboard)) - kbd = inputInfo.keyboard; - if (kbd->focus->win) { - if (!ActivateFocusInGrab(dev, pWin, kbd->focus->win)) - DoFocusEvents(dev, pWin, kbd->focus->win, focusEventMode); - dev->focus->win = FollowKeyboardWin; - dev->focus->traceGood = 0; - } else { + int focusEventMode = NotifyNormal; + + /* If a grab is in progress, then alter the mode of focus events. */ + + if (dev->deviceGrab.grab) + focusEventMode = NotifyWhileGrabbed; + + switch (dev->focus->revert) { + case RevertToNone: + if (!ActivateFocusInGrab(dev, pWin, NoneWin)) + DoFocusEvents(dev, pWin, NoneWin, focusEventMode); + dev->focus->win = NoneWin; + dev->focus->traceGood = 0; + break; + case RevertToParent: + parent = pWin; + do { + parent = parent->parent; + dev->focus->traceGood--; + } + while (!parent->realized); + if (!ActivateFocusInGrab(dev, pWin, parent)) + DoFocusEvents(dev, pWin, parent, focusEventMode); + dev->focus->win = parent; + dev->focus->revert = RevertToNone; + break; + case RevertToPointerRoot: + if (!ActivateFocusInGrab(dev, pWin, PointerRootWin)) + DoFocusEvents(dev, pWin, PointerRootWin, focusEventMode); + dev->focus->win = PointerRootWin; + dev->focus->traceGood = 0; + break; + case RevertToFollowKeyboard: + { + DeviceIntPtr kbd = GetMaster(dev, MASTER_KEYBOARD); + + if (!kbd || (kbd == dev && kbd != inputInfo.keyboard)) + kbd = inputInfo.keyboard; + if (kbd->focus->win) { + if (!ActivateFocusInGrab(dev, pWin, kbd->focus->win)) + DoFocusEvents(dev, pWin, kbd->focus->win, focusEventMode); + dev->focus->win = FollowKeyboardWin; + dev->focus->traceGood = 0; + } + else { if (!ActivateFocusInGrab(dev, pWin, NoneWin)) DoFocusEvents(dev, pWin, NoneWin, focusEventMode); - dev->focus->win = NoneWin; - dev->focus->traceGood = 0; - } + dev->focus->win = NoneWin; + dev->focus->traceGood = 0; } - break; - } + } + break; + } } if (dev->valuator) - if (dev->valuator->motionHintWindow == pWin) - dev->valuator->motionHintWindow = NullWindow; + if (dev->valuator->motionHintWindow == pWin) + dev->valuator->motionHintWindow = NullWindow; } void @@ -2908,79 +2878,80 @@ DeleteWindowFromAnyExtEvents(WindowPtr pWin, Bool freeResources) struct _OtherInputMasks *inputMasks; for (dev = inputInfo.devices; dev; dev = dev->next) { - DeleteDeviceFromAnyExtEvents(pWin, dev); + DeleteDeviceFromAnyExtEvents(pWin, dev); } for (dev = inputInfo.off_devices; dev; dev = dev->next) - DeleteDeviceFromAnyExtEvents(pWin, dev); + DeleteDeviceFromAnyExtEvents(pWin, dev); if (freeResources) - while ((inputMasks = wOtherInputMasks(pWin)) != 0) { - ic = inputMasks->inputClients; - for (i = 0; i < EMASKSIZE; i++) - inputMasks->dontPropagateMask[i] = 0; - FreeResource(ic->resource, RT_NONE); - } + while ((inputMasks = wOtherInputMasks(pWin)) != 0) { + ic = inputMasks->inputClients; + for (i = 0; i < EMASKSIZE; i++) + inputMasks->dontPropagateMask[i] = 0; + FreeResource(ic->resource, RT_NONE); + } } int -MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer * pEvents, Mask mask) +MaybeSendDeviceMotionNotifyHint(deviceKeyButtonPointer *pEvents, Mask mask) { DeviceIntPtr dev; dixLookupDevice(&dev, pEvents->deviceid & DEVICE_BITS, serverClient, - DixReadAccess); + DixReadAccess); if (!dev) return 0; if (pEvents->type == DeviceMotionNotify) { - if (mask & DevicePointerMotionHintMask) { - if (WID(dev->valuator->motionHintWindow) == pEvents->event) { - return 1; /* don't send, but pretend we did */ - } - pEvents->detail = NotifyHint; - } else { - pEvents->detail = NotifyNormal; - } + if (mask & DevicePointerMotionHintMask) { + if (WID(dev->valuator->motionHintWindow) == pEvents->event) { + return 1; /* don't send, but pretend we did */ + } + pEvents->detail = NotifyHint; + } + else { + pEvents->detail = NotifyNormal; + } } return 0; } void CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type, - deviceKeyButtonPointer * xE, GrabPtr grab, - ClientPtr client, Mask deliveryMask) + deviceKeyButtonPointer *xE, GrabPtr grab, + ClientPtr client, Mask deliveryMask) { DeviceIntPtr dev; dixLookupDevice(&dev, xE->deviceid & DEVICE_BITS, serverClient, - DixGrabAccess); + DixGrabAccess); if (!dev) return; if (type == DeviceMotionNotify) - dev->valuator->motionHintWindow = pWin; + dev->valuator->motionHintWindow = pWin; else if ((type == DeviceButtonPress) && (!grab) && - (deliveryMask & DeviceButtonGrabMask)) { - GrabPtr tempGrab; + (deliveryMask & DeviceButtonGrabMask)) { + GrabPtr tempGrab; - tempGrab = AllocGrab(); - if (!tempGrab) - return; + tempGrab = AllocGrab(); + if (!tempGrab) + return; - tempGrab->device = dev; - tempGrab->resource = client->clientAsMask; - tempGrab->window = pWin; - tempGrab->ownerEvents = - (deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE; - tempGrab->eventMask = deliveryMask; - tempGrab->keyboardMode = GrabModeAsync; - tempGrab->pointerMode = GrabModeAsync; - tempGrab->confineTo = NullWindow; - tempGrab->cursor = NullCursor; - tempGrab->next = NULL; - (*dev->deviceGrab.ActivateGrab) (dev, tempGrab, currentTime, TRUE); - FreeGrab(tempGrab); + tempGrab->device = dev; + tempGrab->resource = client->clientAsMask; + tempGrab->window = pWin; + tempGrab->ownerEvents = + (deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE; + tempGrab->eventMask = deliveryMask; + tempGrab->keyboardMode = GrabModeAsync; + tempGrab->pointerMode = GrabModeAsync; + tempGrab->confineTo = NullWindow; + tempGrab->cursor = NullCursor; + tempGrab->next = NULL; + (*dev->deviceGrab.ActivateGrab) (dev, tempGrab, currentTime, TRUE); + FreeGrab(tempGrab); } } @@ -2990,11 +2961,11 @@ DeviceEventMaskForClient(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client) InputClientsPtr other; if (!wOtherInputMasks(pWin)) - return 0; + return 0; for (other = wOtherInputMasks(pWin)->inputClients; other; - other = other->next) { - if (SameClient(other, client)) - return other->mask[dev->id]; + other = other->next) { + if (SameClient(other, client)) + return other->mask[dev->id]; } return 0; } @@ -3008,39 +2979,40 @@ MaybeStopDeviceHint(DeviceIntPtr dev, ClientPtr client) pWin = dev->valuator->motionHintWindow; if ((grab && SameClient(grab, client) && - ((grab->eventMask & DevicePointerMotionHintMask) || - (grab->ownerEvents && - (DeviceEventMaskForClient(dev, pWin, client) & - DevicePointerMotionHintMask)))) || - (!grab && - (DeviceEventMaskForClient(dev, pWin, client) & - DevicePointerMotionHintMask))) - dev->valuator->motionHintWindow = NullWindow; + ((grab->eventMask & DevicePointerMotionHintMask) || + (grab->ownerEvents && + (DeviceEventMaskForClient(dev, pWin, client) & + DevicePointerMotionHintMask)))) || + (!grab && + (DeviceEventMaskForClient(dev, pWin, client) & + DevicePointerMotionHintMask))) + dev->valuator->motionHintWindow = NullWindow; } int DeviceEventSuppressForWindow(WindowPtr pWin, ClientPtr client, Mask mask, - int maskndx) + int maskndx) { struct _OtherInputMasks *inputMasks = wOtherInputMasks(pWin); if (mask & ~PropagateMask[maskndx]) { - client->errorValue = mask; - return BadValue; + client->errorValue = mask; + return BadValue; } if (mask == 0) { - if (inputMasks) - inputMasks->dontPropagateMask[maskndx] = mask; - } else { - if (!inputMasks) - AddExtensionClient(pWin, client, 0, 0); - inputMasks = wOtherInputMasks(pWin); - inputMasks->dontPropagateMask[maskndx] = mask; + if (inputMasks) + inputMasks->dontPropagateMask[maskndx] = mask; + } + else { + if (!inputMasks) + AddExtensionClient(pWin, client, 0, 0); + inputMasks = wOtherInputMasks(pWin); + inputMasks->dontPropagateMask[maskndx] = mask; } RecalculateDeviceDeliverableEvents(pWin); if (ShouldFreeInputMasks(pWin, FALSE)) - FreeResource(inputMasks->inputClients->resource, RT_NONE); + FreeResource(inputMasks->inputClients->resource, RT_NONE); return Success; } @@ -3052,14 +3024,14 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents) struct _OtherInputMasks *inputMasks = wOtherInputMasks(pWin); for (i = 0; i < EMASKSIZE; i++) - allInputEventMasks |= inputMasks->dontPropagateMask[i]; + allInputEventMasks |= inputMasks->dontPropagateMask[i]; if (!ignoreSelectedEvents) - for (i = 0; i < EMASKSIZE; i++) - allInputEventMasks |= inputMasks->inputEvents[i]; + for (i = 0; i < EMASKSIZE; i++) + allInputEventMasks |= inputMasks->inputEvents[i]; if (allInputEventMasks == 0) - return TRUE; + return TRUE; else - return FALSE; + return FALSE; } /*********************************************************************** @@ -3071,7 +3043,7 @@ ShouldFreeInputMasks(WindowPtr pWin, Bool ignoreSelectedEvents) static void FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, - xEvent * ev, int count) + xEvent *ev, int count) { WindowPtr p2; @@ -3090,7 +3062,7 @@ FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask, */ void -SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) +SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent *ev, int count) { int i; WindowPtr pWin, p1; @@ -3115,29 +3087,26 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count) */ int XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, - unsigned int len, unsigned char* mask) + unsigned int len, unsigned char *mask) { OtherInputMasks *masks; InputClientsPtr others = NULL; masks = wOtherInputMasks(win); - if (masks) - { - for (others = wOtherInputMasks(win)->inputClients; others; - others = others->next) { - if (SameClient(others, client)) { + if (masks) { + for (others = wOtherInputMasks(win)->inputClients; others; + others = others->next) { + if (SameClient(others, client)) { xi2mask_zero(others->xi2mask, dev->id); break; } } } - - if (len && !others) - { + if (len && !others) { if (AddExtensionClient(win, client, 0, 0) != Success) return BadAlloc; - others= wOtherInputMasks(win)->inputClients; + others = wOtherInputMasks(win)->inputClients; } if (others) { diff --git a/xorg-server/Xi/extinit.c b/xorg-server/Xi/extinit.c index a81c8f1ff..4483076e9 100644 --- a/xorg-server/Xi/extinit.c +++ b/xorg-server/Xi/extinit.c @@ -58,13 +58,13 @@ SOFTWARE. #endif #include "inputstr.h" -#include "gcstruct.h" /* pointer for extnsionst.h */ -#include "extnsionst.h" /* extension entry */ +#include "gcstruct.h" /* pointer for extnsionst.h */ +#include "extnsionst.h" /* extension entry */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include <X11/extensions/XI2proto.h> #include <X11/extensions/geproto.h> -#include "geext.h" /* extension interfaces for ge */ +#include "geext.h" /* extension interfaces for ge */ #include "dixevents.h" #include "exevents.h" @@ -125,42 +125,40 @@ SOFTWARE. #include "xisetclientpointer.h" #include "xiwarppointer.h" - /* Masks for XI events have to be aligned with core event (partially anyway). * If DeviceButtonMotionMask is != ButtonMotionMask, event delivery * breaks down. The device needs the dev->button->motionMask. If DBMM is * the same as BMM, we can ensure that both core and device events can be * delivered, without the need for extra structures in the DeviceIntRec. */ -const Mask DeviceKeyPressMask = KeyPressMask; -const Mask DeviceKeyReleaseMask = KeyReleaseMask; -const Mask DeviceButtonPressMask = ButtonPressMask; -const Mask DeviceButtonReleaseMask = ButtonReleaseMask; -const Mask DeviceProximityMask = (1L << 4); -const Mask DeviceStateNotifyMask = (1L << 5); -const Mask DevicePointerMotionMask = PointerMotionMask; -const Mask DevicePointerMotionHintMask = PointerMotionHintMask; -const Mask DeviceButton1MotionMask = Button1MotionMask; -const Mask DeviceButton2MotionMask = Button2MotionMask; -const Mask DeviceButton3MotionMask = Button3MotionMask; -const Mask DeviceButton4MotionMask = Button4MotionMask; -const Mask DeviceButton5MotionMask = Button5MotionMask; -const Mask DeviceButtonMotionMask = ButtonMotionMask; -const Mask DeviceFocusChangeMask = (1L << 14); -const Mask DeviceMappingNotifyMask = (1L << 15); -const Mask ChangeDeviceNotifyMask = (1L << 16); -const Mask DeviceButtonGrabMask = (1L << 17); -const Mask DeviceOwnerGrabButtonMask = (1L << 17); -const Mask DevicePresenceNotifyMask = (1L << 18); -const Mask DeviceEnterWindowMask = (1L << 18); -const Mask DeviceLeaveWindowMask = (1L << 19); -const Mask DevicePropertyNotifyMask = (1L << 20); -const Mask XIAllMasks = (1L << 21) - 1; +const Mask DeviceKeyPressMask = KeyPressMask; +const Mask DeviceKeyReleaseMask = KeyReleaseMask; +const Mask DeviceButtonPressMask = ButtonPressMask; +const Mask DeviceButtonReleaseMask = ButtonReleaseMask; +const Mask DeviceProximityMask = (1L << 4); +const Mask DeviceStateNotifyMask = (1L << 5); +const Mask DevicePointerMotionMask = PointerMotionMask; +const Mask DevicePointerMotionHintMask = PointerMotionHintMask; +const Mask DeviceButton1MotionMask = Button1MotionMask; +const Mask DeviceButton2MotionMask = Button2MotionMask; +const Mask DeviceButton3MotionMask = Button3MotionMask; +const Mask DeviceButton4MotionMask = Button4MotionMask; +const Mask DeviceButton5MotionMask = Button5MotionMask; +const Mask DeviceButtonMotionMask = ButtonMotionMask; +const Mask DeviceFocusChangeMask = (1L << 14); +const Mask DeviceMappingNotifyMask = (1L << 15); +const Mask ChangeDeviceNotifyMask = (1L << 16); +const Mask DeviceButtonGrabMask = (1L << 17); +const Mask DeviceOwnerGrabButtonMask = (1L << 17); +const Mask DevicePresenceNotifyMask = (1L << 18); +const Mask DeviceEnterWindowMask = (1L << 18); +const Mask DeviceLeaveWindowMask = (1L << 19); +const Mask DevicePropertyNotifyMask = (1L << 20); +const Mask XIAllMasks = (1L << 21) - 1; int ExtEventIndex; Mask ExtExclusiveMasks[EMASKSIZE]; -static struct dev_type -{ +static struct dev_type { Atom type; const char *name; } dev_type[] = { @@ -194,135 +192,135 @@ static DeviceIntRec xi_all_master_devices; * Dispatch vector. Functions defined in here will be called when the matching * request arrives. */ -static int (*ProcIVector[])(ClientPtr) = { - NULL, /* 0 */ - ProcXGetExtensionVersion, /* 1 */ - ProcXListInputDevices, /* 2 */ - ProcXOpenDevice, /* 3 */ - ProcXCloseDevice, /* 4 */ - ProcXSetDeviceMode, /* 5 */ - ProcXSelectExtensionEvent, /* 6 */ - ProcXGetSelectedExtensionEvents, /* 7 */ - ProcXChangeDeviceDontPropagateList, /* 8 */ - ProcXGetDeviceDontPropagateList, /* 9 */ - ProcXGetDeviceMotionEvents, /* 10 */ - ProcXChangeKeyboardDevice, /* 11 */ - ProcXChangePointerDevice, /* 12 */ - ProcXGrabDevice, /* 13 */ - ProcXUngrabDevice, /* 14 */ - ProcXGrabDeviceKey, /* 15 */ - ProcXUngrabDeviceKey, /* 16 */ - ProcXGrabDeviceButton, /* 17 */ - ProcXUngrabDeviceButton, /* 18 */ - ProcXAllowDeviceEvents, /* 19 */ - ProcXGetDeviceFocus, /* 20 */ - ProcXSetDeviceFocus, /* 21 */ - ProcXGetFeedbackControl, /* 22 */ - ProcXChangeFeedbackControl, /* 23 */ - ProcXGetDeviceKeyMapping, /* 24 */ - ProcXChangeDeviceKeyMapping, /* 25 */ - ProcXGetDeviceModifierMapping, /* 26 */ - ProcXSetDeviceModifierMapping, /* 27 */ - ProcXGetDeviceButtonMapping, /* 28 */ - ProcXSetDeviceButtonMapping, /* 29 */ - ProcXQueryDeviceState, /* 30 */ - ProcXSendExtensionEvent, /* 31 */ - ProcXDeviceBell, /* 32 */ - ProcXSetDeviceValuators, /* 33 */ - ProcXGetDeviceControl, /* 34 */ - ProcXChangeDeviceControl, /* 35 */ +static int (*ProcIVector[]) (ClientPtr) = { + NULL, /* 0 */ + ProcXGetExtensionVersion, /* 1 */ + ProcXListInputDevices, /* 2 */ + ProcXOpenDevice, /* 3 */ + ProcXCloseDevice, /* 4 */ + ProcXSetDeviceMode, /* 5 */ + ProcXSelectExtensionEvent, /* 6 */ + ProcXGetSelectedExtensionEvents, /* 7 */ + ProcXChangeDeviceDontPropagateList, /* 8 */ + ProcXGetDeviceDontPropagateList, /* 9 */ + ProcXGetDeviceMotionEvents, /* 10 */ + ProcXChangeKeyboardDevice, /* 11 */ + ProcXChangePointerDevice, /* 12 */ + ProcXGrabDevice, /* 13 */ + ProcXUngrabDevice, /* 14 */ + ProcXGrabDeviceKey, /* 15 */ + ProcXUngrabDeviceKey, /* 16 */ + ProcXGrabDeviceButton, /* 17 */ + ProcXUngrabDeviceButton, /* 18 */ + ProcXAllowDeviceEvents, /* 19 */ + ProcXGetDeviceFocus, /* 20 */ + ProcXSetDeviceFocus, /* 21 */ + ProcXGetFeedbackControl, /* 22 */ + ProcXChangeFeedbackControl, /* 23 */ + ProcXGetDeviceKeyMapping, /* 24 */ + ProcXChangeDeviceKeyMapping, /* 25 */ + ProcXGetDeviceModifierMapping, /* 26 */ + ProcXSetDeviceModifierMapping, /* 27 */ + ProcXGetDeviceButtonMapping, /* 28 */ + ProcXSetDeviceButtonMapping, /* 29 */ + ProcXQueryDeviceState, /* 30 */ + ProcXSendExtensionEvent, /* 31 */ + ProcXDeviceBell, /* 32 */ + ProcXSetDeviceValuators, /* 33 */ + ProcXGetDeviceControl, /* 34 */ + ProcXChangeDeviceControl, /* 35 */ /* XI 1.5 */ - ProcXListDeviceProperties, /* 36 */ - ProcXChangeDeviceProperty, /* 37 */ - ProcXDeleteDeviceProperty, /* 38 */ - ProcXGetDeviceProperty, /* 39 */ + ProcXListDeviceProperties, /* 36 */ + ProcXChangeDeviceProperty, /* 37 */ + ProcXDeleteDeviceProperty, /* 38 */ + ProcXGetDeviceProperty, /* 39 */ /* XI 2 */ - ProcXIQueryPointer, /* 40 */ - ProcXIWarpPointer, /* 41 */ - ProcXIChangeCursor, /* 42 */ - ProcXIChangeHierarchy, /* 43 */ - ProcXISetClientPointer, /* 44 */ - ProcXIGetClientPointer, /* 45 */ - ProcXISelectEvents, /* 46 */ - ProcXIQueryVersion, /* 47 */ - ProcXIQueryDevice, /* 48 */ - ProcXISetFocus, /* 49 */ - ProcXIGetFocus, /* 50 */ - ProcXIGrabDevice, /* 51 */ - ProcXIUngrabDevice, /* 52 */ - ProcXIAllowEvents, /* 53 */ - ProcXIPassiveGrabDevice, /* 54 */ - ProcXIPassiveUngrabDevice, /* 55 */ - ProcXIListProperties, /* 56 */ - ProcXIChangeProperty, /* 57 */ - ProcXIDeleteProperty, /* 58 */ - ProcXIGetProperty, /* 59 */ - ProcXIGetSelectedEvents /* 60 */ + ProcXIQueryPointer, /* 40 */ + ProcXIWarpPointer, /* 41 */ + ProcXIChangeCursor, /* 42 */ + ProcXIChangeHierarchy, /* 43 */ + ProcXISetClientPointer, /* 44 */ + ProcXIGetClientPointer, /* 45 */ + ProcXISelectEvents, /* 46 */ + ProcXIQueryVersion, /* 47 */ + ProcXIQueryDevice, /* 48 */ + ProcXISetFocus, /* 49 */ + ProcXIGetFocus, /* 50 */ + ProcXIGrabDevice, /* 51 */ + ProcXIUngrabDevice, /* 52 */ + ProcXIAllowEvents, /* 53 */ + ProcXIPassiveGrabDevice, /* 54 */ + ProcXIPassiveUngrabDevice, /* 55 */ + ProcXIListProperties, /* 56 */ + ProcXIChangeProperty, /* 57 */ + ProcXIDeleteProperty, /* 58 */ + ProcXIGetProperty, /* 59 */ + ProcXIGetSelectedEvents /* 60 */ }; /* For swapped clients */ -static int (*SProcIVector[])(ClientPtr) = { - NULL, /* 0 */ - SProcXGetExtensionVersion, /* 1 */ - SProcXListInputDevices, /* 2 */ - SProcXOpenDevice, /* 3 */ - SProcXCloseDevice, /* 4 */ - SProcXSetDeviceMode, /* 5 */ - SProcXSelectExtensionEvent, /* 6 */ - SProcXGetSelectedExtensionEvents, /* 7 */ - SProcXChangeDeviceDontPropagateList, /* 8 */ - SProcXGetDeviceDontPropagateList, /* 9 */ - SProcXGetDeviceMotionEvents, /* 10 */ - SProcXChangeKeyboardDevice, /* 11 */ - SProcXChangePointerDevice, /* 12 */ - SProcXGrabDevice, /* 13 */ - SProcXUngrabDevice, /* 14 */ - SProcXGrabDeviceKey, /* 15 */ - SProcXUngrabDeviceKey, /* 16 */ - SProcXGrabDeviceButton, /* 17 */ - SProcXUngrabDeviceButton, /* 18 */ - SProcXAllowDeviceEvents, /* 19 */ - SProcXGetDeviceFocus, /* 20 */ - SProcXSetDeviceFocus, /* 21 */ - SProcXGetFeedbackControl, /* 22 */ - SProcXChangeFeedbackControl, /* 23 */ - SProcXGetDeviceKeyMapping, /* 24 */ - SProcXChangeDeviceKeyMapping, /* 25 */ - SProcXGetDeviceModifierMapping, /* 26 */ - SProcXSetDeviceModifierMapping, /* 27 */ - SProcXGetDeviceButtonMapping, /* 28 */ - SProcXSetDeviceButtonMapping, /* 29 */ - SProcXQueryDeviceState, /* 30 */ - SProcXSendExtensionEvent, /* 31 */ - SProcXDeviceBell, /* 32 */ - SProcXSetDeviceValuators, /* 33 */ - SProcXGetDeviceControl, /* 34 */ - SProcXChangeDeviceControl, /* 35 */ - SProcXListDeviceProperties, /* 36 */ - SProcXChangeDeviceProperty, /* 37 */ - SProcXDeleteDeviceProperty, /* 38 */ - SProcXGetDeviceProperty, /* 39 */ - SProcXIQueryPointer, /* 40 */ - SProcXIWarpPointer, /* 41 */ - SProcXIChangeCursor, /* 42 */ - SProcXIChangeHierarchy, /* 43 */ - SProcXISetClientPointer, /* 44 */ - SProcXIGetClientPointer, /* 45 */ - SProcXISelectEvents, /* 46 */ - SProcXIQueryVersion, /* 47 */ - SProcXIQueryDevice, /* 48 */ - SProcXISetFocus, /* 49 */ - SProcXIGetFocus, /* 50 */ - SProcXIGrabDevice, /* 51 */ - SProcXIUngrabDevice, /* 52 */ - SProcXIAllowEvents, /* 53 */ - SProcXIPassiveGrabDevice, /* 54 */ - SProcXIPassiveUngrabDevice, /* 55 */ - SProcXIListProperties, /* 56 */ - SProcXIChangeProperty, /* 57 */ - SProcXIDeleteProperty, /* 58 */ - SProcXIGetProperty, /* 59 */ - SProcXIGetSelectedEvents /* 60 */ +static int (*SProcIVector[]) (ClientPtr) = { + NULL, /* 0 */ + SProcXGetExtensionVersion, /* 1 */ + SProcXListInputDevices, /* 2 */ + SProcXOpenDevice, /* 3 */ + SProcXCloseDevice, /* 4 */ + SProcXSetDeviceMode, /* 5 */ + SProcXSelectExtensionEvent, /* 6 */ + SProcXGetSelectedExtensionEvents, /* 7 */ + SProcXChangeDeviceDontPropagateList, /* 8 */ + SProcXGetDeviceDontPropagateList, /* 9 */ + SProcXGetDeviceMotionEvents, /* 10 */ + SProcXChangeKeyboardDevice, /* 11 */ + SProcXChangePointerDevice, /* 12 */ + SProcXGrabDevice, /* 13 */ + SProcXUngrabDevice, /* 14 */ + SProcXGrabDeviceKey, /* 15 */ + SProcXUngrabDeviceKey, /* 16 */ + SProcXGrabDeviceButton, /* 17 */ + SProcXUngrabDeviceButton, /* 18 */ + SProcXAllowDeviceEvents, /* 19 */ + SProcXGetDeviceFocus, /* 20 */ + SProcXSetDeviceFocus, /* 21 */ + SProcXGetFeedbackControl, /* 22 */ + SProcXChangeFeedbackControl, /* 23 */ + SProcXGetDeviceKeyMapping, /* 24 */ + SProcXChangeDeviceKeyMapping, /* 25 */ + SProcXGetDeviceModifierMapping, /* 26 */ + SProcXSetDeviceModifierMapping, /* 27 */ + SProcXGetDeviceButtonMapping, /* 28 */ + SProcXSetDeviceButtonMapping, /* 29 */ + SProcXQueryDeviceState, /* 30 */ + SProcXSendExtensionEvent, /* 31 */ + SProcXDeviceBell, /* 32 */ + SProcXSetDeviceValuators, /* 33 */ + SProcXGetDeviceControl, /* 34 */ + SProcXChangeDeviceControl, /* 35 */ + SProcXListDeviceProperties, /* 36 */ + SProcXChangeDeviceProperty, /* 37 */ + SProcXDeleteDeviceProperty, /* 38 */ + SProcXGetDeviceProperty, /* 39 */ + SProcXIQueryPointer, /* 40 */ + SProcXIWarpPointer, /* 41 */ + SProcXIChangeCursor, /* 42 */ + SProcXIChangeHierarchy, /* 43 */ + SProcXISetClientPointer, /* 44 */ + SProcXIGetClientPointer, /* 45 */ + SProcXISelectEvents, /* 46 */ + SProcXIQueryVersion, /* 47 */ + SProcXIQueryDevice, /* 48 */ + SProcXISetFocus, /* 49 */ + SProcXIGetFocus, /* 50 */ + SProcXIGrabDevice, /* 51 */ + SProcXIUngrabDevice, /* 52 */ + SProcXIAllowEvents, /* 53 */ + SProcXIPassiveGrabDevice, /* 54 */ + SProcXIPassiveUngrabDevice, /* 55 */ + SProcXIListProperties, /* 56 */ + SProcXIChangeProperty, /* 57 */ + SProcXIDeleteProperty, /* 58 */ + SProcXIGetProperty, /* 59 */ + SProcXIGetSelectedEvents /* 60 */ }; /***************************************************************** @@ -367,7 +365,6 @@ RESTYPE RT_INPUTCLIENT; extern XExtensionVersion XIVersion; - Mask PropagateMask[MAXDEVICES]; /***************************************************************** @@ -385,11 +382,9 @@ DevPrivateKeyRec XIClientPrivateKeyRec; */ static void -XIClientCallback(CallbackListPtr *list, - pointer closure, - pointer data) +XIClientCallback(CallbackListPtr *list, pointer closure, pointer data) { - NewClientInfoRec *clientinfo = (NewClientInfoRec*)data; + NewClientInfoRec *clientinfo = (NewClientInfoRec *) data; ClientPtr pClient = clientinfo->client; XIClientPtr pXIClient; @@ -412,7 +407,7 @@ ProcIDispatch(ClientPtr client) if (stuff->data >= ARRAY_SIZE(ProcIVector) || !ProcIVector[stuff->data]) return BadRequest; - return (*ProcIVector[stuff->data])(client); + return (*ProcIVector[stuff->data]) (client); } /******************************************************************************* @@ -431,7 +426,7 @@ SProcIDispatch(ClientPtr client) if (stuff->data >= ARRAY_SIZE(SProcIVector) || !SProcIVector[stuff->data]) return BadRequest; - return (*SProcIVector[stuff->data])(client); + return (*SProcIVector[stuff->data]) (client); } /********************************************************************** @@ -443,84 +438,85 @@ SProcIDispatch(ClientPtr client) static void SReplyIDispatch(ClientPtr client, int len, xGrabDeviceReply * rep) - /* All we look at is the type field */ -{ /* This is common to all replies */ + /* All we look at is the type field */ +{ /* This is common to all replies */ if (rep->RepType == X_GetExtensionVersion) - SRepXGetExtensionVersion(client, len, - (xGetExtensionVersionReply *) rep); + SRepXGetExtensionVersion(client, len, + (xGetExtensionVersionReply *) rep); else if (rep->RepType == X_ListInputDevices) - SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep); + SRepXListInputDevices(client, len, (xListInputDevicesReply *) rep); else if (rep->RepType == X_OpenDevice) - SRepXOpenDevice(client, len, (xOpenDeviceReply *) rep); + SRepXOpenDevice(client, len, (xOpenDeviceReply *) rep); else if (rep->RepType == X_SetDeviceMode) - SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep); + SRepXSetDeviceMode(client, len, (xSetDeviceModeReply *) rep); else if (rep->RepType == X_GetSelectedExtensionEvents) - SRepXGetSelectedExtensionEvents(client, len, - (xGetSelectedExtensionEventsReply *) - rep); + SRepXGetSelectedExtensionEvents(client, len, + (xGetSelectedExtensionEventsReply *) + rep); else if (rep->RepType == X_GetDeviceDontPropagateList) - SRepXGetDeviceDontPropagateList(client, len, - (xGetDeviceDontPropagateListReply *) - rep); + SRepXGetDeviceDontPropagateList(client, len, + (xGetDeviceDontPropagateListReply *) + rep); else if (rep->RepType == X_GetDeviceMotionEvents) - SRepXGetDeviceMotionEvents(client, len, - (xGetDeviceMotionEventsReply *) rep); + SRepXGetDeviceMotionEvents(client, len, + (xGetDeviceMotionEventsReply *) rep); else if (rep->RepType == X_GrabDevice) - SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep); + SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep); else if (rep->RepType == X_GetDeviceFocus) - SRepXGetDeviceFocus(client, len, (xGetDeviceFocusReply *) rep); + SRepXGetDeviceFocus(client, len, (xGetDeviceFocusReply *) rep); else if (rep->RepType == X_GetFeedbackControl) - SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep); + SRepXGetFeedbackControl(client, len, (xGetFeedbackControlReply *) rep); else if (rep->RepType == X_GetDeviceKeyMapping) - SRepXGetDeviceKeyMapping(client, len, - (xGetDeviceKeyMappingReply *) rep); + SRepXGetDeviceKeyMapping(client, len, + (xGetDeviceKeyMappingReply *) rep); else if (rep->RepType == X_GetDeviceModifierMapping) - SRepXGetDeviceModifierMapping(client, len, - (xGetDeviceModifierMappingReply *) rep); + SRepXGetDeviceModifierMapping(client, len, + (xGetDeviceModifierMappingReply *) rep); else if (rep->RepType == X_SetDeviceModifierMapping) - SRepXSetDeviceModifierMapping(client, len, - (xSetDeviceModifierMappingReply *) rep); + SRepXSetDeviceModifierMapping(client, len, + (xSetDeviceModifierMappingReply *) rep); else if (rep->RepType == X_GetDeviceButtonMapping) - SRepXGetDeviceButtonMapping(client, len, - (xGetDeviceButtonMappingReply *) rep); + SRepXGetDeviceButtonMapping(client, len, + (xGetDeviceButtonMappingReply *) rep); else if (rep->RepType == X_SetDeviceButtonMapping) - SRepXSetDeviceButtonMapping(client, len, - (xSetDeviceButtonMappingReply *) rep); + SRepXSetDeviceButtonMapping(client, len, + (xSetDeviceButtonMappingReply *) rep); else if (rep->RepType == X_QueryDeviceState) - SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep); + SRepXQueryDeviceState(client, len, (xQueryDeviceStateReply *) rep); else if (rep->RepType == X_SetDeviceValuators) - SRepXSetDeviceValuators(client, len, (xSetDeviceValuatorsReply *) rep); + SRepXSetDeviceValuators(client, len, (xSetDeviceValuatorsReply *) rep); else if (rep->RepType == X_GetDeviceControl) - SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep); + SRepXGetDeviceControl(client, len, (xGetDeviceControlReply *) rep); else if (rep->RepType == X_ChangeDeviceControl) - SRepXChangeDeviceControl(client, len, - (xChangeDeviceControlReply *) rep); + SRepXChangeDeviceControl(client, len, + (xChangeDeviceControlReply *) rep); else if (rep->RepType == X_ListDeviceProperties) - SRepXListDeviceProperties(client, len, (xListDevicePropertiesReply*)rep); + SRepXListDeviceProperties(client, len, + (xListDevicePropertiesReply *) rep); else if (rep->RepType == X_GetDeviceProperty) - SRepXGetDeviceProperty(client, len, (xGetDevicePropertyReply *) rep); + SRepXGetDeviceProperty(client, len, (xGetDevicePropertyReply *) rep); else if (rep->RepType == X_XIQueryPointer) - SRepXIQueryPointer(client, len, (xXIQueryPointerReply *) rep); + SRepXIQueryPointer(client, len, (xXIQueryPointerReply *) rep); else if (rep->RepType == X_XIGetClientPointer) - SRepXIGetClientPointer(client, len, (xXIGetClientPointerReply*) rep); + SRepXIGetClientPointer(client, len, (xXIGetClientPointerReply *) rep); else if (rep->RepType == X_XIQueryVersion) - SRepXIQueryVersion(client, len, (xXIQueryVersionReply*)rep); + SRepXIQueryVersion(client, len, (xXIQueryVersionReply *) rep); else if (rep->RepType == X_XIQueryDevice) - SRepXIQueryDevice(client, len, (xXIQueryDeviceReply*)rep); + SRepXIQueryDevice(client, len, (xXIQueryDeviceReply *) rep); else if (rep->RepType == X_XIGrabDevice) - SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep); + SRepXIGrabDevice(client, len, (xXIGrabDeviceReply *) rep); else if (rep->RepType == X_XIPassiveGrabDevice) - SRepXIPassiveGrabDevice(client, len, (xXIPassiveGrabDeviceReply *) rep); + SRepXIPassiveGrabDevice(client, len, (xXIPassiveGrabDeviceReply *) rep); else if (rep->RepType == X_XIListProperties) - SRepXIListProperties(client, len, (xXIListPropertiesReply *) rep); + SRepXIListProperties(client, len, (xXIListPropertiesReply *) rep); else if (rep->RepType == X_XIGetProperty) - SRepXIGetProperty(client, len, (xXIGetPropertyReply *) rep); + SRepXIGetProperty(client, len, (xXIGetPropertyReply *) rep); else if (rep->RepType == X_XIGetSelectedEvents) - SRepXIGetSelectedEvents(client, len, (xXIGetSelectedEventsReply *) rep); + SRepXIGetSelectedEvents(client, len, (xXIGetSelectedEventsReply *) rep); else if (rep->RepType == X_XIGetFocus) - SRepXIGetFocus(client, len, (xXIGetFocusReply *) rep); + SRepXIGetFocus(client, len, (xXIGetFocusReply *) rep); else { - FatalError("XINPUT confused sending swapped reply"); + FatalError("XINPUT confused sending swapped reply"); } } @@ -541,7 +537,7 @@ SEventDeviceValuator(deviceValuator * from, deviceValuator * to) swaps(&to->device_state); ip = &to->valuator0; for (i = 0; i < 6; i++) { - swapl(ip + i); + swapl(ip + i); } } @@ -565,13 +561,13 @@ SDeviceStateNotifyEvent(deviceStateNotify * from, deviceStateNotify * to) swapl(&to->time); ip = &to->valuator0; for (i = 0; i < 3; i++) { - swapl(ip + i); + swapl(ip + i); } } static void SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, - deviceKeyStateNotify * to) + deviceKeyStateNotify * to) { *to = *from; swaps(&to->sequenceNumber); @@ -579,7 +575,7 @@ SDeviceKeyStateNotifyEvent(deviceKeyStateNotify * from, static void SDeviceButtonStateNotifyEvent(deviceButtonStateNotify * from, - deviceButtonStateNotify * to) + deviceButtonStateNotify * to) { *to = *from; swaps(&to->sequenceNumber); @@ -602,7 +598,8 @@ SDeviceMappingNotifyEvent(deviceMappingNotify * from, deviceMappingNotify * to) } static void -SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to) +SDevicePresenceNotifyEvent(devicePresenceNotify * from, + devicePresenceNotify * to) { *to = *from; swaps(&to->sequenceNumber); @@ -611,7 +608,8 @@ SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to } static void -SDevicePropertyNotifyEvent (devicePropertyNotify *from, devicePropertyNotify *to) +SDevicePropertyNotifyEvent(devicePropertyNotify * from, + devicePropertyNotify * to) { *to = *from; swaps(&to->sequenceNumber); @@ -620,7 +618,7 @@ SDevicePropertyNotifyEvent (devicePropertyNotify *from, devicePropertyNotify *to } static void -SDeviceLeaveNotifyEvent (xXILeaveEvent *from, xXILeaveEvent *to) +SDeviceLeaveNotifyEvent(xXILeaveEvent * from, xXILeaveEvent * to) { *to = *from; swaps(&to->sequenceNumber); @@ -643,7 +641,7 @@ SDeviceLeaveNotifyEvent (xXILeaveEvent *from, xXILeaveEvent *to) } static void -SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to) +SDeviceChangedEvent(xXIDeviceChangedEvent * from, xXIDeviceChangedEvent * to) { int i, j; xXIAnyInfo *any; @@ -651,51 +649,52 @@ SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to) *to = *from; memcpy(&to[1], &from[1], from->length * 4); - any = (xXIAnyInfo*)&to[1]; - for (i = 0; i < to->num_classes; i++) - { + any = (xXIAnyInfo *) & to[1]; + for (i = 0; i < to->num_classes; i++) { int length = any->length; - switch(any->type) + switch (any->type) { + case KeyClass: + { + xXIKeyInfo *ki = (xXIKeyInfo *) any; + uint32_t *key = (uint32_t *) & ki[1]; + + for (j = 0; j < ki->num_keycodes; j++, key++) + swapl(key); + swaps(&ki->num_keycodes); + } + break; + case ButtonClass: + { + xXIButtonInfo *bi = (xXIButtonInfo *) any; + Atom *labels = (Atom *) ((char *) bi + sizeof(xXIButtonInfo) + + pad_to_int32(bits_to_bytes + (bi->num_buttons))); + for (j = 0; j < bi->num_buttons; j++) + swapl(&labels[j]); + swaps(&bi->num_buttons); + } + break; + case ValuatorClass: { - case KeyClass: - { - xXIKeyInfo *ki = (xXIKeyInfo*)any; - uint32_t *key = (uint32_t*)&ki[1]; - for (j = 0; j < ki->num_keycodes; j++, key++) - swapl(key); - swaps(&ki->num_keycodes); - } - break; - case ButtonClass: - { - xXIButtonInfo *bi = (xXIButtonInfo*)any; - Atom *labels = (Atom*)((char*)bi + sizeof(xXIButtonInfo) + - pad_to_int32(bits_to_bytes(bi->num_buttons))); - for (j = 0; j < bi->num_buttons; j++) - swapl(&labels[j]); - swaps(&bi->num_buttons); - } - break; - case ValuatorClass: - { - xXIValuatorInfo* ai = (xXIValuatorInfo*)any; - swapl(&ai->label); - swapl(&ai->min.integral); - swapl(&ai->min.frac); - swapl(&ai->max.integral); - swapl(&ai->max.frac); - swapl(&ai->resolution); - swaps(&ai->number); - } - break; + xXIValuatorInfo *ai = (xXIValuatorInfo *) any; + + swapl(&ai->label); + swapl(&ai->min.integral); + swapl(&ai->min.frac); + swapl(&ai->max.integral); + swapl(&ai->max.frac); + swapl(&ai->resolution); + swaps(&ai->number); + } + break; } swaps(&any->type); swaps(&any->length); swaps(&any->sourceid); - any = (xXIAnyInfo*)((char*)any + length * 4); + any = (xXIAnyInfo *) ((char *) any + length * 4); } swaps(&to->sequenceNumber); @@ -708,7 +707,8 @@ SDeviceChangedEvent(xXIDeviceChangedEvent* from, xXIDeviceChangedEvent* to) } -static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to) +static void +SDeviceEvent(xXIDeviceEvent * from, xXIDeviceEvent * to) { int i; char *ptr; @@ -738,24 +738,22 @@ static void SDeviceEvent(xXIDeviceEvent *from, xXIDeviceEvent *to) swapl(&to->mods.effective_mods); swapl(&to->flags); - ptr = (char*)(&to[1]); + ptr = (char *) (&to[1]); ptr += from->buttons_len * 4; - vmask = ptr; /* valuator mask */ + vmask = ptr; /* valuator mask */ ptr += from->valuators_len * 4; - for (i = 0; i < from->valuators_len * 32; i++) - { - if (BitIsOn(vmask, i)) - { - swapl(((uint32_t *)ptr)); + for (i = 0; i < from->valuators_len * 32; i++) { + if (BitIsOn(vmask, i)) { + swapl(((uint32_t *) ptr)); ptr += 4; - swapl(((uint32_t *)ptr)); + swapl(((uint32_t *) ptr)); ptr += 4; } } } -static void SDeviceHierarchyEvent(xXIHierarchyEvent *from, - xXIHierarchyEvent *to) +static void +SDeviceHierarchyEvent(xXIHierarchyEvent * from, xXIHierarchyEvent * to) { int i; xXIHierarchyInfo *info; @@ -770,16 +768,16 @@ static void SDeviceHierarchyEvent(xXIHierarchyEvent *from, swapl(&to->flags); swaps(&to->num_info); - info = (xXIHierarchyInfo*)&to[1]; - for (i = 0; i< from->num_info; i++) - { + info = (xXIHierarchyInfo *) & to[1]; + for (i = 0; i < from->num_info; i++) { swaps(&info->deviceid); swaps(&info->attachment); info++; } } -static void SXIPropertyEvent(xXIPropertyEvent *from, xXIPropertyEvent *to) +static void +SXIPropertyEvent(xXIPropertyEvent * from, xXIPropertyEvent * to) { *to = *from; swaps(&to->sequenceNumber); @@ -789,7 +787,8 @@ static void SXIPropertyEvent(xXIPropertyEvent *from, xXIPropertyEvent *to) swapl(&to->property); } -static void SRawEvent(xXIRawEvent *from, xXIRawEvent *to) +static void +SRawEvent(xXIRawEvent * from, xXIRawEvent * to) { int i; FP3232 *values; @@ -804,14 +803,11 @@ static void SRawEvent(xXIRawEvent *from, xXIRawEvent *to) swapl(&to->time); swapl(&to->detail); + mask = (unsigned char *) &to[1]; + values = (FP3232 *) (mask + from->valuators_len * 4); - mask = (unsigned char*)&to[1]; - values = (FP3232*)(mask + from->valuators_len * 4); - - for (i = 0; i < from->valuators_len * 4 * 8; i++) - { - if (BitIsOn(mask, i)) - { + for (i = 0; i < from->valuators_len * 4 * 8; i++) { + if (BitIsOn(mask, i)) { /* for each bit set there are two FP3232 values on the wire, in * the order abcABC for data and data_raw. Here we swap as if * they were in aAbBcC order because it's easier and really @@ -829,8 +825,8 @@ static void SRawEvent(xXIRawEvent *from, xXIRawEvent *to) swaps(&to->valuators_len); } -static void STouchOwnershipEvent(xXITouchOwnershipEvent *from, - xXITouchOwnershipEvent *to) +static void +STouchOwnershipEvent(xXITouchOwnershipEvent * from, xXITouchOwnershipEvent * to) { *to = *from; swaps(&to->sequenceNumber); @@ -850,52 +846,51 @@ static void STouchOwnershipEvent(xXITouchOwnershipEvent *from, void XI2EventSwap(xGenericEvent *from, xGenericEvent *to) { - switch(from->evtype) - { - case XI_Enter: - case XI_Leave: - case XI_FocusIn: - case XI_FocusOut: - SDeviceLeaveNotifyEvent((xXILeaveEvent*)from, (xXILeaveEvent*)to); - break; - case XI_DeviceChanged: - SDeviceChangedEvent((xXIDeviceChangedEvent*)from, - (xXIDeviceChangedEvent*)to); - break; - case XI_HierarchyChanged: - SDeviceHierarchyEvent((xXIHierarchyEvent*)from, (xXIHierarchyEvent*)to); - break; - case XI_PropertyEvent: - SXIPropertyEvent((xXIPropertyEvent*)from, - (xXIPropertyEvent*)to); - break; - case XI_Motion: - case XI_KeyPress: - case XI_KeyRelease: - case XI_ButtonPress: - case XI_ButtonRelease: - case XI_TouchBegin: - case XI_TouchUpdate: - case XI_TouchEnd: - SDeviceEvent((xXIDeviceEvent*)from, (xXIDeviceEvent*)to); - break; - case XI_TouchOwnership: - STouchOwnershipEvent((xXITouchOwnershipEvent*)from, - (xXITouchOwnershipEvent*)to); - break; - case XI_RawMotion: - case XI_RawKeyPress: - case XI_RawKeyRelease: - case XI_RawButtonPress: - case XI_RawButtonRelease: - case XI_RawTouchBegin: - case XI_RawTouchUpdate: - case XI_RawTouchEnd: - SRawEvent((xXIRawEvent*)from, (xXIRawEvent*)to); - break; - default: - ErrorF("[Xi] Unknown event type to swap. This is a bug.\n"); - break; + switch (from->evtype) { + case XI_Enter: + case XI_Leave: + case XI_FocusIn: + case XI_FocusOut: + SDeviceLeaveNotifyEvent((xXILeaveEvent *) from, (xXILeaveEvent *) to); + break; + case XI_DeviceChanged: + SDeviceChangedEvent((xXIDeviceChangedEvent *) from, + (xXIDeviceChangedEvent *) to); + break; + case XI_HierarchyChanged: + SDeviceHierarchyEvent((xXIHierarchyEvent *) from, + (xXIHierarchyEvent *) to); + break; + case XI_PropertyEvent: + SXIPropertyEvent((xXIPropertyEvent *) from, (xXIPropertyEvent *) to); + break; + case XI_Motion: + case XI_KeyPress: + case XI_KeyRelease: + case XI_ButtonPress: + case XI_ButtonRelease: + case XI_TouchBegin: + case XI_TouchUpdate: + case XI_TouchEnd: + SDeviceEvent((xXIDeviceEvent *) from, (xXIDeviceEvent *) to); + break; + case XI_TouchOwnership: + STouchOwnershipEvent((xXITouchOwnershipEvent *) from, + (xXITouchOwnershipEvent *) to); + break; + case XI_RawMotion: + case XI_RawKeyPress: + case XI_RawKeyRelease: + case XI_RawButtonPress: + case XI_RawButtonRelease: + case XI_RawTouchBegin: + case XI_RawTouchUpdate: + case XI_RawTouchEnd: + SRawEvent((xXIRawEvent *) from, (xXIRawEvent *) to); + break; + default: + ErrorF("[Xi] Unknown event type to swap. This is a bug.\n"); + break; } } @@ -912,7 +907,7 @@ AllowPropagateSuppress(Mask mask) int i; for (i = 0; i < MAXDEVICES; i++) - PropagateMask[i] |= mask; + PropagateMask[i] |= mask; } /************************************************************************** @@ -949,7 +944,7 @@ SetExclusiveAccess(Mask mask) int i; for (i = 0; i < MAXDEVICES; i++) - ExtExclusiveMasks[i] |= mask; + ExtExclusiveMasks[i] |= mask; } /************************************************************************** @@ -967,7 +962,7 @@ SetMaskForExtEvent(Mask mask, int event) EventInfo[ExtEventIndex++].type = event; if ((event < LASTEvent) || (event >= 128)) - FatalError("MaskForExtensionEvent: bogus event number"); + FatalError("MaskForExtensionEvent: bogus event number"); for (i = 0; i < MAXDEVICES; i++) SetMaskForEvent(i, mask, event); @@ -1078,13 +1073,12 @@ RestoreExtensionEvents(void) IEventBase = 0; for (i = 0; i < ExtEventIndex - 1; i++) { - if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128)) - { + if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128)) { for (j = 0; j < MAXDEVICES; j++) SetMaskForEvent(j, 0, EventInfo[i].type); } - EventInfo[i].mask = 0; - EventInfo[i].type = 0; + EventInfo[i].mask = 0; + EventInfo[i].type = 0; } ExtEventIndex = 0; DeviceValuator = 0; @@ -1145,7 +1139,6 @@ IResetProc(ExtensionEntry * unused) RestoreExtensionEvents(); } - /*********************************************************************** * * Assign an id and type to an input device. @@ -1171,8 +1164,8 @@ MakeDeviceTypeAtoms(void) int i; for (i = 0; i < NUMTYPES; i++) - dev_type[i].type = - MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1); + dev_type[i].type = + MakeAtom(dev_type[i].name, strlen(dev_type[i].name), 1); } /***************************************************************************** @@ -1184,53 +1177,60 @@ MakeDeviceTypeAtoms(void) #define DO_SWAP(func,type) func ((type *)from, (type *)to) static void -SEventIDispatch(xEvent * from, xEvent * to) +SEventIDispatch(xEvent *from, xEvent *to) { int type = from->u.u.type & 0177; if (type == DeviceValuator) - DO_SWAP(SEventDeviceValuator, deviceValuator); + DO_SWAP(SEventDeviceValuator, deviceValuator); else if (type == DeviceKeyPress) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceKeyRelease) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceButtonPress) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceButtonRelease) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceMotionNotify) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceFocusIn) - DO_SWAP(SEventFocus, deviceFocus); + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } + else if (type == DeviceKeyRelease) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } + else if (type == DeviceButtonPress) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } + else if (type == DeviceButtonRelease) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } + else if (type == DeviceMotionNotify) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } + else if (type == DeviceFocusIn) + DO_SWAP(SEventFocus, deviceFocus); else if (type == DeviceFocusOut) - DO_SWAP(SEventFocus, deviceFocus); + DO_SWAP(SEventFocus, deviceFocus); else if (type == ProximityIn) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == ProximityOut) { - SKeyButtonPtrEvent(from, to); - to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; - } else if (type == DeviceStateNotify) - DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } + else if (type == ProximityOut) { + SKeyButtonPtrEvent(from, to); + to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1; + } + else if (type == DeviceStateNotify) + DO_SWAP(SDeviceStateNotifyEvent, deviceStateNotify); else if (type == DeviceKeyStateNotify) - DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); + DO_SWAP(SDeviceKeyStateNotifyEvent, deviceKeyStateNotify); else if (type == DeviceButtonStateNotify) - DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); + DO_SWAP(SDeviceButtonStateNotifyEvent, deviceButtonStateNotify); else if (type == DeviceMappingNotify) - DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); + DO_SWAP(SDeviceMappingNotifyEvent, deviceMappingNotify); else if (type == ChangeDeviceNotify) - DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); + DO_SWAP(SChangeDeviceNotifyEvent, changeDeviceNotify); else if (type == DevicePresenceNotify) - DO_SWAP(SDevicePresenceNotifyEvent, devicePresenceNotify); + DO_SWAP(SDevicePresenceNotifyEvent, devicePresenceNotify); else if (type == DevicePropertyNotify) - DO_SWAP(SDevicePropertyNotifyEvent, devicePropertyNotify); + DO_SWAP(SDevicePropertyNotifyEvent, devicePropertyNotify); else { - FatalError("XInputExtension: Impossible event!\n"); + FatalError("XInputExtension: Impossible event!\n"); } } @@ -1250,63 +1250,64 @@ void XInputExtensionInit(void) { ExtensionEntry *extEntry; + XExtensionVersion thisversion = { XI_Present, SERVER_XI_MAJOR_VERSION, SERVER_XI_MINOR_VERSION, }; - if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec))) + if (!dixRegisterPrivateKey + (&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec))) FatalError("Cannot request private for XI.\n"); if (!AddCallback(&ClientStateCallback, XIClientCallback, 0)) FatalError("Failed to add callback to XI.\n"); extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, - SProcIDispatch, IResetProc, StandardMinorOpcode); + SProcIDispatch, IResetProc, StandardMinorOpcode); if (extEntry) { - IReqCode = extEntry->base; - IEventBase = extEntry->eventBase; - XIVersion = thisversion; - MakeDeviceTypeAtoms(); - RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone, - "INPUTCLIENT"); - if (!RT_INPUTCLIENT) - FatalError("Failed to add resource type for XI.\n"); - FixExtensionEvents(extEntry); - ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; - EventSwapVector[DeviceValuator] = SEventIDispatch; - EventSwapVector[DeviceKeyPress] = SEventIDispatch; - EventSwapVector[DeviceKeyRelease] = SEventIDispatch; - EventSwapVector[DeviceButtonPress] = SEventIDispatch; - EventSwapVector[DeviceButtonRelease] = SEventIDispatch; - EventSwapVector[DeviceMotionNotify] = SEventIDispatch; - EventSwapVector[DeviceFocusIn] = SEventIDispatch; - EventSwapVector[DeviceFocusOut] = SEventIDispatch; - EventSwapVector[ProximityIn] = SEventIDispatch; - EventSwapVector[ProximityOut] = SEventIDispatch; - EventSwapVector[DeviceStateNotify] = SEventIDispatch; - EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; - EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; - EventSwapVector[DeviceMappingNotify] = SEventIDispatch; - EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; - EventSwapVector[DevicePresenceNotify] = SEventIDispatch; - - GERegisterExtension(IReqCode, XI2EventSwap); - - - memset(&xi_all_devices, 0, sizeof(xi_all_devices)); - memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices)); - xi_all_devices.id = XIAllDevices; - xi_all_devices.name = "XIAllDevices"; - xi_all_master_devices.id = XIAllMasterDevices; - xi_all_master_devices.name = "XIAllMasterDevices"; - - inputInfo.all_devices = &xi_all_devices; - inputInfo.all_master_devices = &xi_all_master_devices; - - XIResetProperties(); - } else { - FatalError("IExtensionInit: AddExtensions failed\n"); + IReqCode = extEntry->base; + IEventBase = extEntry->eventBase; + XIVersion = thisversion; + MakeDeviceTypeAtoms(); + RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone, + "INPUTCLIENT"); + if (!RT_INPUTCLIENT) + FatalError("Failed to add resource type for XI.\n"); + FixExtensionEvents(extEntry); + ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; + EventSwapVector[DeviceValuator] = SEventIDispatch; + EventSwapVector[DeviceKeyPress] = SEventIDispatch; + EventSwapVector[DeviceKeyRelease] = SEventIDispatch; + EventSwapVector[DeviceButtonPress] = SEventIDispatch; + EventSwapVector[DeviceButtonRelease] = SEventIDispatch; + EventSwapVector[DeviceMotionNotify] = SEventIDispatch; + EventSwapVector[DeviceFocusIn] = SEventIDispatch; + EventSwapVector[DeviceFocusOut] = SEventIDispatch; + EventSwapVector[ProximityIn] = SEventIDispatch; + EventSwapVector[ProximityOut] = SEventIDispatch; + EventSwapVector[DeviceStateNotify] = SEventIDispatch; + EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; + EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; + EventSwapVector[DeviceMappingNotify] = SEventIDispatch; + EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; + EventSwapVector[DevicePresenceNotify] = SEventIDispatch; + + GERegisterExtension(IReqCode, XI2EventSwap); + + memset(&xi_all_devices, 0, sizeof(xi_all_devices)); + memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices)); + xi_all_devices.id = XIAllDevices; + xi_all_devices.name = "XIAllDevices"; + xi_all_master_devices.id = XIAllMasterDevices; + xi_all_master_devices.name = "XIAllMasterDevices"; + + inputInfo.all_devices = &xi_all_devices; + inputInfo.all_master_devices = &xi_all_master_devices; + + XIResetProperties(); + } + else { + FatalError("IExtensionInit: AddExtensions failed\n"); } } - diff --git a/xorg-server/Xi/getdctl.c b/xorg-server/Xi/getdctl.c index 6090b814a..4d66a4dfc 100644 --- a/xorg-server/Xi/getdctl.c +++ b/xorg-server/Xi/getdctl.c @@ -54,7 +54,7 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exglobals.h" @@ -86,7 +86,7 @@ SProcXGetDeviceControl(ClientPtr client) static void CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, - int length) + int length) { AxisInfoPtr a; xDeviceResolutionState *r; @@ -97,25 +97,26 @@ CopySwapDeviceResolution(ClientPtr client, ValuatorClassPtr v, char *buf, r->length = length; r->num_valuators = v->numAxes; buf += sizeof(xDeviceResolutionState); - iptr = (int *)buf; + iptr = (int *) buf; for (i = 0, a = v->axes; i < v->numAxes; i++, a++) - *iptr++ = a->resolution; + *iptr++ = a->resolution; for (i = 0, a = v->axes; i < v->numAxes; i++, a++) - *iptr++ = a->min_resolution; + *iptr++ = a->min_resolution; for (i = 0, a = v->axes; i < v->numAxes; i++, a++) - *iptr++ = a->max_resolution; + *iptr++ = a->max_resolution; if (client->swapped) { - swaps(&r->control); - swaps(&r->length); - swapl(&r->num_valuators); - iptr = (int *)buf; - for (i = 0; i < (3 * v->numAxes); i++, iptr++) { - swapl(iptr); - } + swaps(&r->control); + swaps(&r->length); + swapl(&r->num_valuators); + iptr = (int *) buf; + for (i = 0; i < (3 * v->numAxes); i++, iptr++) { + swapl(iptr); + } } } -static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) +static void +CopySwapDeviceCore(ClientPtr client, DeviceIntPtr dev, char *buf) { xDeviceCoreState *c = (xDeviceCoreState *) buf; @@ -130,7 +131,8 @@ static void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf) } } -static void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf) +static void +CopySwapDeviceEnable(ClientPtr client, DeviceIntPtr dev, char *buf) { xDeviceEnableState *e = (xDeviceEnableState *) buf; @@ -156,7 +158,7 @@ SRepXGetDeviceControl(ClientPtr client, int size, xGetDeviceControlReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } /*********************************************************************** @@ -178,7 +180,7 @@ ProcXGetDeviceControl(ClientPtr client) rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; rep.repType = X_Reply; rep.RepType = X_GetDeviceControl; @@ -187,11 +189,11 @@ ProcXGetDeviceControl(ClientPtr client) switch (stuff->control) { case DEVICE_RESOLUTION: - if (!dev->valuator) - return BadMatch; - total_length = sizeof(xDeviceResolutionState) + - (3 * sizeof(int) * dev->valuator->numAxes); - break; + if (!dev->valuator) + return BadMatch; + total_length = sizeof(xDeviceResolutionState) + + (3 * sizeof(int) * dev->valuator->numAxes); + break; case DEVICE_ABS_CALIB: case DEVICE_ABS_AREA: return BadMatch; @@ -202,18 +204,18 @@ ProcXGetDeviceControl(ClientPtr client) total_length = sizeof(xDeviceEnableState); break; default: - return BadValue; + return BadValue; } - buf = (char *)malloc(total_length); + buf = (char *) malloc(total_length); if (!buf) - return BadAlloc; + return BadAlloc; savbuf = buf; switch (stuff->control) { case DEVICE_RESOLUTION: - CopySwapDeviceResolution(client, dev->valuator, buf, total_length); - break; + CopySwapDeviceResolution(client, dev->valuator, buf, total_length); + break; case DEVICE_CORE: CopySwapDeviceCore(client, dev, buf); break; @@ -221,7 +223,7 @@ ProcXGetDeviceControl(ClientPtr client) CopySwapDeviceEnable(client, dev, buf); break; default: - break; + break; } rep.length = bytes_to_int32(total_length); diff --git a/xorg-server/Xi/getprop.c b/xorg-server/Xi/getprop.c index 11afd3784..b7b9e6b5a 100644 --- a/xorg-server/Xi/getprop.c +++ b/xorg-server/Xi/getprop.c @@ -54,8 +54,8 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structs */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structs */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exglobals.h" @@ -109,30 +109,29 @@ ProcXGetDeviceDontPropagateList(ClientPtr client) rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); if (rc != Success) - return rc; + return rc; if ((others = wOtherInputMasks(pWin)) != 0) { - for (i = 0; i < EMASKSIZE; i++) - ClassFromMask(NULL, others->dontPropagateMask[i], i, - &count, COUNT); - if (count) { - rep.count = count; - buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass)); - rep.length = bytes_to_int32(rep.count * sizeof(XEventClass)); - - tbuf = buf; - for (i = 0; i < EMASKSIZE; i++) - tbuf = ClassFromMask(tbuf, others->dontPropagateMask[i], i, - NULL, CREATE); - } + for (i = 0; i < EMASKSIZE; i++) + ClassFromMask(NULL, others->dontPropagateMask[i], i, &count, COUNT); + if (count) { + rep.count = count; + buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass)); + rep.length = bytes_to_int32(rep.count * sizeof(XEventClass)); + + tbuf = buf; + for (i = 0; i < EMASKSIZE; i++) + tbuf = ClassFromMask(tbuf, others->dontPropagateMask[i], i, + NULL, CREATE); + } } WriteReplyToClient(client, sizeof(xGetDeviceDontPropagateListReply), &rep); if (count) { - client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; - WriteSwappedDataToClient(client, count * sizeof(XEventClass), buf); - free(buf); + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; + WriteSwappedDataToClient(client, count * sizeof(XEventClass), buf); + free(buf); } return Success; } @@ -145,23 +144,23 @@ ProcXGetDeviceDontPropagateList(ClientPtr client) */ XEventClass - * ClassFromMask(XEventClass * buf, Mask mask, int maskndx, CARD16 * count, - int mode) + * ClassFromMask(XEventClass * buf, Mask mask, int maskndx, CARD16 *count, + int mode) { int i, j; int id = maskndx; Mask tmask = 0x80000000; for (i = 0; i < 32; i++, tmask >>= 1) - if (tmask & mask) { - for (j = 0; j < ExtEventIndex; j++) - if (EventInfo[j].mask == tmask) { - if (mode == COUNT) - (*count)++; - else - *buf++ = (id << 8) | EventInfo[j].type; - } - } + if (tmask & mask) { + for (j = 0; j < ExtEventIndex; j++) + if (EventInfo[j].mask == tmask) { + if (mode == COUNT) + (*count)++; + else + *buf++ = (id << 8) | EventInfo[j].type; + } + } return buf; } @@ -174,10 +173,10 @@ XEventClass void SRepXGetDeviceDontPropagateList(ClientPtr client, int size, - xGetDeviceDontPropagateListReply * rep) + xGetDeviceDontPropagateListReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); swaps(&rep->count); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/grabdev.c b/xorg-server/Xi/grabdev.c index 8fd114e60..c904a9707 100644 --- a/xorg-server/Xi/grabdev.c +++ b/xorg-server/Xi/grabdev.c @@ -54,12 +54,12 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exglobals.h" -#include "dixevents.h" /* GrabDevice */ +#include "dixevents.h" /* GrabDevice */ #include "grabdev.h" @@ -82,9 +82,10 @@ SProcXGrabDevice(ClientPtr client) swapl(&stuff->time); swaps(&stuff->event_count); - if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count) - return BadLength; - + if (stuff->length != + bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count) + return BadLength; + SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); return (ProcXGrabDevice(client)); @@ -108,8 +109,9 @@ ProcXGrabDevice(ClientPtr client) REQUEST(xGrabDeviceReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceReq); - if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count) - return BadLength; + if (stuff->length != + bytes_to_int32(sizeof(xGrabDeviceReq)) + stuff->event_count) + return BadLength; rep.repType = X_Reply; rep.RepType = X_GrabDevice; @@ -118,23 +120,22 @@ ProcXGrabDevice(ClientPtr client) rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); if (rc != Success) - return rc; + return rc; - if ((rc = CreateMaskFromList(client, (XEventClass *) & stuff[1], - stuff->event_count, tmp, dev, - X_GrabDevice)) != Success) - return rc; + if ((rc = CreateMaskFromList(client, (XEventClass *) &stuff[1], + stuff->event_count, tmp, dev, + X_GrabDevice)) != Success) + return rc; mask.xi = tmp[stuff->deviceid].mask; rc = GrabDevice(client, dev, stuff->other_devices_mode, stuff->this_device_mode, stuff->grabWindow, - stuff->ownerEvents, stuff->time, - &mask, XI, None, None, - &rep.status); + stuff->ownerEvents, stuff->time, + &mask, XI, None, None, &rep.status); if (rc != Success) - return rc; + return rc; WriteReplyToClient(client, sizeof(xGrabDeviceReply), &rep); return Success; @@ -166,34 +167,34 @@ ProcXGrabDevice(ClientPtr client) int CreateMaskFromList(ClientPtr client, XEventClass * list, int count, - struct tmask *mask, DeviceIntPtr dev, int req) + struct tmask *mask, DeviceIntPtr dev, int req) { int rc, i, j; int device; DeviceIntPtr tdev; for (i = 0; i < EMASKSIZE; i++) { - mask[i].mask = 0; - mask[i].dev = NULL; + mask[i].mask = 0; + mask[i].dev = NULL; } for (i = 0; i < count; i++, list++) { - device = *list >> 8; - if (device > 255) - return BadClass; - - rc = dixLookupDevice(&tdev, device, client, DixUseAccess); - if (rc != BadDevice && rc != Success) - return rc; - if (rc == BadDevice || (dev != NULL && tdev != dev)) - return BadClass; - - for (j = 0; j < ExtEventIndex; j++) - if (EventInfo[j].type == (*list & 0xff)) { - mask[device].mask |= EventInfo[j].mask; - mask[device].dev = (Pointer) tdev; - break; - } + device = *list >> 8; + if (device > 255) + return BadClass; + + rc = dixLookupDevice(&tdev, device, client, DixUseAccess); + if (rc != BadDevice && rc != Success) + return rc; + if (rc == BadDevice || (dev != NULL && tdev != dev)) + return BadClass; + + for (j = 0; j < ExtEventIndex; j++) + if (EventInfo[j].type == (*list & 0xff)) { + mask[device].mask |= EventInfo[j].mask; + mask[device].dev = (Pointer) tdev; + break; + } } return Success; } @@ -210,5 +211,5 @@ SRepXGrabDevice(ClientPtr client, int size, xGrabDeviceReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/grabdevb.c b/xorg-server/Xi/grabdevb.c index dda0da8bb..0f0e975a0 100644 --- a/xorg-server/Xi/grabdevb.c +++ b/xorg-server/Xi/grabdevb.c @@ -54,8 +54,8 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exevents.h" @@ -81,7 +81,7 @@ SProcXGrabDeviceButton(ClientPtr client) swaps(&stuff->modifiers); swaps(&stuff->event_count); REQUEST_FIXED_SIZE(xGrabDeviceButtonReq, - stuff->event_count * sizeof(CARD32)); + stuff->event_count * sizeof(CARD32)); SwapLongs((CARD32 *) (&stuff[1]), stuff->event_count); return (ProcXGrabDeviceButton(client)); @@ -108,33 +108,34 @@ ProcXGrabDeviceButton(ClientPtr client) REQUEST_AT_LEAST_SIZE(xGrabDeviceButtonReq); if (stuff->length != - bytes_to_int32(sizeof(xGrabDeviceButtonReq)) + stuff->event_count) - return BadLength; + bytes_to_int32(sizeof(xGrabDeviceButtonReq)) + stuff->event_count) + return BadLength; ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess); if (ret != Success) - return ret; + return ret; if (stuff->modifier_device != UseXKeyboard) { - ret = dixLookupDevice(&mdev, stuff->modifier_device, client, - DixUseAccess); - if (ret != Success) - return ret; - if (mdev->key == NULL) - return BadMatch; - } else { - mdev = PickKeyboard(client); - ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess); - if (ret != Success) - return ret; + ret = dixLookupDevice(&mdev, stuff->modifier_device, client, + DixUseAccess); + if (ret != Success) + return ret; + if (mdev->key == NULL) + return BadMatch; + } + else { + mdev = PickKeyboard(client); + ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess); + if (ret != Success) + return ret; } - class = (XEventClass *) (&stuff[1]); /* first word of values */ + class = (XEventClass *) (&stuff[1]); /* first word of values */ if ((ret = CreateMaskFromList(client, class, - stuff->event_count, tmp, dev, - X_GrabDeviceButton)) != Success) - return ret; + stuff->event_count, tmp, dev, + X_GrabDeviceButton)) != Success) + return ret; memset(¶m, 0, sizeof(param)); param.grabtype = XI; @@ -145,8 +146,7 @@ ProcXGrabDeviceButton(ClientPtr client) param.modifiers = stuff->modifiers; mask.xi = tmp[stuff->grabbed_device].mask; - ret = GrabButton(client, dev, mdev, stuff->button, ¶m, - XI, &mask); + ret = GrabButton(client, dev, mdev, stuff->button, ¶m, XI, &mask); return ret; } diff --git a/xorg-server/Xi/grabdevk.c b/xorg-server/Xi/grabdevk.c index 61ab43a20..b75518211 100644 --- a/xorg-server/Xi/grabdevk.c +++ b/xorg-server/Xi/grabdevk.c @@ -54,8 +54,8 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exevents.h" @@ -105,34 +105,35 @@ ProcXGrabDeviceKey(ClientPtr client) REQUEST(xGrabDeviceKeyReq); REQUEST_AT_LEAST_SIZE(xGrabDeviceKeyReq); - if (stuff->length != bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count) - return BadLength; + if (stuff->length != + bytes_to_int32(sizeof(xGrabDeviceKeyReq)) + stuff->event_count) + return BadLength; ret = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess); if (ret != Success) - return ret; + return ret; if (stuff->modifier_device != UseXKeyboard) { - ret = dixLookupDevice(&mdev, stuff->modifier_device, client, - DixUseAccess); - if (ret != Success) - return ret; - if (mdev->key == NULL) - return BadMatch; - } else { - mdev = PickKeyboard(client); - ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess); - if (ret != Success) - return ret; + ret = dixLookupDevice(&mdev, stuff->modifier_device, client, + DixUseAccess); + if (ret != Success) + return ret; + if (mdev->key == NULL) + return BadMatch; + } + else { + mdev = PickKeyboard(client); + ret = XaceHook(XACE_DEVICE_ACCESS, client, mdev, DixUseAccess); + if (ret != Success) + return ret; } - class = (XEventClass *) (&stuff[1]); /* first word of values */ + class = (XEventClass *) (&stuff[1]); /* first word of values */ if ((ret = CreateMaskFromList(client, class, - stuff->event_count, tmp, dev, - X_GrabDeviceKey)) != Success) - return ret; - + stuff->event_count, tmp, dev, + X_GrabDeviceKey)) != Success) + return ret; memset(¶m, 0, sizeof(param)); param.grabtype = XI; diff --git a/xorg-server/Xi/listdev.c b/xorg-server/Xi/listdev.c index 1b3081d96..a02112f32 100644 --- a/xorg-server/Xi/listdev.c +++ b/xorg-server/Xi/listdev.c @@ -54,9 +54,9 @@ SOFTWARE. #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "XIstubs.h" @@ -68,7 +68,6 @@ SOFTWARE. #include "listdev.h" - /*********************************************************************** * * This procedure lists the input devices available to the server. @@ -97,15 +96,15 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) *namesize += 1; if (d->name) - *namesize += strlen(d->name); + *namesize += strlen(d->name); if (d->key != NULL) - *size += sizeof(xKeyInfo); + *size += sizeof(xKeyInfo); if (d->button != NULL) - *size += sizeof(xButtonInfo); + *size += sizeof(xButtonInfo); if (d->valuator != NULL) { - chunks = ((int)d->valuator->numAxes + 19) / VPC; - *size += (chunks * sizeof(xValuatorInfo) + - d->valuator->numAxes * sizeof(xAxisInfo)); + chunks = ((int) d->valuator->numAxes + 19) / VPC; + *size += (chunks * sizeof(xValuatorInfo) + + d->valuator->numAxes * sizeof(xAxisInfo)); } } @@ -122,15 +121,16 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) static void CopyDeviceName(char **namebuf, char *name) { - char *nameptr = (char *)*namebuf; + char *nameptr = (char *) *namebuf; if (name) { - *nameptr++ = strlen(name); - strcpy(nameptr, name); - *namebuf += (strlen(name) + 1); - } else { - *nameptr++ = 0; - *namebuf += 1; + *nameptr++ = strlen(name); + strcpy(nameptr, name); + *namebuf += (strlen(name) + 1); + } + else { + *nameptr++ = 0; + *namebuf += 1; } } @@ -150,7 +150,7 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf) b2->length = sizeof(xButtonInfo); b2->num_buttons = b->numButtons; if (client && client->swapped) { - swaps(&b2->num_buttons); + swaps(&b2->num_buttons); } *buf += sizeof(xButtonInfo); } @@ -162,8 +162,7 @@ CopySwapButtonClass(ClientPtr client, ButtonClassPtr b, char **buf) */ static void -CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, - char **buf) +CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, char **buf) { xDeviceInfoPtr dev; @@ -173,18 +172,18 @@ CopySwapDevice(ClientPtr client, DeviceIntPtr d, int num_classes, dev->type = d->xinput_type; dev->num_classes = num_classes; if (IsMaster(d) && IsKeyboardDevice(d)) - dev->use = IsXKeyboard; + dev->use = IsXKeyboard; else if (IsMaster(d) && IsPointerDevice(d)) - dev->use = IsXPointer; + dev->use = IsXPointer; else if (d->valuator && d->button) dev->use = IsXExtensionPointer; else if (d->key && d->kbdfeed) dev->use = IsXExtensionKeyboard; else - dev->use = IsXExtensionDevice; + dev->use = IsXExtensionDevice; if (client->swapped) { - swapl(&dev->type); + swapl(&dev->type); } *buf += sizeof(xDeviceInfo); } @@ -207,7 +206,7 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf) k2->max_keycode = k->xkbInfo->desc->max_key_code; k2->num_keys = k2->max_keycode - k2->min_keycode + 1; if (client && client->swapped) { - swaps(&k2->num_keys); + swaps(&k2->num_keys); } *buf += sizeof(xKeyInfo); } @@ -234,54 +233,53 @@ CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf) xAxisInfoPtr a2; for (i = 0, axes = v->numAxes; i < ((v->numAxes + 19) / VPC); - i++, axes -= VPC) { - t_axes = axes < VPC ? axes : VPC; - if (t_axes < 0) - t_axes = v->numAxes % VPC; - v2 = (xValuatorInfoPtr) * buf; - v2->class = ValuatorClass; - v2->length = sizeof(xValuatorInfo) + t_axes * sizeof(xAxisInfo); - v2->num_axes = t_axes; - v2->mode = valuator_get_mode(dev, 0); - v2->motion_buffer_size = v->numMotionEvents; - if (client && client->swapped) { - swapl(&v2->motion_buffer_size); - } - *buf += sizeof(xValuatorInfo); - a = v->axes + (VPC * i); - a2 = (xAxisInfoPtr) * buf; - for (j = 0; j < t_axes; j++) { - a2->min_value = a->min_value; - a2->max_value = a->max_value; - a2->resolution = a->resolution; - if (client && client->swapped) { - swapl(&a2->min_value); - swapl(&a2->max_value); - swapl(&a2->resolution); - } - a2++; - a++; - *buf += sizeof(xAxisInfo); - } + i++, axes -= VPC) { + t_axes = axes < VPC ? axes : VPC; + if (t_axes < 0) + t_axes = v->numAxes % VPC; + v2 = (xValuatorInfoPtr) * buf; + v2->class = ValuatorClass; + v2->length = sizeof(xValuatorInfo) + t_axes * sizeof(xAxisInfo); + v2->num_axes = t_axes; + v2->mode = valuator_get_mode(dev, 0); + v2->motion_buffer_size = v->numMotionEvents; + if (client && client->swapped) { + swapl(&v2->motion_buffer_size); + } + *buf += sizeof(xValuatorInfo); + a = v->axes + (VPC * i); + a2 = (xAxisInfoPtr) * buf; + for (j = 0; j < t_axes; j++) { + a2->min_value = a->min_value; + a2->max_value = a->max_value; + a2->resolution = a->resolution; + if (client && client->swapped) { + swapl(&a2->min_value); + swapl(&a2->max_value); + swapl(&a2->resolution); + } + a2++; + a++; + *buf += sizeof(xAxisInfo); + } } return i; } static void CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes, - char** classbuf) + char **classbuf) { if (dev->key != NULL) { - CopySwapKeyClass(client, dev->key, classbuf); - (*num_classes)++; + CopySwapKeyClass(client, dev->key, classbuf); + (*num_classes)++; } if (dev->button != NULL) { - CopySwapButtonClass(client, dev->button, classbuf); - (*num_classes)++; + CopySwapButtonClass(client, dev->button, classbuf); + (*num_classes)++; } if (dev->valuator != NULL) { - (*num_classes) += - CopySwapValuatorClass(client, dev, classbuf); + (*num_classes) += CopySwapValuatorClass(client, dev, classbuf); } } @@ -293,7 +291,7 @@ CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes, static void ListDeviceInfo(ClientPtr client, DeviceIntPtr d, xDeviceInfoPtr dev, - char **devbuf, char **classbuf, char **namebuf) + char **devbuf, char **classbuf, char **namebuf) { CopyDeviceName(namebuf, d->name); CopySwapDevice(client, d, 0, devbuf); @@ -310,16 +308,15 @@ static Bool ShouldSkipDevice(ClientPtr client, DeviceIntPtr d) { /* don't send master devices other than VCP/VCK */ - if (!IsMaster(d) || d == inputInfo.pointer || d == inputInfo.keyboard) - { + if (!IsMaster(d) || d == inputInfo.pointer ||d == inputInfo.keyboard) { int rc = XaceHook(XACE_DEVICE_ACCESS, client, d, DixGetAttrAccess); + if (rc == Success) return FALSE; } return TRUE; } - /*********************************************************************** * * This procedure lists the input devices available to the server. @@ -335,7 +332,7 @@ ProcXListInputDevices(ClientPtr client) { xListInputDevicesReply rep; int numdevs = 0; - int namesize = 1; /* need 1 extra byte for strcpy */ + int namesize = 1; /* need 1 extra byte for strcpy */ int i = 0, size = 0; int total_length; char *devbuf, *classbuf, *namebuf, *savbuf; @@ -378,7 +375,7 @@ ProcXListInputDevices(ClientPtr client) /* allocate space for reply */ total_length = numdevs * sizeof(xDeviceInfo) + size + namesize; - devbuf = (char *)calloc(1, total_length); + devbuf = (char *) calloc(1, total_length); classbuf = devbuf + (numdevs * sizeof(xDeviceInfo)); namebuf = classbuf + size; savbuf = devbuf; @@ -420,5 +417,5 @@ SRepXListInputDevices(ClientPtr client, int size, xListInputDevicesReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/opendev.c b/xorg-server/Xi/opendev.c index ba0d30436..e7c00a236 100644 --- a/xorg-server/Xi/opendev.c +++ b/xorg-server/Xi/opendev.c @@ -54,11 +54,11 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "XIstubs.h" -#include "windowstr.h" /* window structure */ +#include "windowstr.h" /* window structure */ #include "exglobals.h" #include "exevents.h" @@ -102,55 +102,56 @@ ProcXOpenDevice(ClientPtr client) status = dixLookupDevice(&dev, stuff->deviceid, client, DixUseAccess); if (status == BadDevice) { /* not open */ - for (dev = inputInfo.off_devices; dev; dev = dev->next) - if (dev->id == stuff->deviceid) - break; - if (dev == NULL) - return BadDevice; - } else if (status != Success) - return status; + for (dev = inputInfo.off_devices; dev; dev = dev->next) + if (dev->id == stuff->deviceid) + break; + if (dev == NULL) + return BadDevice; + } + else if (status != Success) + return status; if (IsMaster(dev)) - return BadDevice; + return BadDevice; if (status != Success) - return status; + return status; memset(&rep, 0, sizeof(xOpenDeviceReply)); rep.repType = X_Reply; rep.RepType = X_OpenDevice; rep.sequenceNumber = client->sequence; if (dev->key != NULL) { - evbase[j].class = KeyClass; - evbase[j++].event_type_base = event_base[KeyClass]; + evbase[j].class = KeyClass; + evbase[j++].event_type_base = event_base[KeyClass]; } if (dev->button != NULL) { - evbase[j].class = ButtonClass; - evbase[j++].event_type_base = event_base[ButtonClass]; + evbase[j].class = ButtonClass; + evbase[j++].event_type_base = event_base[ButtonClass]; } if (dev->valuator != NULL) { - evbase[j].class = ValuatorClass; - evbase[j++].event_type_base = event_base[ValuatorClass]; + evbase[j].class = ValuatorClass; + evbase[j++].event_type_base = event_base[ValuatorClass]; } if (dev->kbdfeed != NULL || dev->ptrfeed != NULL || dev->leds != NULL || - dev->intfeed != NULL || dev->bell != NULL || dev->stringfeed != NULL) { - evbase[j].class = FeedbackClass; - evbase[j++].event_type_base = event_base[FeedbackClass]; + dev->intfeed != NULL || dev->bell != NULL || dev->stringfeed != NULL) { + evbase[j].class = FeedbackClass; + evbase[j++].event_type_base = event_base[FeedbackClass]; } if (dev->focus != NULL) { - evbase[j].class = FocusClass; - evbase[j++].event_type_base = event_base[FocusClass]; + evbase[j].class = FocusClass; + evbase[j++].event_type_base = event_base[FocusClass]; } if (dev->proximity != NULL) { - evbase[j].class = ProximityClass; - evbase[j++].event_type_base = event_base[ProximityClass]; + evbase[j].class = ProximityClass; + evbase[j++].event_type_base = event_base[ProximityClass]; } evbase[j].class = OtherClass; evbase[j++].event_type_base = event_base[OtherClass]; rep.length = bytes_to_int32(j * sizeof(xInputClassInfo)); rep.num_classes = j; WriteReplyToClient(client, sizeof(xOpenDeviceReply), &rep); - WriteToClient(client, j * sizeof(xInputClassInfo), (char *)evbase); + WriteToClient(client, j * sizeof(xInputClassInfo), (char *) evbase); return Success; } @@ -166,5 +167,5 @@ SRepXOpenDevice(ClientPtr client, int size, xOpenDeviceReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/queryst.c b/xorg-server/Xi/queryst.c index 8c3bdcf97..ffb6de04a 100644 --- a/xorg-server/Xi/queryst.c +++ b/xorg-server/Xi/queryst.c @@ -36,8 +36,8 @@ from The Open Group. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exevents.h" @@ -94,79 +94,80 @@ ProcXQueryDeviceState(ClientPtr client) rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess); if (rc != Success && rc != BadAccess) - return rc; + return rc; v = dev->valuator; if (v != NULL && v->motionHintWindow != NULL) - MaybeStopDeviceHint(dev, client); + MaybeStopDeviceHint(dev, client); k = dev->key; if (k != NULL) { - total_length += sizeof(xKeyState); - num_classes++; + total_length += sizeof(xKeyState); + num_classes++; } b = dev->button; if (b != NULL) { - total_length += sizeof(xButtonState); - num_classes++; + total_length += sizeof(xButtonState); + num_classes++; } if (v != NULL) { - total_length += (sizeof(xValuatorState) + (v->numAxes * sizeof(int))); - num_classes++; + total_length += (sizeof(xValuatorState) + (v->numAxes * sizeof(int))); + num_classes++; } - buf = (char *)calloc(total_length, 1); + buf = (char *) calloc(total_length, 1); if (!buf) - return BadAlloc; + return BadAlloc; savbuf = buf; if (k != NULL) { - tk = (xKeyState *) buf; - tk->class = KeyClass; - tk->length = sizeof(xKeyState); - tk->num_keys = k->xkbInfo->desc->max_key_code - - k->xkbInfo->desc->min_key_code + 1; - if (rc != BadAccess) - for (i = 0; i < 32; i++) - tk->keys[i] = k->down[i]; - buf += sizeof(xKeyState); + tk = (xKeyState *) buf; + tk->class = KeyClass; + tk->length = sizeof(xKeyState); + tk->num_keys = k->xkbInfo->desc->max_key_code - + k->xkbInfo->desc->min_key_code + 1; + if (rc != BadAccess) + for (i = 0; i < 32; i++) + tk->keys[i] = k->down[i]; + buf += sizeof(xKeyState); } if (b != NULL) { - tb = (xButtonState *) buf; - tb->class = ButtonClass; - tb->length = sizeof(xButtonState); - tb->num_buttons = b->numButtons; - if (rc != BadAccess) - memcpy(tb->buttons, b->down, sizeof(b->down)); - buf += sizeof(xButtonState); + tb = (xButtonState *) buf; + tb->class = ButtonClass; + tb->length = sizeof(xButtonState); + tb->num_buttons = b->numButtons; + if (rc != BadAccess) + memcpy(tb->buttons, b->down, sizeof(b->down)); + buf += sizeof(xButtonState); } if (v != NULL) { - tv = (xValuatorState *) buf; - tv->class = ValuatorClass; - tv->length = sizeof(xValuatorState) + v->numAxes * 4; - tv->num_valuators = v->numAxes; - tv->mode = valuator_get_mode(dev, 0); - tv->mode |= (dev->proximity && !dev->proximity->in_proximity) ? OutOfProximity : 0; - buf += sizeof(xValuatorState); - for (i = 0, values = v->axisVal; i < v->numAxes; i++) { - if (rc != BadAccess) - *((int *)buf) = *values; - values++; - if (client->swapped) { - swapl((int *)buf); - } - buf += sizeof(int); - } + tv = (xValuatorState *) buf; + tv->class = ValuatorClass; + tv->length = sizeof(xValuatorState) + v->numAxes * 4; + tv->num_valuators = v->numAxes; + tv->mode = valuator_get_mode(dev, 0); + tv->mode |= (dev->proximity && + !dev->proximity->in_proximity) ? OutOfProximity : 0; + buf += sizeof(xValuatorState); + for (i = 0, values = v->axisVal; i < v->numAxes; i++) { + if (rc != BadAccess) + *((int *) buf) = *values; + values++; + if (client->swapped) { + swapl((int *) buf); + } + buf += sizeof(int); + } } rep.num_classes = num_classes; rep.length = bytes_to_int32(total_length); WriteReplyToClient(client, sizeof(xQueryDeviceStateReply), &rep); if (total_length > 0) - WriteToClient(client, total_length, savbuf); + WriteToClient(client, total_length, savbuf); free(savbuf); return Success; } @@ -183,5 +184,5 @@ SRepXQueryDeviceState(ClientPtr client, int size, xQueryDeviceStateReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/selectev.c b/xorg-server/Xi/selectev.c index 4c2c2fe05..284bd29e5 100644 --- a/xorg-server/Xi/selectev.c +++ b/xorg-server/Xi/selectev.c @@ -50,13 +50,12 @@ SOFTWARE. * */ - #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2.h> #include <X11/extensions/XIproto.h> @@ -70,7 +69,7 @@ extern Mask ExtExclusiveMasks[]; static int HandleDevicePresenceMask(ClientPtr client, WindowPtr win, - XEventClass *cls, CARD16 *count) + XEventClass * cls, CARD16 *count) { int i, j; Mask mask; @@ -106,7 +105,7 @@ HandleDevicePresenceMask(ClientPtr client, WindowPtr win, /* We always only use mksidx = AllDevices for events not bound to * devices */ - if (AddExtensionClient (win, client, mask, XIAllDevices) != Success) + if (AddExtensionClient(win, client, mask, XIAllDevices) != Success) return BadAlloc; RecalculateDeviceDeliverableEvents(win); @@ -128,8 +127,7 @@ SProcXSelectExtensionEvent(ClientPtr client) REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq); swapl(&stuff->window); swaps(&stuff->count); - REQUEST_FIXED_SIZE(xSelectExtensionEventReq, - stuff->count * sizeof(CARD32)); + REQUEST_FIXED_SIZE(xSelectExtensionEventReq, stuff->count * sizeof(CARD32)); SwapLongs((CARD32 *) (&stuff[1]), stuff->count); return (ProcXSelectExtensionEvent(client)); @@ -152,33 +150,34 @@ ProcXSelectExtensionEvent(ClientPtr client) REQUEST(xSelectExtensionEventReq); REQUEST_AT_LEAST_SIZE(xSelectExtensionEventReq); - if (stuff->length != bytes_to_int32(sizeof(xSelectExtensionEventReq)) + stuff->count) - return BadLength; + if (stuff->length != + bytes_to_int32(sizeof(xSelectExtensionEventReq)) + stuff->count) + return BadLength; ret = dixLookupWindow(&pWin, stuff->window, client, DixReceiveAccess); if (ret != Success) - return ret; + return ret; - if (HandleDevicePresenceMask(client, pWin, (XEventClass *) & stuff[1], - &stuff->count) != Success) - return BadAlloc; + if (HandleDevicePresenceMask(client, pWin, (XEventClass *) &stuff[1], + &stuff->count) != Success) + return BadAlloc; - if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1], - stuff->count, tmp, NULL, - X_SelectExtensionEvent)) != Success) - return ret; + if ((ret = CreateMaskFromList(client, (XEventClass *) &stuff[1], + stuff->count, tmp, NULL, + X_SelectExtensionEvent)) != Success) + return ret; for (i = 0; i < EMASKSIZE; i++) - if (tmp[i].dev != NULL) { + if (tmp[i].dev != NULL) { if (tmp[i].mask & ~XIAllMasks) { client->errorValue = tmp[i].mask; return BadValue; } - if ((ret = - SelectForWindow((DeviceIntPtr) tmp[i].dev, pWin, client, - tmp[i].mask, ExtExclusiveMasks[i]))!= Success) - return ret; - } + if ((ret = + SelectForWindow((DeviceIntPtr) tmp[i].dev, pWin, client, + tmp[i].mask, ExtExclusiveMasks[i])) != Success) + return ret; + } return Success; } diff --git a/xorg-server/Xi/sendexev.c b/xorg-server/Xi/sendexev.c index 4770c28d1..3c213864b 100644 --- a/xorg-server/Xi/sendexev.c +++ b/xorg-server/Xi/sendexev.c @@ -54,9 +54,9 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* Window */ -#include "extnsionst.h" /* EventSwapPtr */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* Window */ +#include "extnsionst.h" /* EventSwapPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exevents.h" @@ -65,7 +65,7 @@ SOFTWARE. #include "grabdev.h" #include "sendexev.h" -extern int lastEvent; /* Defined in extension.c */ +extern int lastEvent; /* Defined in extension.c */ /*********************************************************************** * @@ -88,20 +88,21 @@ SProcXSendExtensionEvent(ClientPtr client) swapl(&stuff->destination); swaps(&stuff->count); - if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + - bytes_to_int32(stuff->num_events * sizeof(xEvent))) - return BadLength; + if (stuff->length != + bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + + bytes_to_int32(stuff->num_events * sizeof(xEvent))) + return BadLength; - eventP = (xEvent *) & stuff[1]; + eventP = (xEvent *) &stuff[1]; for (i = 0; i < stuff->num_events; i++, eventP++) { - proc = EventSwapVector[eventP->u.u.type & 0177]; - if (proc == NotImplemented) /* no swapping proc; invalid event type? */ - return BadValue; - (*proc) (eventP, &eventT); - *eventP = eventT; + proc = EventSwapVector[eventP->u.u.type & 0177]; + if (proc == NotImplemented) /* no swapping proc; invalid event type? */ + return BadValue; + (*proc) (eventP, &eventT); + *eventP = eventT; } - p = (CARD32 *)(((xEvent *) & stuff[1]) + stuff->num_events); + p = (CARD32 *) (((xEvent *) &stuff[1]) + stuff->num_events); SwapLongs(p, stuff->count); return (ProcXSendExtensionEvent(client)); } @@ -125,31 +126,32 @@ ProcXSendExtensionEvent(ClientPtr client) REQUEST(xSendExtensionEventReq); REQUEST_AT_LEAST_SIZE(xSendExtensionEventReq); - if (stuff->length != bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + - (stuff->num_events * bytes_to_int32(sizeof(xEvent)))) - return BadLength; + if (stuff->length != + bytes_to_int32(sizeof(xSendExtensionEventReq)) + stuff->count + + (stuff->num_events * bytes_to_int32(sizeof(xEvent)))) + return BadLength; ret = dixLookupDevice(&dev, stuff->deviceid, client, DixWriteAccess); if (ret != Success) - return ret; + return ret; /* The client's event type must be one defined by an extension. */ - first = ((xEvent *) & stuff[1]); + first = ((xEvent *) &stuff[1]); if (!((EXTENSION_EVENT_BASE <= first->u.u.type) && - (first->u.u.type < lastEvent))) { - client->errorValue = first->u.u.type; - return BadValue; + (first->u.u.type < lastEvent))) { + client->errorValue = first->u.u.type; + return BadValue; } list = (XEventClass *) (first + stuff->num_events); if ((ret = CreateMaskFromList(client, list, stuff->count, tmp, dev, - X_SendExtensionEvent)) != Success) - return ret; + X_SendExtensionEvent)) != Success) + return ret; ret = (SendEvent(client, dev, stuff->destination, - stuff->propagate, (xEvent *) & stuff[1], - tmp[stuff->deviceid].mask, stuff->num_events)); + stuff->propagate, (xEvent *) &stuff[1], + tmp[stuff->deviceid].mask, stuff->num_events)); return ret; } diff --git a/xorg-server/Xi/setbmap.c b/xorg-server/Xi/setbmap.c index 2a8f5d3b7..110f5e91e 100644 --- a/xorg-server/Xi/setbmap.c +++ b/xorg-server/Xi/setbmap.c @@ -54,7 +54,7 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exevents.h" @@ -94,7 +94,7 @@ ProcXSetDeviceButtonMapping(ClientPtr client) if (stuff->length != bytes_to_int32(sizeof(xSetDeviceButtonMappingReq) + stuff->map_length)) - return BadLength; + return BadLength; ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); if (ret != Success) @@ -106,7 +106,9 @@ ProcXSetDeviceButtonMapping(ClientPtr client) rep.sequenceNumber = client->sequence; rep.status = MappingSuccess; - ret = ApplyPointerMapping(dev, (CARD8 *) &stuff[1], stuff->map_length, client); + ret = + ApplyPointerMapping(dev, (CARD8 *) &stuff[1], stuff->map_length, + client); if (ret == -1) return BadValue; else if (ret == MappingBusy) @@ -128,9 +130,9 @@ ProcXSetDeviceButtonMapping(ClientPtr client) void SRepXSetDeviceButtonMapping(ClientPtr client, int size, - xSetDeviceButtonMappingReply * rep) + xSetDeviceButtonMappingReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/setmode.c b/xorg-server/Xi/setmode.c index 80ee764b0..a7bf1eaff 100644 --- a/xorg-server/Xi/setmode.c +++ b/xorg-server/Xi/setmode.c @@ -54,7 +54,7 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ +#include "inputstr.h" /* DeviceIntPtr */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "XIstubs.h" @@ -99,27 +99,26 @@ ProcXSetDeviceMode(ClientPtr client) rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetAttrAccess); if (rc != Success) - return rc; + return rc; if (dev->valuator == NULL) - return BadMatch; + return BadMatch; if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) - rep.status = AlreadyGrabbed; + rep.status = AlreadyGrabbed; else - rep.status = SetDeviceMode(client, dev, stuff->mode); + rep.status = SetDeviceMode(client, dev, stuff->mode); if (rep.status == Success) valuator_set_mode(dev, VALUATOR_MODE_ALL_AXES, stuff->mode); - else if (rep.status != AlreadyGrabbed) - { - switch(rep.status) { - case BadMatch: - case BadImplementation: - case BadAlloc: - break; - default: - rep.status = BadMode; - } - return rep.status; + else if (rep.status != AlreadyGrabbed) { + switch (rep.status) { + case BadMatch: + case BadImplementation: + case BadAlloc: + break; + default: + rep.status = BadMode; + } + return rep.status; } WriteReplyToClient(client, sizeof(xSetDeviceModeReply), &rep); @@ -138,5 +137,5 @@ SRepXSetDeviceMode(ClientPtr client, int size, xSetDeviceModeReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/stubs.c b/xorg-server/Xi/stubs.c index 6a4c18158..8baa5a09b 100644 --- a/xorg-server/Xi/stubs.c +++ b/xorg-server/Xi/stubs.c @@ -98,7 +98,7 @@ SetDeviceMode(ClientPtr client, DeviceIntPtr dev, int mode) int SetDeviceValuators(ClientPtr client, DeviceIntPtr dev, - int *valuators, int first_valuator, int num_valuators) + int *valuators, int first_valuator, int num_valuators) { return BadMatch; } @@ -112,13 +112,11 @@ SetDeviceValuators(ClientPtr client, DeviceIntPtr dev, */ int -ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, - xDeviceCtl * control) +ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, xDeviceCtl * control) { return BadMatch; } - /**************************************************************************** * * Caller: configAddDevice (and others) @@ -127,7 +125,7 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev, * */ int -NewInputDeviceRequest(InputOption *options, InputAttributes *attrs, +NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, DeviceIntPtr *pdev) { return BadValue; diff --git a/xorg-server/Xi/ungrdevb.c b/xorg-server/Xi/ungrdevb.c index 0ba395cf3..c4632fadc 100644 --- a/xorg-server/Xi/ungrdevb.c +++ b/xorg-server/Xi/ungrdevb.c @@ -54,8 +54,8 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exglobals.h" @@ -104,27 +104,28 @@ ProcXUngrabDeviceButton(ClientPtr client) rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess); if (rc != Success) - return rc; + return rc; if (dev->button == NULL) - return BadMatch; + return BadMatch; if (stuff->modifier_device != UseXKeyboard) { - rc = dixLookupDevice(&mdev, stuff->modifier_device, client, - DixReadAccess); - if (rc != Success) - return BadDevice; - if (mdev->key == NULL) - return BadMatch; - } else - mdev = PickKeyboard(client); + rc = dixLookupDevice(&mdev, stuff->modifier_device, client, + DixReadAccess); + if (rc != Success) + return BadDevice; + if (mdev->key == NULL) + return BadMatch; + } + else + mdev = PickKeyboard(client); rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); if (rc != Success) - return rc; + return rc; if ((stuff->modifiers != AnyModifier) && - (stuff->modifiers & ~AllModifiersMask)) - return BadValue; + (stuff->modifiers & ~AllModifiersMask)) + return BadValue; temporaryGrab = AllocGrab(); if (!temporaryGrab) diff --git a/xorg-server/Xi/ungrdevk.c b/xorg-server/Xi/ungrdevk.c index 8785989b0..3273878d3 100644 --- a/xorg-server/Xi/ungrdevk.c +++ b/xorg-server/Xi/ungrdevk.c @@ -54,8 +54,8 @@ SOFTWARE. #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XIproto.h> #include "exglobals.h" @@ -106,32 +106,33 @@ ProcXUngrabDeviceKey(ClientPtr client) rc = dixLookupDevice(&dev, stuff->grabbed_device, client, DixGrabAccess); if (rc != Success) - return rc; + return rc; if (dev->key == NULL) - return BadMatch; + return BadMatch; if (stuff->modifier_device != UseXKeyboard) { - rc = dixLookupDevice(&mdev, stuff->modifier_device, client, - DixReadAccess); - if (rc != Success) - return BadDevice; - if (mdev->key == NULL) - return BadMatch; - } else - mdev = PickKeyboard(client); + rc = dixLookupDevice(&mdev, stuff->modifier_device, client, + DixReadAccess); + if (rc != Success) + return BadDevice; + if (mdev->key == NULL) + return BadMatch; + } + else + mdev = PickKeyboard(client); rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixSetAttrAccess); if (rc != Success) - return rc; + return rc; if (((stuff->key > dev->key->xkbInfo->desc->max_key_code) || - (stuff->key < dev->key->xkbInfo->desc->min_key_code)) - && (stuff->key != AnyKey)) - return BadValue; + (stuff->key < dev->key->xkbInfo->desc->min_key_code)) + && (stuff->key != AnyKey)) + return BadValue; if ((stuff->modifiers != AnyModifier) && - (stuff->modifiers & ~AllModifiersMask)) - return BadValue; + (stuff->modifiers & ~AllModifiersMask)) + return BadValue; temporaryGrab = AllocGrab(); if (!temporaryGrab) diff --git a/xorg-server/Xi/xiallowev.c b/xorg-server/Xi/xiallowev.c index d0856b656..62a0727b0 100644 --- a/xorg-server/Xi/xiallowev.c +++ b/xorg-server/Xi/xiallowev.c @@ -33,14 +33,14 @@ #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include "mi.h" #include "eventstr.h" #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> -#include "exglobals.h" /* BadDevice */ +#include "exglobals.h" /* BadDevice */ #include "exevents.h" #include "xiallowev.h" @@ -52,9 +52,9 @@ SProcXIAllowEvents(ClientPtr client) swaps(&stuff->length); swaps(&stuff->deviceid); swapl(&stuff->time); - if (stuff->length > 3) - { - xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq*)stuff; + if (stuff->length > 3) { + xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq *) stuff; + swapl(&req_xi22->touchid); swapl(&req_xi22->grab_window); } @@ -70,70 +70,69 @@ ProcXIAllowEvents(ClientPtr client) int ret = Success; XIClientPtr xi_client; Bool have_xi22 = FALSE; + REQUEST(xXI2_2AllowEventsReq); xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); if (version_compare(xi_client->major_version, - xi_client->minor_version, 2, 2) >= 0) - { + xi_client->minor_version, 2, 2) >= 0) { REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq); have_xi22 = TRUE; - } else - { + } + else { REQUEST_SIZE_MATCH(xXIAllowEventsReq); } ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); if (ret != Success) - return ret; + return ret; time = ClientTimeToServerTime(stuff->time); switch (stuff->mode) { case XIReplayDevice: - AllowSome(client, time, dev, NOT_GRABBED); - break; + AllowSome(client, time, dev, NOT_GRABBED); + break; case XISyncDevice: - AllowSome(client, time, dev, FREEZE_NEXT_EVENT); - break; + AllowSome(client, time, dev, FREEZE_NEXT_EVENT); + break; case XIAsyncDevice: - AllowSome(client, time, dev, THAWED); - break; + AllowSome(client, time, dev, THAWED); + break; case XIAsyncPairedDevice: if (IsMaster(dev)) AllowSome(client, time, dev, THAW_OTHERS); - break; + break; case XISyncPair: if (IsMaster(dev)) AllowSome(client, time, dev, FREEZE_BOTH_NEXT_EVENT); - break; + break; case XIAsyncPair: if (IsMaster(dev)) AllowSome(client, time, dev, THAWED_BOTH); - break; + break; case XIRejectTouch: case XIAcceptTouch: - { - int rc; - WindowPtr win; + { + int rc; + WindowPtr win; - if (!have_xi22) - return BadValue; + if (!have_xi22) + return BadValue; - rc = dixLookupWindow(&win, stuff->grab_window, client, DixReadAccess); - if (rc != Success) - return rc; + rc = dixLookupWindow(&win, stuff->grab_window, client, DixReadAccess); + if (rc != Success) + return rc; - ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid, - stuff->grab_window, &client->errorValue); - } + ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid, + stuff->grab_window, &client->errorValue); + } break; default: - client->errorValue = stuff->mode; - ret = BadValue; + client->errorValue = stuff->mode; + ret = BadValue; } return ret; } - diff --git a/xorg-server/Xi/xichangecursor.c b/xorg-server/Xi/xichangecursor.c index 48f51f3b5..0be6bc0d4 100644 --- a/xorg-server/Xi/xichangecursor.c +++ b/xorg-server/Xi/xichangecursor.c @@ -33,11 +33,11 @@ #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> #include "extnsionst.h" @@ -65,10 +65,11 @@ SProcXIChangeCursor(ClientPtr client) return (ProcXIChangeCursor(client)); } -int ProcXIChangeCursor(ClientPtr client) +int +ProcXIChangeCursor(ClientPtr client) { int rc; - WindowPtr pWin = NULL; + WindowPtr pWin = NULL; DeviceIntPtr pDev = NULL; CursorPtr pCursor = NULL; @@ -82,30 +83,26 @@ int ProcXIChangeCursor(ClientPtr client) if (!IsMaster(pDev) || !IsPointerDevice(pDev)) return BadDevice; - if (stuff->win != None) - { + if (stuff->win != None) { rc = dixLookupWindow(&pWin, stuff->win, client, DixSetAttrAccess); if (rc != Success) return rc; } - if (stuff->cursor == None) - { + if (stuff->cursor == None) { if (pWin == pWin->drawable.pScreen->root) pCursor = rootCursor; else - pCursor = (CursorPtr)None; + pCursor = (CursorPtr) None; } - else - { - rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, - RT_CURSOR, client, DixUseAccess); - if (rc != Success) - return rc; + else { + rc = dixLookupResourceByType((pointer *) &pCursor, stuff->cursor, + RT_CURSOR, client, DixUseAccess); + if (rc != Success) + return rc; } ChangeWindowDeviceCursor(pWin, pDev, pCursor); return Success; } - diff --git a/xorg-server/Xi/xichangehierarchy.c b/xorg-server/Xi/xichangehierarchy.c index 503404e64..756aaac06 100644 --- a/xorg-server/Xi/xichangehierarchy.c +++ b/xorg-server/Xi/xichangehierarchy.c @@ -30,16 +30,15 @@ * */ - #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> #include <X11/extensions/geproto.h> @@ -48,7 +47,7 @@ #include "exglobals.h" #include "geext.h" #include "xace.h" -#include "xiquerydevice.h" /* for GetDeviceUse */ +#include "xiquerydevice.h" /* for GetDeviceUse */ #include "xkbsrv.h" @@ -57,7 +56,8 @@ /** * Send the current state of the device hierarchy to all clients. */ -void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) +void +XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) { xXIHierarchyEvent *ev; xXIHierarchyInfo *info; @@ -69,7 +69,7 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) return; ev = calloc(1, sizeof(xXIHierarchyEvent) + - MAXDEVICES * sizeof(xXIHierarchyInfo)); + MAXDEVICES * sizeof(xXIHierarchyInfo)); if (!ev) return; ev->type = GenericEvent; @@ -79,9 +79,8 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) ev->flags = 0; ev->num_info = inputInfo.numDevices; - info = (xXIHierarchyInfo*)&ev[1]; - for (dev = inputInfo.devices; dev; dev = dev->next) - { + info = (xXIHierarchyInfo *) & ev[1]; + for (dev = inputInfo.devices; dev; dev = dev->next) { info->deviceid = dev->id; info->enabled = dev->enabled; info->use = GetDeviceUse(dev, &info->attachment); @@ -89,8 +88,7 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) ev->flags |= info->flags; info++; } - for (dev = inputInfo.off_devices; dev; dev = dev->next) - { + for (dev = inputInfo.off_devices; dev; dev = dev->next) { info->deviceid = dev->id; info->enabled = dev->enabled; info->use = GetDeviceUse(dev, &info->attachment); @@ -99,11 +97,8 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) info++; } - - for (i = 0; i < MAXDEVICES; i++) - { - if (flags[i] & (XIMasterRemoved | XISlaveRemoved)) - { + for (i = 0; i < MAXDEVICES; i++) { + if (flags[i] & (XIMasterRemoved | XISlaveRemoved)) { info->deviceid = i; info->enabled = FALSE; info->flags = flags[i]; @@ -119,11 +114,11 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) memset(&dummyDev, 0, sizeof(dummyDev)); dummyDev.id = XIAllDevices; dummyDev.type = SLAVE; - SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8), (xEvent*)ev, 1); + SendEventToAllWindows(&dummyDev, (XI_HierarchyChangedMask >> 8), + (xEvent *) ev, 1); free(ev); } - /*********************************************************************** * * This procedure allows a client to change the device hierarchy through @@ -131,7 +126,8 @@ void XISendDeviceHierarchyEvent(int flags[MAXDEVICES]) * */ -int SProcXIChangeHierarchy(ClientPtr client) +int +SProcXIChangeHierarchy(ClientPtr client) { REQUEST(xXIChangeHierarchyReq); swaps(&stuff->length); @@ -139,14 +135,14 @@ int SProcXIChangeHierarchy(ClientPtr client) } static int -add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES]) +add_master(ClientPtr client, xXIAddMasterInfo * c, int flags[MAXDEVICES]) { DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; - char* name; + char *name; int rc; name = calloc(c->name_len + 1, sizeof(char)); - strncpy(name, (char*)&c[1], c->name_len); + strncpy(name, (char *) &c[1], c->name_len); rc = AllocDevicePair(client, name, &ptr, &keybd, CorePointerProc, CoreKeyboardProc, TRUE); @@ -154,12 +150,11 @@ add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES]) goto unwind; if (!c->send_core) - ptr->coreEvents = keybd->coreEvents = FALSE; + ptr->coreEvents = keybd->coreEvents = FALSE; /* Allocate virtual slave devices for xtest events */ rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd, ptr, keybd); - if (rc != Success) - { + if (rc != Success) { DeleteInputDeviceRequest(ptr); DeleteInputDeviceRequest(keybd); goto unwind; @@ -175,8 +170,7 @@ add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES]) flags[XTestptr->id] |= XISlaveAdded; flags[XTestkeybd->id] |= XISlaveAdded; - if (c->enable) - { + if (c->enable) { EnableDevice(ptr, FALSE); EnableDevice(keybd, FALSE); flags[ptr->id] |= XIDeviceEnabled; @@ -195,7 +189,7 @@ add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES]) flags[XTestptr->id] |= XISlaveAttached; flags[XTestkeybd->id] |= XISlaveAttached; -unwind: + unwind: free(name); return rc; } @@ -205,44 +199,39 @@ disable_clientpointer(DeviceIntPtr dev) { int i; - for (i = 0; i < currentMaxClients; i++) - { + for (i = 0; i < currentMaxClients; i++) { ClientPtr client = clients[i]; + if (client && client->clientPtr == dev) client->clientPtr = NULL; } } static int -remove_master(ClientPtr client, xXIRemoveMasterInfo *r, - int flags[MAXDEVICES]) +remove_master(ClientPtr client, xXIRemoveMasterInfo * r, int flags[MAXDEVICES]) { DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; int rc = Success; - if (r->return_mode != XIAttachToMaster && - r->return_mode != XIFloating) + if (r->return_mode != XIAttachToMaster && r->return_mode != XIFloating) return BadValue; rc = dixLookupDevice(&ptr, r->deviceid, client, DixDestroyAccess); if (rc != Success) goto unwind; - if (!IsMaster(ptr)) - { + if (!IsMaster(ptr)) { client->errorValue = r->deviceid; rc = BadDevice; goto unwind; } /* XXX: For now, don't allow removal of VCP, VCK */ - if (ptr == inputInfo.pointer || ptr == inputInfo.keyboard) - { + if (ptr == inputInfo.pointer ||ptr == inputInfo.keyboard) { rc = BadDevice; goto unwind; } - ptr = GetMaster(ptr, MASTER_POINTER); rc = dixLookupDevice(&ptr, ptr->id, client, DixDestroyAccess); if (rc != Success) @@ -258,8 +247,7 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r, goto unwind; XTestkeybd = GetXTestDevice(keybd); - rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client, - DixDestroyAccess); + rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client, DixDestroyAccess); if (rc != Success) goto unwind; @@ -267,18 +255,14 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r, /* Disabling sends the devices floating, reattach them if * desired. */ - if (r->return_mode == XIAttachToMaster) - { - DeviceIntPtr attached, - newptr, - newkeybd; + if (r->return_mode == XIAttachToMaster) { + DeviceIntPtr attached, newptr, newkeybd; rc = dixLookupDevice(&newptr, r->return_pointer, client, DixAddAccess); if (rc != Success) goto unwind; - if (!IsMaster(newptr)) - { + if (!IsMaster(newptr)) { client->errorValue = r->return_pointer; rc = BadDevice; goto unwind; @@ -289,23 +273,19 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r, if (rc != Success) goto unwind; - if (!IsMaster(newkeybd)) - { + if (!IsMaster(newkeybd)) { client->errorValue = r->return_keyboard; rc = BadDevice; goto unwind; } - for (attached = inputInfo.devices; attached; attached = attached->next) - { + for (attached = inputInfo.devices; attached; attached = attached->next) { if (!IsMaster(attached)) { - if (GetMaster(attached, MASTER_ATTACHED) == ptr) - { + if (GetMaster(attached, MASTER_ATTACHED) == ptr) { AttachDevice(client, attached, newptr); flags[attached->id] |= XISlaveAttached; } - if (GetMaster(attached, MASTER_ATTACHED) == keybd) - { + if (GetMaster(attached, MASTER_ATTACHED) == keybd) { AttachDevice(client, attached, newkeybd); flags[attached->id] |= XISlaveAttached; } @@ -339,12 +319,12 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r, flags[keybd->id] |= XIMasterRemoved; flags[ptr->id] |= XIMasterRemoved; -unwind: + unwind: return rc; } static int -detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES]) +detach_slave(ClientPtr client, xXIDetachSlaveInfo * c, int flags[MAXDEVICES]) { DeviceIntPtr dev; int rc; @@ -353,16 +333,14 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES]) if (rc != Success) goto unwind; - if (IsMaster(dev)) - { + if (IsMaster(dev)) { client->errorValue = c->deviceid; rc = BadDevice; goto unwind; } /* Don't allow changes to XTest Devices, these are fixed */ - if (IsXTestDevice(dev, NULL)) - { + if (IsXTestDevice(dev, NULL)) { client->errorValue = c->deviceid; rc = BadDevice; goto unwind; @@ -372,13 +350,12 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES]) AttachDevice(client, dev, NULL); flags[dev->id] |= XISlaveDetached; -unwind: + unwind: return rc; } static int -attach_slave(ClientPtr client, xXIAttachSlaveInfo *c, - int flags[MAXDEVICES]) +attach_slave(ClientPtr client, xXIAttachSlaveInfo * c, int flags[MAXDEVICES]) { DeviceIntPtr dev; DeviceIntPtr newmaster; @@ -388,16 +365,14 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c, if (rc != Success) goto unwind; - if (IsMaster(dev)) - { + if (IsMaster(dev)) { client->errorValue = c->deviceid; rc = BadDevice; goto unwind; } /* Don't allow changes to XTest Devices, these are fixed */ - if (IsXTestDevice(dev, NULL)) - { + if (IsXTestDevice(dev, NULL)) { client->errorValue = c->deviceid; rc = BadDevice; goto unwind; @@ -406,16 +381,14 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c, rc = dixLookupDevice(&newmaster, c->new_master, client, DixAddAccess); if (rc != Success) goto unwind; - if (!IsMaster(newmaster)) - { + if (!IsMaster(newmaster)) { client->errorValue = c->new_master; rc = BadDevice; goto unwind; } if (!((IsPointerDevice(newmaster) && IsPointerDevice(dev)) || - (IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev)))) - { + (IsKeyboardDevice(newmaster) && IsKeyboardDevice(dev)))) { rc = BadDevice; goto unwind; } @@ -424,12 +397,10 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c, AttachDevice(client, dev, newmaster); flags[dev->id] |= XISlaveAttached; -unwind: + unwind: return rc; } - - #define SWAPIF(cmd) if (client->swapped) { cmd; } int @@ -438,7 +409,7 @@ ProcXIChangeHierarchy(ClientPtr client) xXIAnyHierarchyChangeInfo *any; int required_len = sizeof(xXIChangeHierarchyReq); int rc = Success; - int flags[MAXDEVICES] = {0}; + int flags[MAXDEVICES] = { 0 }; REQUEST(xXIChangeHierarchyReq); REQUEST_AT_LEAST_SIZE(xXIChangeHierarchyReq); @@ -446,9 +417,8 @@ ProcXIChangeHierarchy(ClientPtr client) if (!stuff->num_changes) return rc; - any = (xXIAnyHierarchyChangeInfo*)&stuff[1]; - while(stuff->num_changes--) - { + any = (xXIAnyHierarchyChangeInfo *) &stuff[1]; + while (stuff->num_changes--) { SWAPIF(swaps(&any->type)); SWAPIF(swaps(&any->length)); @@ -456,53 +426,52 @@ ProcXIChangeHierarchy(ClientPtr client) if ((stuff->length * 4) < required_len) return BadLength; - switch(any->type) + switch (any->type) { + case XIAddMaster: { - case XIAddMaster: - { - xXIAddMasterInfo* c = (xXIAddMasterInfo*)any; - SWAPIF(swaps(&c->name_len)); - - rc = add_master(client, c, flags); - if (rc != Success) - goto unwind; - } - break; - case XIRemoveMaster: - { - xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any; - - rc = remove_master(client, r, flags); - if (rc != Success) - goto unwind; - } - break; - case XIDetachSlave: - { - xXIDetachSlaveInfo* c = (xXIDetachSlaveInfo*)any; - - rc = detach_slave(client, c, flags); - if (rc != Success) - goto unwind; - } - break; - case XIAttachSlave: - { - xXIAttachSlaveInfo* c = (xXIAttachSlaveInfo*)any; - - rc = attach_slave(client, c, flags); - if (rc != Success) - goto unwind; - } - break; + xXIAddMasterInfo *c = (xXIAddMasterInfo *) any; + + SWAPIF(swaps(&c->name_len)); + + rc = add_master(client, c, flags); + if (rc != Success) + goto unwind; } + break; + case XIRemoveMaster: + { + xXIRemoveMasterInfo *r = (xXIRemoveMasterInfo *) any; + + rc = remove_master(client, r, flags); + if (rc != Success) + goto unwind; + } + break; + case XIDetachSlave: + { + xXIDetachSlaveInfo *c = (xXIDetachSlaveInfo *) any; - any = (xXIAnyHierarchyChangeInfo*)((char*)any + any->length * 4); + rc = detach_slave(client, c, flags); + if (rc != Success) + goto unwind; + } + break; + case XIAttachSlave: + { + xXIAttachSlaveInfo *c = (xXIAttachSlaveInfo *) any; + + rc = attach_slave(client, c, flags); + if (rc != Success) + goto unwind; + } + break; + } + + any = (xXIAnyHierarchyChangeInfo *) ((char *) any + any->length * 4); } -unwind: + unwind: XISendDeviceHierarchyEvent(flags); return rc; } - diff --git a/xorg-server/Xi/xigetclientpointer.c b/xorg-server/Xi/xigetclientpointer.c index 1124ae08c..07dbf1800 100644 --- a/xorg-server/Xi/xigetclientpointer.c +++ b/xorg-server/Xi/xigetclientpointer.c @@ -27,15 +27,15 @@ #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> #include "extnsionst.h" -#include "extinit.h" /* LookupDeviceIntRec */ +#include "extinit.h" /* LookupDeviceIntRec */ #include "exevents.h" #include "exglobals.h" @@ -56,22 +56,23 @@ SProcXIGetClientPointer(ClientPtr client) return ProcXIGetClientPointer(client); } -int ProcXIGetClientPointer(ClientPtr client) +int +ProcXIGetClientPointer(ClientPtr client) { int rc; ClientPtr winclient; xXIGetClientPointerReply rep; + REQUEST(xXIGetClientPointerReq); REQUEST_SIZE_MATCH(xXIGetClientPointerReq); - if (stuff->win != None) - { - rc = dixLookupClient(&winclient, stuff->win, client, - DixGetAttrAccess); + if (stuff->win != None) { + rc = dixLookupClient(&winclient, stuff->win, client, DixGetAttrAccess); if (rc != Success) return BadWindow; - } else + } + else winclient = client; rep.repType = X_Reply; @@ -94,11 +95,10 @@ int ProcXIGetClientPointer(ClientPtr client) void SRepXIGetClientPointer(ClientPtr client, int size, - xXIGetClientPointerReply* rep) + xXIGetClientPointerReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); swaps(&rep->deviceid); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } - diff --git a/xorg-server/Xi/xigrabdev.c b/xorg-server/Xi/xigrabdev.c index 2b3055004..8d2cf0bed 100644 --- a/xorg-server/Xi/xigrabdev.c +++ b/xorg-server/Xi/xigrabdev.c @@ -33,12 +33,12 @@ #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> -#include "exglobals.h" /* BadDevice */ +#include "exglobals.h" /* BadDevice */ #include "exevents.h" #include "xigrabdev.h" #include "inpututils.h" @@ -73,12 +73,12 @@ ProcXIGrabDevice(ClientPtr client) ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); if (ret != Success) - return ret; + return ret; if (!IsMaster(dev)) stuff->paired_device_mode = GrabModeAsync; - if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1], + if (XICheckInvalidMaskBits(client, (unsigned char *) &stuff[1], stuff->mask_len * 4) != Success) return BadValue; @@ -88,17 +88,15 @@ ProcXIGrabDevice(ClientPtr client) mask_len = min(xi2mask_mask_size(mask.xi2mask), stuff->mask_len * 4); /* FIXME: I think the old code was broken here */ - xi2mask_set_one_mask(mask.xi2mask, dev->id, (unsigned char*)&stuff[1], mask_len); + xi2mask_set_one_mask(mask.xi2mask, dev->id, (unsigned char *) &stuff[1], + mask_len); ret = GrabDevice(client, dev, stuff->grab_mode, stuff->paired_device_mode, stuff->grab_window, stuff->owner_events, stuff->time, - &mask, - XI2, - stuff->cursor, - None /* confineTo */, + &mask, XI2, stuff->cursor, None /* confineTo */ , &status); xi2mask_free(&mask.xi2mask); @@ -112,7 +110,6 @@ ProcXIGrabDevice(ClientPtr client) rep.sequenceNumber = client->sequence; rep.status = status; - WriteReplyToClient(client, sizeof(rep), &rep); return ret; } @@ -141,22 +138,23 @@ ProcXIUngrabDevice(ClientPtr client) ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); if (ret != Success) - return ret; + return ret; grab = dev->deviceGrab.grab; time = ClientTimeToServerTime(stuff->time); if ((CompareTimeStamps(time, currentTime) != LATER) && - (CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) && - (grab) && SameClient(grab, client) && grab->grabtype == XI2) - (*dev->deviceGrab.DeactivateGrab) (dev); + (CompareTimeStamps(time, dev->deviceGrab.grabTime) != EARLIER) && + (grab) && SameClient(grab, client) && grab->grabtype == XI2) + (*dev->deviceGrab.DeactivateGrab) (dev); return Success; } -void SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep) +void +SRepXIGrabDevice(ClientPtr client, int size, xXIGrabDeviceReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/xipassivegrab.c b/xorg-server/Xi/xipassivegrab.c index c80da8044..8a1c59968 100644 --- a/xorg-server/Xi/xipassivegrab.c +++ b/xorg-server/Xi/xipassivegrab.c @@ -33,13 +33,13 @@ #include <dix-config.h> #endif -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI2.h> #include <X11/extensions/XI2proto.h> #include "swaprep.h" -#include "exglobals.h" /* BadDevice */ +#include "exglobals.h" /* BadDevice */ #include "exevents.h" #include "xipassivegrab.h" #include "dixgrabs.h" @@ -63,10 +63,9 @@ SProcXIPassiveGrabDevice(ClientPtr client) swaps(&stuff->mask_len); swaps(&stuff->num_modifiers); - mods = (xXIModifierInfo*)&stuff[1]; + mods = (xXIModifierInfo *) &stuff[1]; - for (i = 0; i < stuff->num_modifiers; i++, mods++) - { + for (i = 0; i < stuff->num_modifiers; i++, mods++) { swapl(&mods->base_mods); swapl(&mods->latched_mods); swapl(&mods->locked_mods); @@ -95,11 +94,9 @@ ProcXIPassiveGrabDevice(ClientPtr client) dev = inputInfo.all_devices; else if (stuff->deviceid == XIAllMasterDevices) dev = inputInfo.all_master_devices; - else - { + else { ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); - if (ret != Success) - { + if (ret != Success) { client->errorValue = stuff->deviceid; return ret; } @@ -109,29 +106,26 @@ ProcXIPassiveGrabDevice(ClientPtr client) stuff->grab_type != XIGrabtypeKeycode && stuff->grab_type != XIGrabtypeEnter && stuff->grab_type != XIGrabtypeFocusIn && - stuff->grab_type != XIGrabtypeTouchBegin) - { + stuff->grab_type != XIGrabtypeTouchBegin) { client->errorValue = stuff->grab_type; return BadValue; } if ((stuff->grab_type == XIGrabtypeEnter || stuff->grab_type == XIGrabtypeFocusIn || - stuff->grab_type == XIGrabtypeTouchBegin) && stuff->detail != 0) - { + stuff->grab_type == XIGrabtypeTouchBegin) && stuff->detail != 0) { client->errorValue = stuff->detail; return BadValue; } if (stuff->grab_type == XIGrabtypeTouchBegin && (stuff->grab_mode != XIGrabModeTouch || - stuff->paired_device_mode != GrabModeAsync)) - { + stuff->paired_device_mode != GrabModeAsync)) { client->errorValue = stuff->grab_mode; return BadValue; } - if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1], + if (XICheckInvalidMaskBits(client, (unsigned char *) &stuff[1], stuff->mask_len * 4) != Success) return BadValue; @@ -140,7 +134,8 @@ ProcXIPassiveGrabDevice(ClientPtr client) return BadAlloc; mask_len = min(xi2mask_mask_size(mask.xi2mask), stuff->mask_len * 4); - xi2mask_set_one_mask(mask.xi2mask, stuff->deviceid, (unsigned char*)&stuff[1], mask_len * 4); + xi2mask_set_one_mask(mask.xi2mask, stuff->deviceid, + (unsigned char *) &stuff[1], mask_len * 4); rep.repType = X_Reply; rep.RepType = X_XIPassiveGrabDevice; @@ -157,23 +152,24 @@ ProcXIPassiveGrabDevice(ClientPtr client) if (IsKeyboardDevice(dev)) { param.this_device_mode = stuff->grab_mode; param.other_devices_mode = stuff->paired_device_mode; - } else { + } + else { param.this_device_mode = stuff->paired_device_mode; param.other_devices_mode = stuff->grab_mode; } - if (stuff->cursor != None) - { + if (stuff->cursor != None) { ret = dixLookupResourceByType(&tmp, stuff->cursor, RT_CURSOR, client, DixUseAccess); - if (ret != Success) - { + if (ret != Success) { client->errorValue = stuff->cursor; goto out; } } - ret = dixLookupWindow((WindowPtr*)&tmp, stuff->grab_window, client, DixSetAttrAccess); + ret = + dixLookupWindow((WindowPtr *) &tmp, stuff->grab_window, client, + DixSetAttrAccess); if (ret != Success) goto out; @@ -181,8 +177,9 @@ ProcXIPassiveGrabDevice(ClientPtr client) if (ret != Success) goto out; - modifiers = (uint32_t*)&stuff[1] + stuff->mask_len; - modifiers_failed = calloc(stuff->num_modifiers, sizeof(xXIGrabModifierInfo)); + modifiers = (uint32_t *) &stuff[1] + stuff->mask_len; + modifiers_failed = + calloc(stuff->num_modifiers, sizeof(xXIGrabModifierInfo)); if (!modifiers_failed) { ret = BadAlloc; goto out; @@ -190,33 +187,29 @@ ProcXIPassiveGrabDevice(ClientPtr client) mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); - for (i = 0; i < stuff->num_modifiers; i++, modifiers++) - { + for (i = 0; i < stuff->num_modifiers; i++, modifiers++) { uint8_t status = Success; param.modifiers = *modifiers; - switch(stuff->grab_type) - { - case XIGrabtypeButton: - status = GrabButton(client, dev, mod_dev, stuff->detail, - ¶m, XI2, &mask); - break; - case XIGrabtypeKeycode: - status = GrabKey(client, dev, mod_dev, stuff->detail, - ¶m, XI2, &mask); - break; - case XIGrabtypeEnter: - case XIGrabtypeFocusIn: - status = GrabWindow(client, dev, stuff->grab_type, - ¶m, &mask); - break; - case XIGrabtypeTouchBegin: - status = GrabTouch(client, dev, mod_dev, ¶m, &mask); - break; + switch (stuff->grab_type) { + case XIGrabtypeButton: + status = GrabButton(client, dev, mod_dev, stuff->detail, + ¶m, XI2, &mask); + break; + case XIGrabtypeKeycode: + status = GrabKey(client, dev, mod_dev, stuff->detail, + ¶m, XI2, &mask); + break; + case XIGrabtypeEnter: + case XIGrabtypeFocusIn: + status = GrabWindow(client, dev, stuff->grab_type, ¶m, &mask); + break; + case XIGrabtypeTouchBegin: + status = GrabTouch(client, dev, mod_dev, ¶m, &mask); + break; } - if (status != GrabSuccess) - { + if (status != GrabSuccess) { xXIGrabModifierInfo *info = modifiers_failed + rep.num_modifiers; info->status = status; @@ -231,10 +224,10 @@ ProcXIPassiveGrabDevice(ClientPtr client) WriteReplyToClient(client, sizeof(rep), &rep); if (rep.num_modifiers) - WriteToClient(client, rep.length * 4, (char*)modifiers_failed); + WriteToClient(client, rep.length * 4, (char *) modifiers_failed); free(modifiers_failed); -out: + out: xi2mask_free(&mask.xi2mask); return ret; } @@ -247,7 +240,7 @@ SRepXIPassiveGrabDevice(ClientPtr client, int size, swapl(&rep->length); swaps(&rep->num_modifiers); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } int @@ -264,7 +257,7 @@ SProcXIPassiveUngrabDevice(ClientPtr client) swapl(&stuff->detail); swaps(&stuff->num_modifiers); - modifiers = (uint32_t*)&stuff[1]; + modifiers = (uint32_t *) &stuff[1]; for (i = 0; i < stuff->num_modifiers; i++, modifiers++) swapl(modifiers); @@ -278,7 +271,7 @@ ProcXIPassiveUngrabDevice(ClientPtr client) DeviceIntPtr dev, mod_dev; WindowPtr win; GrabPtr tempGrab; - uint32_t* modifiers; + uint32_t *modifiers; int i, rc; REQUEST(xXIPassiveUngrabDeviceReq); @@ -288,25 +281,22 @@ ProcXIPassiveUngrabDevice(ClientPtr client) dev = inputInfo.all_devices; else if (stuff->deviceid == XIAllMasterDevices) dev = inputInfo.all_master_devices; - else - { + else { rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGrabAccess); if (rc != Success) - return rc; + return rc; } if (stuff->grab_type != XIGrabtypeButton && stuff->grab_type != XIGrabtypeKeycode && stuff->grab_type != XIGrabtypeEnter && - stuff->grab_type != XIGrabtypeFocusIn) - { + stuff->grab_type != XIGrabtypeFocusIn) { client->errorValue = stuff->grab_type; return BadValue; } if ((stuff->grab_type == XIGrabtypeEnter || - stuff->grab_type == XIGrabtypeFocusIn) && stuff->detail != 0) - { + stuff->grab_type == XIGrabtypeFocusIn) && stuff->detail != 0) { client->errorValue = stuff->detail; return BadValue; } @@ -317,7 +307,6 @@ ProcXIPassiveUngrabDevice(ClientPtr client) mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD); - tempGrab = AllocGrab(); if (!tempGrab) return BadAlloc; @@ -325,12 +314,19 @@ ProcXIPassiveUngrabDevice(ClientPtr client) tempGrab->resource = client->clientAsMask; tempGrab->device = dev; tempGrab->window = win; - switch(stuff->grab_type) - { - case XIGrabtypeButton: tempGrab->type = XI_ButtonPress; break; - case XIGrabtypeKeycode: tempGrab->type = XI_KeyPress; break; - case XIGrabtypeEnter: tempGrab->type = XI_Enter; break; - case XIGrabtypeFocusIn: tempGrab->type = XI_FocusIn; break; + switch (stuff->grab_type) { + case XIGrabtypeButton: + tempGrab->type = XI_ButtonPress; + break; + case XIGrabtypeKeycode: + tempGrab->type = XI_KeyPress; + break; + case XIGrabtypeEnter: + tempGrab->type = XI_Enter; + break; + case XIGrabtypeFocusIn: + tempGrab->type = XI_FocusIn; + break; } tempGrab->grabtype = XI2; tempGrab->modifierDevice = mod_dev; @@ -338,10 +334,9 @@ ProcXIPassiveUngrabDevice(ClientPtr client) tempGrab->detail.exact = stuff->detail; tempGrab->detail.pMask = NULL; - modifiers = (uint32_t*)&stuff[1]; + modifiers = (uint32_t *) &stuff[1]; - for (i = 0; i < stuff->num_modifiers; i++, modifiers++) - { + for (i = 0; i < stuff->num_modifiers; i++, modifiers++) { tempGrab->modifiersDetail.exact = *modifiers; DeletePassiveGrabFromList(tempGrab); } diff --git a/xorg-server/Xi/xipassivegrab.h b/xorg-server/Xi/xipassivegrab.h index 079e7c61b..c790bb779 100644 --- a/xorg-server/Xi/xipassivegrab.h +++ b/xorg-server/Xi/xipassivegrab.h @@ -32,8 +32,9 @@ int SProcXIPassiveUngrabDevice(ClientPtr client); int ProcXIPassiveUngrabDevice(ClientPtr client); -void SRepXIPassiveGrabDevice(ClientPtr client, int size, xXIPassiveGrabDeviceReply * rep); +void SRepXIPassiveGrabDevice(ClientPtr client, int size, + xXIPassiveGrabDeviceReply * rep); int ProcXIPassiveGrabDevice(ClientPtr client); int SProcXIPassiveGrabDevice(ClientPtr client); -#endif /* XIPASSIVEGRAB_H */ +#endif /* XIPASSIVEGRAB_H */ diff --git a/xorg-server/Xi/xiproperty.c b/xorg-server/Xi/xiproperty.c index c612af22c..e17efe407 100644 --- a/xorg-server/Xi/xiproperty.c +++ b/xorg-server/Xi/xiproperty.c @@ -45,195 +45,185 @@ /** * Properties used or alloced from inside the server. */ -static struct dev_properties -{ +static struct dev_properties { Atom type; const char *name; } dev_properties[] = { - {0, XI_PROP_ENABLED}, - {0, XI_PROP_XTEST_DEVICE}, - - {0, XATOM_FLOAT}, - - {0, ACCEL_PROP_PROFILE_NUMBER}, - {0, ACCEL_PROP_CONSTANT_DECELERATION}, - {0, ACCEL_PROP_ADAPTIVE_DECELERATION}, - {0, ACCEL_PROP_VELOCITY_SCALING}, - - {0, AXIS_LABEL_PROP}, - {0, AXIS_LABEL_PROP_REL_X}, - {0, AXIS_LABEL_PROP_REL_Y}, - {0, AXIS_LABEL_PROP_REL_Z}, - {0, AXIS_LABEL_PROP_REL_RX}, - {0, AXIS_LABEL_PROP_REL_RY}, - {0, AXIS_LABEL_PROP_REL_RZ}, - {0, AXIS_LABEL_PROP_REL_HWHEEL}, - {0, AXIS_LABEL_PROP_REL_DIAL}, - {0, AXIS_LABEL_PROP_REL_WHEEL}, - {0, AXIS_LABEL_PROP_REL_MISC}, - {0, AXIS_LABEL_PROP_REL_VSCROLL}, - {0, AXIS_LABEL_PROP_REL_HSCROLL}, - {0, AXIS_LABEL_PROP_ABS_X}, - {0, AXIS_LABEL_PROP_ABS_Y}, - {0, AXIS_LABEL_PROP_ABS_Z}, - {0, AXIS_LABEL_PROP_ABS_RX}, - {0, AXIS_LABEL_PROP_ABS_RY}, - {0, AXIS_LABEL_PROP_ABS_RZ}, - {0, AXIS_LABEL_PROP_ABS_THROTTLE}, - {0, AXIS_LABEL_PROP_ABS_RUDDER}, - {0, AXIS_LABEL_PROP_ABS_WHEEL}, - {0, AXIS_LABEL_PROP_ABS_GAS}, - {0, AXIS_LABEL_PROP_ABS_BRAKE}, - {0, AXIS_LABEL_PROP_ABS_HAT0X}, - {0, AXIS_LABEL_PROP_ABS_HAT0Y}, - {0, AXIS_LABEL_PROP_ABS_HAT1X}, - {0, AXIS_LABEL_PROP_ABS_HAT1Y}, - {0, AXIS_LABEL_PROP_ABS_HAT2X}, - {0, AXIS_LABEL_PROP_ABS_HAT2Y}, - {0, AXIS_LABEL_PROP_ABS_HAT3X}, - {0, AXIS_LABEL_PROP_ABS_HAT3Y}, - {0, AXIS_LABEL_PROP_ABS_PRESSURE}, - {0, AXIS_LABEL_PROP_ABS_DISTANCE}, - {0, AXIS_LABEL_PROP_ABS_TILT_X}, - {0, AXIS_LABEL_PROP_ABS_TILT_Y}, - {0, AXIS_LABEL_PROP_ABS_TOOL_WIDTH}, - {0, AXIS_LABEL_PROP_ABS_VOLUME}, - {0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR}, - {0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR}, - {0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR}, - {0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR}, - {0, AXIS_LABEL_PROP_ABS_MT_ORIENTATION}, - {0, AXIS_LABEL_PROP_ABS_MT_POSITION_X}, - {0, AXIS_LABEL_PROP_ABS_MT_POSITION_Y}, - {0, AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE}, - {0, AXIS_LABEL_PROP_ABS_MT_BLOB_ID}, - {0, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID}, - {0, AXIS_LABEL_PROP_ABS_MT_PRESSURE}, - {0, AXIS_LABEL_PROP_ABS_MISC}, - - {0, BTN_LABEL_PROP}, - {0, BTN_LABEL_PROP_BTN_UNKNOWN}, - {0, BTN_LABEL_PROP_BTN_WHEEL_UP}, - {0, BTN_LABEL_PROP_BTN_WHEEL_DOWN}, - {0, BTN_LABEL_PROP_BTN_HWHEEL_LEFT}, - {0, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT}, - {0, BTN_LABEL_PROP_BTN_0}, - {0, BTN_LABEL_PROP_BTN_1}, - {0, BTN_LABEL_PROP_BTN_2}, - {0, BTN_LABEL_PROP_BTN_3}, - {0, BTN_LABEL_PROP_BTN_4}, - {0, BTN_LABEL_PROP_BTN_5}, - {0, BTN_LABEL_PROP_BTN_6}, - {0, BTN_LABEL_PROP_BTN_7}, - {0, BTN_LABEL_PROP_BTN_8}, - {0, BTN_LABEL_PROP_BTN_9}, - - {0, BTN_LABEL_PROP_BTN_LEFT}, - {0, BTN_LABEL_PROP_BTN_RIGHT}, - {0, BTN_LABEL_PROP_BTN_MIDDLE}, - {0, BTN_LABEL_PROP_BTN_SIDE}, - {0, BTN_LABEL_PROP_BTN_EXTRA}, - {0, BTN_LABEL_PROP_BTN_FORWARD}, - {0, BTN_LABEL_PROP_BTN_BACK}, - {0, BTN_LABEL_PROP_BTN_TASK}, - - {0, BTN_LABEL_PROP_BTN_TRIGGER}, - {0, BTN_LABEL_PROP_BTN_THUMB}, - {0, BTN_LABEL_PROP_BTN_THUMB2}, - {0, BTN_LABEL_PROP_BTN_TOP}, - {0, BTN_LABEL_PROP_BTN_TOP2}, - {0, BTN_LABEL_PROP_BTN_PINKIE}, - {0, BTN_LABEL_PROP_BTN_BASE}, - {0, BTN_LABEL_PROP_BTN_BASE2}, - {0, BTN_LABEL_PROP_BTN_BASE3}, - {0, BTN_LABEL_PROP_BTN_BASE4}, - {0, BTN_LABEL_PROP_BTN_BASE5}, - {0, BTN_LABEL_PROP_BTN_BASE6}, - {0, BTN_LABEL_PROP_BTN_DEAD}, - - {0, BTN_LABEL_PROP_BTN_A}, - {0, BTN_LABEL_PROP_BTN_B}, - {0, BTN_LABEL_PROP_BTN_C}, - {0, BTN_LABEL_PROP_BTN_X}, - {0, BTN_LABEL_PROP_BTN_Y}, - {0, BTN_LABEL_PROP_BTN_Z}, - {0, BTN_LABEL_PROP_BTN_TL}, - {0, BTN_LABEL_PROP_BTN_TR}, - {0, BTN_LABEL_PROP_BTN_TL2}, - {0, BTN_LABEL_PROP_BTN_TR2}, - {0, BTN_LABEL_PROP_BTN_SELECT}, - {0, BTN_LABEL_PROP_BTN_START}, - {0, BTN_LABEL_PROP_BTN_MODE}, - {0, BTN_LABEL_PROP_BTN_THUMBL}, - {0, BTN_LABEL_PROP_BTN_THUMBR}, - - {0, BTN_LABEL_PROP_BTN_TOOL_PEN}, - {0, BTN_LABEL_PROP_BTN_TOOL_RUBBER}, - {0, BTN_LABEL_PROP_BTN_TOOL_BRUSH}, - {0, BTN_LABEL_PROP_BTN_TOOL_PENCIL}, - {0, BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH}, - {0, BTN_LABEL_PROP_BTN_TOOL_FINGER}, - {0, BTN_LABEL_PROP_BTN_TOOL_MOUSE}, - {0, BTN_LABEL_PROP_BTN_TOOL_LENS}, - {0, BTN_LABEL_PROP_BTN_TOUCH}, - {0, BTN_LABEL_PROP_BTN_STYLUS}, - {0, BTN_LABEL_PROP_BTN_STYLUS2}, - {0, BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP}, - {0, BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP}, - - {0, BTN_LABEL_PROP_BTN_GEAR_DOWN}, - {0, BTN_LABEL_PROP_BTN_GEAR_UP}, - - {0, XI_PROP_TRANSFORM} + { + 0, XI_PROP_ENABLED}, { + 0, XI_PROP_XTEST_DEVICE}, { + 0, XATOM_FLOAT}, { + 0, ACCEL_PROP_PROFILE_NUMBER}, { + 0, ACCEL_PROP_CONSTANT_DECELERATION}, { + 0, ACCEL_PROP_ADAPTIVE_DECELERATION}, { + 0, ACCEL_PROP_VELOCITY_SCALING}, { + 0, AXIS_LABEL_PROP}, { + 0, AXIS_LABEL_PROP_REL_X}, { + 0, AXIS_LABEL_PROP_REL_Y}, { + 0, AXIS_LABEL_PROP_REL_Z}, { + 0, AXIS_LABEL_PROP_REL_RX}, { + 0, AXIS_LABEL_PROP_REL_RY}, { + 0, AXIS_LABEL_PROP_REL_RZ}, { + 0, AXIS_LABEL_PROP_REL_HWHEEL}, { + 0, AXIS_LABEL_PROP_REL_DIAL}, { + 0, AXIS_LABEL_PROP_REL_WHEEL}, { + 0, AXIS_LABEL_PROP_REL_MISC}, { + 0, AXIS_LABEL_PROP_REL_VSCROLL}, { + 0, AXIS_LABEL_PROP_REL_HSCROLL}, { + 0, AXIS_LABEL_PROP_ABS_X}, { + 0, AXIS_LABEL_PROP_ABS_Y}, { + 0, AXIS_LABEL_PROP_ABS_Z}, { + 0, AXIS_LABEL_PROP_ABS_RX}, { + 0, AXIS_LABEL_PROP_ABS_RY}, { + 0, AXIS_LABEL_PROP_ABS_RZ}, { + 0, AXIS_LABEL_PROP_ABS_THROTTLE}, { + 0, AXIS_LABEL_PROP_ABS_RUDDER}, { + 0, AXIS_LABEL_PROP_ABS_WHEEL}, { + 0, AXIS_LABEL_PROP_ABS_GAS}, { + 0, AXIS_LABEL_PROP_ABS_BRAKE}, { + 0, AXIS_LABEL_PROP_ABS_HAT0X}, { + 0, AXIS_LABEL_PROP_ABS_HAT0Y}, { + 0, AXIS_LABEL_PROP_ABS_HAT1X}, { + 0, AXIS_LABEL_PROP_ABS_HAT1Y}, { + 0, AXIS_LABEL_PROP_ABS_HAT2X}, { + 0, AXIS_LABEL_PROP_ABS_HAT2Y}, { + 0, AXIS_LABEL_PROP_ABS_HAT3X}, { + 0, AXIS_LABEL_PROP_ABS_HAT3Y}, { + 0, AXIS_LABEL_PROP_ABS_PRESSURE}, { + 0, AXIS_LABEL_PROP_ABS_DISTANCE}, { + 0, AXIS_LABEL_PROP_ABS_TILT_X}, { + 0, AXIS_LABEL_PROP_ABS_TILT_Y}, { + 0, AXIS_LABEL_PROP_ABS_TOOL_WIDTH}, { + 0, AXIS_LABEL_PROP_ABS_VOLUME}, { + 0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR}, { + 0, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR}, { + 0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR}, { + 0, AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR}, { + 0, AXIS_LABEL_PROP_ABS_MT_ORIENTATION}, { + 0, AXIS_LABEL_PROP_ABS_MT_POSITION_X}, { + 0, AXIS_LABEL_PROP_ABS_MT_POSITION_Y}, { + 0, AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE}, { + 0, AXIS_LABEL_PROP_ABS_MT_BLOB_ID}, { + 0, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID}, { + 0, AXIS_LABEL_PROP_ABS_MT_PRESSURE}, { + 0, AXIS_LABEL_PROP_ABS_MISC}, { + 0, BTN_LABEL_PROP}, { + 0, BTN_LABEL_PROP_BTN_UNKNOWN}, { + 0, BTN_LABEL_PROP_BTN_WHEEL_UP}, { + 0, BTN_LABEL_PROP_BTN_WHEEL_DOWN}, { + 0, BTN_LABEL_PROP_BTN_HWHEEL_LEFT}, { + 0, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT}, { + 0, BTN_LABEL_PROP_BTN_0}, { + 0, BTN_LABEL_PROP_BTN_1}, { + 0, BTN_LABEL_PROP_BTN_2}, { + 0, BTN_LABEL_PROP_BTN_3}, { + 0, BTN_LABEL_PROP_BTN_4}, { + 0, BTN_LABEL_PROP_BTN_5}, { + 0, BTN_LABEL_PROP_BTN_6}, { + 0, BTN_LABEL_PROP_BTN_7}, { + 0, BTN_LABEL_PROP_BTN_8}, { + 0, BTN_LABEL_PROP_BTN_9}, { + 0, BTN_LABEL_PROP_BTN_LEFT}, { + 0, BTN_LABEL_PROP_BTN_RIGHT}, { + 0, BTN_LABEL_PROP_BTN_MIDDLE}, { + 0, BTN_LABEL_PROP_BTN_SIDE}, { + 0, BTN_LABEL_PROP_BTN_EXTRA}, { + 0, BTN_LABEL_PROP_BTN_FORWARD}, { + 0, BTN_LABEL_PROP_BTN_BACK}, { + 0, BTN_LABEL_PROP_BTN_TASK}, { + 0, BTN_LABEL_PROP_BTN_TRIGGER}, { + 0, BTN_LABEL_PROP_BTN_THUMB}, { + 0, BTN_LABEL_PROP_BTN_THUMB2}, { + 0, BTN_LABEL_PROP_BTN_TOP}, { + 0, BTN_LABEL_PROP_BTN_TOP2}, { + 0, BTN_LABEL_PROP_BTN_PINKIE}, { + 0, BTN_LABEL_PROP_BTN_BASE}, { + 0, BTN_LABEL_PROP_BTN_BASE2}, { + 0, BTN_LABEL_PROP_BTN_BASE3}, { + 0, BTN_LABEL_PROP_BTN_BASE4}, { + 0, BTN_LABEL_PROP_BTN_BASE5}, { + 0, BTN_LABEL_PROP_BTN_BASE6}, { + 0, BTN_LABEL_PROP_BTN_DEAD}, { + 0, BTN_LABEL_PROP_BTN_A}, { + 0, BTN_LABEL_PROP_BTN_B}, { + 0, BTN_LABEL_PROP_BTN_C}, { + 0, BTN_LABEL_PROP_BTN_X}, { + 0, BTN_LABEL_PROP_BTN_Y}, { + 0, BTN_LABEL_PROP_BTN_Z}, { + 0, BTN_LABEL_PROP_BTN_TL}, { + 0, BTN_LABEL_PROP_BTN_TR}, { + 0, BTN_LABEL_PROP_BTN_TL2}, { + 0, BTN_LABEL_PROP_BTN_TR2}, { + 0, BTN_LABEL_PROP_BTN_SELECT}, { + 0, BTN_LABEL_PROP_BTN_START}, { + 0, BTN_LABEL_PROP_BTN_MODE}, { + 0, BTN_LABEL_PROP_BTN_THUMBL}, { + 0, BTN_LABEL_PROP_BTN_THUMBR}, { + 0, BTN_LABEL_PROP_BTN_TOOL_PEN}, { + 0, BTN_LABEL_PROP_BTN_TOOL_RUBBER}, { + 0, BTN_LABEL_PROP_BTN_TOOL_BRUSH}, { + 0, BTN_LABEL_PROP_BTN_TOOL_PENCIL}, { + 0, BTN_LABEL_PROP_BTN_TOOL_AIRBRUSH}, { + 0, BTN_LABEL_PROP_BTN_TOOL_FINGER}, { + 0, BTN_LABEL_PROP_BTN_TOOL_MOUSE}, { + 0, BTN_LABEL_PROP_BTN_TOOL_LENS}, { + 0, BTN_LABEL_PROP_BTN_TOUCH}, { + 0, BTN_LABEL_PROP_BTN_STYLUS}, { + 0, BTN_LABEL_PROP_BTN_STYLUS2}, { + 0, BTN_LABEL_PROP_BTN_TOOL_DOUBLETAP}, { + 0, BTN_LABEL_PROP_BTN_TOOL_TRIPLETAP}, { + 0, BTN_LABEL_PROP_BTN_GEAR_DOWN}, { + 0, BTN_LABEL_PROP_BTN_GEAR_UP}, { + 0, XI_PROP_TRANSFORM} }; static long XIPropHandlerID = 1; -static void send_property_event(DeviceIntPtr dev, Atom property, int what) +static void +send_property_event(DeviceIntPtr dev, Atom property, int what) { - devicePropertyNotify event; - xXIPropertyEvent xi2; - int state; - - if (what == XIPropertyDeleted) - state = PropertyDelete; - else - state = PropertyNewValue; - - event.type = DevicePropertyNotify; - event.deviceid = dev->id; - event.state = state; - event.atom = property; - event.time = currentTime.milliseconds; - SendEventToAllWindows(dev, DevicePropertyNotifyMask, - (xEvent*)&event, 1); - - xi2.type = GenericEvent; - xi2.extension = IReqCode; - xi2.length = 0; - xi2.evtype = XI_PropertyEvent; - xi2.deviceid = dev->id; - xi2.time = currentTime.milliseconds; - xi2.property = property; - xi2.what = what; - SendEventToAllWindows(dev, GetEventFilter(dev, (xEvent*)&xi2), - (xEvent*)&xi2, 1); + devicePropertyNotify event; + xXIPropertyEvent xi2; + int state; + + if (what == XIPropertyDeleted) + state = PropertyDelete; + else + state = PropertyNewValue; + + event.type = DevicePropertyNotify; + event.deviceid = dev->id; + event.state = state; + event.atom = property; + event.time = currentTime.milliseconds; + SendEventToAllWindows(dev, DevicePropertyNotifyMask, (xEvent *) &event, 1); + + xi2.type = GenericEvent; + xi2.extension = IReqCode; + xi2.length = 0; + xi2.evtype = XI_PropertyEvent; + xi2.deviceid = dev->id; + xi2.time = currentTime.milliseconds; + xi2.property = property; + xi2.what = what; + SendEventToAllWindows(dev, GetEventFilter(dev, (xEvent *) &xi2), + (xEvent *) &xi2, 1); } -static int list_atoms(DeviceIntPtr dev, int *natoms, Atom **atoms_return) +static int +list_atoms(DeviceIntPtr dev, int *natoms, Atom **atoms_return) { XIPropertyPtr prop; - Atom *atoms = NULL; - int nprops = 0; + Atom *atoms = NULL; + int nprops = 0; for (prop = dev->properties.properties; prop; prop = prop->next) nprops++; - if (nprops) - { + if (nprops) { Atom *a; atoms = malloc(nprops * sizeof(Atom)); - if(!atoms) + if (!atoms) return BadAlloc; a = atoms; for (prop = dev->properties.properties; prop; prop = prop->next, a++) @@ -256,19 +246,16 @@ get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, XIPropertyPtr prop; XIPropertyValuePtr prop_value; - if (!ValidAtom(property)) - { + if (!ValidAtom(property)) { client->errorValue = property; return BadAtom; } - if ((delete != xTrue) && (delete != xFalse)) - { + if ((delete != xTrue) && (delete != xFalse)) { client->errorValue = delete; return BadValue; } - if ((type != AnyPropertyType) && !ValidAtom(type)) - { + if ((type != AnyPropertyType) && !ValidAtom(type)) { client->errorValue = type; return BadAtom; } @@ -277,8 +264,7 @@ get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, if (prop->propertyName == property) break; - if (!prop) - { + if (!prop) { *bytes_after = 0; *type_return = None; *format = 0; @@ -288,17 +274,15 @@ get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, } rc = XIGetDeviceProperty(dev, property, &prop_value); - if (rc != Success) - { + if (rc != Success) { client->errorValue = property; return rc; } /* If the request type and actual type don't match. Return the - property information, but not the data. */ + property information, but not the data. */ - if (((type != prop_value->type) && (type != AnyPropertyType))) - { + if (((type != prop_value->type) && (type != AnyPropertyType))) { *bytes_after = prop_value->size; *format = prop_value->format; *length_return = 0; @@ -308,14 +292,13 @@ get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, } /* Return type, format, value to client */ - n = (prop_value->format/8) * prop_value->size; /* size (bytes) of prop */ + n = (prop_value->format / 8) * prop_value->size; /* size (bytes) of prop */ ind = offset << 2; - /* If offset is invalid such that it causes "len" to - be negative, it's a value error. */ + /* If offset is invalid such that it causes "len" to + be negative, it's a value error. */ - if (n < ind) - { + if (n < ind) { client->errorValue = offset; return BadValue; } @@ -331,7 +314,7 @@ get_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, *nitems = 0; *type_return = prop_value->type; - *data = (char*)prop_value->data + ind; + *data = (char *) prop_value->data + ind; return Success; } @@ -341,24 +324,20 @@ check_change_property(ClientPtr client, Atom property, Atom type, int format, int mode, int nitems) { if ((mode != PropModeReplace) && (mode != PropModeAppend) && - (mode != PropModePrepend)) - { + (mode != PropModePrepend)) { client->errorValue = mode; return BadValue; } - if ((format != 8) && (format != 16) && (format != 32)) - { + if ((format != 8) && (format != 16) && (format != 32)) { client->errorValue = format; return BadValue; } - if (!ValidAtom(property)) - { + if (!ValidAtom(property)) { client->errorValue = property; return BadAtom; } - if (!ValidAtom(type)) - { + if (!ValidAtom(type)) { client->errorValue = type; return BadAtom; } @@ -372,7 +351,8 @@ change_property(ClientPtr client, DeviceIntPtr dev, Atom property, Atom type, { int rc = Success; - rc = XIChangeDeviceProperty(dev, property, type, format, mode, len, data, TRUE); + rc = XIChangeDeviceProperty(dev, property, type, format, mode, len, data, + TRUE); if (rc != Success) client->errorValue = property; @@ -393,14 +373,13 @@ XIGetKnownProperty(const char *name) if (!name) return None; - for (i = 0; i < (sizeof(dev_properties)/sizeof(struct dev_properties)); i++) - { - if (strcmp(name, dev_properties[i].name) == 0){ - if (dev_properties[i].type == None){ - dev_properties[i].type = - MakeAtom(dev_properties[i].name, - strlen(dev_properties[i].name), - TRUE); + for (i = 0; i < (sizeof(dev_properties) / sizeof(struct dev_properties)); + i++) { + if (strcmp(name, dev_properties[i].name) == 0) { + if (dev_properties[i].type == None) { + dev_properties[i].type = + MakeAtom(dev_properties[i].name, + strlen(dev_properties[i].name), TRUE); } return dev_properties[i].type; @@ -415,7 +394,8 @@ XIResetProperties(void) { int i; - for (i = 0; i < (sizeof(dev_properties)/sizeof(struct dev_properties)); i++) + for (i = 0; i < (sizeof(dev_properties) / sizeof(struct dev_properties)); + i++) dev_properties[i].type = None; } @@ -450,35 +430,38 @@ XIPropToInt(XIPropertyValuePtr val, int *nelem_return, int **buf_return) if (!*buf_return && *nelem_return) return BadLength; - switch(val->format) - { - case 8: - case 16: - case 32: - break; - default: - return BadValue; + switch (val->format) { + case 8: + case 16: + case 32: + break; + default: + return BadValue; } buf = *buf_return; - if (!buf && !(*nelem_return)) - { + if (!buf && !(*nelem_return)) { buf = calloc(val->size, sizeof(int)); if (!buf) return BadAlloc; *buf_return = buf; *nelem_return = val->size; - } else if (val->size < *nelem_return) + } + else if (val->size < *nelem_return) *nelem_return = val->size; - for (i = 0; i < val->size && i < *nelem_return; i++) - { - switch(val->format) - { - case 8: buf[i] = ((CARD8*)val->data)[i]; break; - case 16: buf[i] = ((CARD16*)val->data)[i]; break; - case 32: buf[i] = ((CARD32*)val->data)[i]; break; + for (i = 0; i < val->size && i < *nelem_return; i++) { + switch (val->format) { + case 8: + buf[i] = ((CARD8 *) val->data)[i]; + break; + case 16: + buf[i] = ((CARD16 *) val->data)[i]; + break; + case 32: + buf[i] = ((CARD32 *) val->data)[i]; + break; } } @@ -522,18 +505,18 @@ XIPropToFloat(XIPropertyValuePtr val, int *nelem_return, float **buf_return) buf = *buf_return; - if (!buf && !(*nelem_return)) - { + if (!buf && !(*nelem_return)) { buf = calloc(val->size, sizeof(float)); if (!buf) return BadAlloc; *buf_return = buf; *nelem_return = val->size; - } else if (val->size < *nelem_return) + } + else if (val->size < *nelem_return) *nelem_return = val->size; for (i = 0; i < val->size && i < *nelem_return; i++) - buf[i] = ((float*)val->data)[i]; + buf[i] = ((float *) val->data)[i]; return Success; } @@ -544,7 +527,7 @@ XIPropToFloat(XIPropertyValuePtr val, int *nelem_return, float **buf_return) * @return The handler's identifier or 0 if an error occured. */ long -XIRegisterPropertyHandler(DeviceIntPtr dev, +XIRegisterPropertyHandler(DeviceIntPtr dev, int (*SetProperty) (DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, @@ -576,8 +559,7 @@ XIUnregisterPropertyHandler(DeviceIntPtr dev, long id) XIPropertyHandlerPtr curr, prev = NULL; curr = dev->properties.handlers; - while(curr && curr->id != id) - { + while (curr && curr->id != id) { prev = curr; curr = curr->next; } @@ -585,7 +567,7 @@ XIUnregisterPropertyHandler(DeviceIntPtr dev, long id) if (!curr) return; - if (!prev) /* first one */ + if (!prev) /* first one */ dev->properties.handlers = curr->next; else prev->next = curr->next; @@ -594,21 +576,21 @@ XIUnregisterPropertyHandler(DeviceIntPtr dev, long id) } static XIPropertyPtr -XICreateDeviceProperty (Atom property) +XICreateDeviceProperty(Atom property) { - XIPropertyPtr prop; + XIPropertyPtr prop; - prop = (XIPropertyPtr)malloc(sizeof(XIPropertyRec)); + prop = (XIPropertyPtr) malloc(sizeof(XIPropertyRec)); if (!prop) return NULL; - prop->next = NULL; - prop->propertyName = property; - prop->value.type = None; + prop->next = NULL; + prop->propertyName = property; + prop->value.type = None; prop->value.format = 0; - prop->value.size = 0; - prop->value.data = NULL; - prop->deletable = TRUE; + prop->value.size = 0; + prop->value.data = NULL; + prop->deletable = TRUE; return prop; } @@ -616,7 +598,7 @@ XICreateDeviceProperty (Atom property) static XIPropertyPtr XIFetchDeviceProperty(DeviceIntPtr dev, Atom property) { - XIPropertyPtr prop; + XIPropertyPtr prop; for (prop = dev->properties.properties; prop; prop = prop->next) if (prop->propertyName == property) @@ -625,7 +607,7 @@ XIFetchDeviceProperty(DeviceIntPtr dev, Atom property) } static void -XIDestroyDeviceProperty (XIPropertyPtr prop) +XIDestroyDeviceProperty(XIPropertyPtr prop) { free(prop->value.data); free(prop); @@ -636,13 +618,12 @@ XIDestroyDeviceProperty (XIPropertyPtr prop) * DO NOT CALL FROM THE DRIVER. */ void -XIDeleteAllDeviceProperties (DeviceIntPtr device) +XIDeleteAllDeviceProperties(DeviceIntPtr device) { - XIPropertyPtr prop, next; - XIPropertyHandlerPtr curr_handler, next_handler; + XIPropertyPtr prop, next; + XIPropertyHandlerPtr curr_handler, next_handler; - for (prop = device->properties.properties; prop; prop = next) - { + for (prop = device->properties.properties; prop; prop = next) { next = prop->next; send_property_event(device, prop->propertyName, XIPropertyDeleted); XIDestroyDeviceProperty(prop); @@ -652,8 +633,7 @@ XIDeleteAllDeviceProperties (DeviceIntPtr device) /* Now free all handlers */ curr_handler = device->properties.handlers; - while(curr_handler) - { + while (curr_handler) { next_handler = curr_handler->next; free(curr_handler); curr_handler = next_handler; @@ -662,14 +642,14 @@ XIDeleteAllDeviceProperties (DeviceIntPtr device) device->properties.handlers = NULL; } - int -XIDeleteDeviceProperty (DeviceIntPtr device, Atom property, Bool fromClient) +XIDeleteDeviceProperty(DeviceIntPtr device, Atom property, Bool fromClient) { - XIPropertyPtr prop, *prev; - int rc = Success; + XIPropertyPtr prop, *prev; + int rc = Success; - for (prev = &device->properties.properties; (prop = *prev); prev = &(prop->next)) + for (prev = &device->properties.properties; (prop = *prev); + prev = &(prop->next)) if (prop->propertyName == property) break; @@ -680,11 +660,10 @@ XIDeleteDeviceProperty (DeviceIntPtr device, Atom property, Bool fromClient) return BadAccess; /* Ask handlers if we may delete the property */ - if (device->properties.handlers) - { + if (device->properties.handlers) { XIPropertyHandlerPtr handler = device->properties.handlers; - while(handler) - { + + while (handler) { if (handler->DeleteProperty) rc = handler->DeleteProperty(device, prop->propertyName); if (rc != Success) @@ -693,37 +672,35 @@ XIDeleteDeviceProperty (DeviceIntPtr device, Atom property, Bool fromClient) } } - if (prop) - { + if (prop) { *prev = prop->next; send_property_event(device, prop->propertyName, XIPropertyDeleted); - XIDestroyDeviceProperty (prop); + XIDestroyDeviceProperty(prop); } return Success; } int -XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, - int format, int mode, unsigned long len, - const void *value, Bool sendevent) +XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type, + int format, int mode, unsigned long len, + const void *value, Bool sendevent) { - XIPropertyPtr prop; - int size_in_bytes; - int total_size; - unsigned long total_len; - XIPropertyValuePtr prop_value; - XIPropertyValueRec new_value; - Bool add = FALSE; - int rc; + XIPropertyPtr prop; + int size_in_bytes; + int total_size; + unsigned long total_len; + XIPropertyValuePtr prop_value; + XIPropertyValueRec new_value; + Bool add = FALSE; + int rc; size_in_bytes = format >> 3; /* first see if property already exists */ - prop = XIFetchDeviceProperty (dev, property); - if (!prop) /* just add to list */ - { - prop = XICreateDeviceProperty (property); + prop = XIFetchDeviceProperty(dev, property); + if (!prop) { /* just add to list */ + prop = XICreateDeviceProperty(property); if (!prop) return BadAlloc; add = TRUE; @@ -732,9 +709,9 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, prop_value = &prop->value; /* To append or prepend to a property the request format and type - must match those of the already defined property. The - existing format and type are irrelevant when using the mode - "PropModeReplace" since they will be written over. */ + must match those of the already defined property. The + existing format and type are irrelevant when using the mode + "PropModeReplace" since they will be written over. */ if ((format != prop_value->format) && (mode != PropModeReplace)) return BadMatch; @@ -746,16 +723,14 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, else total_len = prop_value->size + len; - if (mode == PropModeReplace || len > 0) - { - pointer new_data = NULL, old_data = NULL; + if (mode == PropModeReplace || len > 0) { + pointer new_data = NULL, old_data = NULL; total_size = total_len * size_in_bytes; - new_value.data = (pointer)malloc(total_size); - if (!new_value.data && total_size) - { + new_value.data = (pointer) malloc(total_size); + if (!new_value.data && total_size) { if (add) - XIDestroyDeviceProperty (prop); + XIDestroyDeviceProperty(prop); return BadAlloc; } new_value.size = len; @@ -779,29 +754,25 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, break; } if (new_data) - memcpy ((char *) new_data, (char *) value, len * size_in_bytes); + memcpy((char *) new_data, (char *) value, len * size_in_bytes); if (old_data) - memcpy ((char *) old_data, (char *) prop_value->data, - prop_value->size * size_in_bytes); + memcpy((char *) old_data, (char *) prop_value->data, + prop_value->size * size_in_bytes); - if (dev->properties.handlers) - { + if (dev->properties.handlers) { XIPropertyHandlerPtr handler; BOOL checkonly = TRUE; + /* run through all handlers with checkonly TRUE, then again with * checkonly FALSE. Handlers MUST return error codes on the * checkonly run, errors on the second run are ignored */ - do - { + do { handler = dev->properties.handlers; - while(handler) - { - if (handler->SetProperty) - { + while (handler) { + if (handler->SetProperty) { rc = handler->SetProperty(dev, prop->propertyName, - &new_value, checkonly); - if (checkonly && rc != Success) - { + &new_value, checkonly); + if (checkonly && rc != Success) { free(new_value.data); return rc; } @@ -813,47 +784,42 @@ XIChangeDeviceProperty (DeviceIntPtr dev, Atom property, Atom type, } free(prop_value->data); *prop_value = new_value; - } else if (len == 0) - { + } + else if (len == 0) { /* do nothing */ } - if (add) - { + if (add) { prop->next = dev->properties.properties; dev->properties.properties = prop; } if (sendevent) send_property_event(dev, prop->propertyName, - (add) ? XIPropertyCreated : XIPropertyModified); + (add) ? XIPropertyCreated : XIPropertyModified); return Success; } int -XIGetDeviceProperty (DeviceIntPtr dev, Atom property, XIPropertyValuePtr *value) +XIGetDeviceProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr *value) { - XIPropertyPtr prop = XIFetchDeviceProperty (dev, property); + XIPropertyPtr prop = XIFetchDeviceProperty(dev, property); int rc; - if (!prop) - { + if (!prop) { *value = NULL; return BadAtom; } /* If we can, try to update the property value first */ - if (dev->properties.handlers) - { + if (dev->properties.handlers) { XIPropertyHandlerPtr handler = dev->properties.handlers; - while(handler) - { - if (handler->GetProperty) - { + + while (handler) { + if (handler->GetProperty) { rc = handler->GetProperty(dev, prop->propertyName); - if (rc != Success) - { + if (rc != Success) { *value = NULL; return rc; } @@ -879,18 +845,18 @@ XISetDevicePropertyDeletable(DeviceIntPtr dev, Atom property, Bool deletable) } int -ProcXListDeviceProperties (ClientPtr client) +ProcXListDeviceProperties(ClientPtr client) { - Atom *atoms; - xListDevicePropertiesReply rep; - int natoms; - DeviceIntPtr dev; - int rc = Success; + Atom *atoms; + xListDevicePropertiesReply rep; + int natoms; + DeviceIntPtr dev; + int rc = Success; REQUEST(xListDevicePropertiesReq); REQUEST_SIZE_MATCH(xListDevicePropertiesReq); - rc = dixLookupDevice (&dev, stuff->deviceid, client, DixListPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess); if (rc != Success) return rc; @@ -905,9 +871,8 @@ ProcXListDeviceProperties (ClientPtr client) rep.nAtoms = natoms; WriteReplyToClient(client, sizeof(xListDevicePropertiesReply), &rep); - if (natoms) - { - client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; + if (natoms) { + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms); free(atoms); } @@ -915,18 +880,18 @@ ProcXListDeviceProperties (ClientPtr client) } int -ProcXChangeDeviceProperty (ClientPtr client) +ProcXChangeDeviceProperty(ClientPtr client) { REQUEST(xChangeDevicePropertyReq); - DeviceIntPtr dev; - unsigned long len; - int totalSize; - int rc; + DeviceIntPtr dev; + unsigned long len; + int totalSize; + int rc; REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq); UpdateCurrentTime(); - rc = dixLookupDevice (&dev, stuff->deviceid, client, DixSetPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); if (rc != Success) return rc; @@ -937,29 +902,28 @@ ProcXChangeDeviceProperty (ClientPtr client) if (len > (bytes_to_int32(0xffffffff - sizeof(xChangeDevicePropertyReq)))) return BadLength; - totalSize = len * (stuff->format/8); + totalSize = len * (stuff->format / 8); REQUEST_FIXED_SIZE(xChangeDevicePropertyReq, totalSize); rc = change_property(client, dev, stuff->property, stuff->type, - stuff->format, stuff->mode, len, (void*)&stuff[1]); + stuff->format, stuff->mode, len, (void *) &stuff[1]); return rc; } int -ProcXDeleteDeviceProperty (ClientPtr client) +ProcXDeleteDeviceProperty(ClientPtr client) { REQUEST(xDeleteDevicePropertyReq); - DeviceIntPtr dev; - int rc; + DeviceIntPtr dev; + int rc; REQUEST_SIZE_MATCH(xDeleteDevicePropertyReq); UpdateCurrentTime(); - rc = dixLookupDevice (&dev, stuff->deviceid, client, DixSetPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); if (rc != Success) return rc; - if (!ValidAtom(stuff->property)) - { + if (!ValidAtom(stuff->property)) { client->errorValue = stuff->property; return BadAtom; } @@ -969,28 +933,27 @@ ProcXDeleteDeviceProperty (ClientPtr client) } int -ProcXGetDeviceProperty (ClientPtr client) +ProcXGetDeviceProperty(ClientPtr client) { REQUEST(xGetDevicePropertyReq); - DeviceIntPtr dev; - int length; - int rc, format, nitems, bytes_after; - char *data; - Atom type; - xGetDevicePropertyReply reply; + DeviceIntPtr dev; + int length; + int rc, format, nitems, bytes_after; + char *data; + Atom type; + xGetDevicePropertyReply reply; REQUEST_SIZE_MATCH(xGetDevicePropertyReq); if (stuff->delete) UpdateCurrentTime(); - rc = dixLookupDevice (&dev, stuff->deviceid, client, - stuff->delete ? DixSetPropAccess : - DixGetPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, + stuff->delete ? DixSetPropAccess : DixGetPropAccess); if (rc != Success) return rc; rc = get_property(client, dev, stuff->property, stuff->type, - stuff->delete, stuff->longOffset, stuff->longLength, - &bytes_after, &type, &format, &nitems, &length, &data); + stuff->delete, stuff->longOffset, stuff->longLength, + &bytes_after, &type, &format, &nitems, &length, &data); if (rc != Success) return rc; @@ -1010,24 +973,28 @@ ProcXGetDeviceProperty (ClientPtr client) WriteReplyToClient(client, sizeof(xGenericReply), &reply); - if (length) - { + if (length) { switch (reply.format) { - case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break; - case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break; - default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break; + case 32: + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; + break; + case 16: + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; + break; + default: + client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient; + break; } WriteSwappedDataToClient(client, length, data); } /* delete the Property */ - if (stuff->delete && (reply.bytesAfter == 0)) - { + if (stuff->delete && (reply.bytesAfter == 0)) { XIPropertyPtr prop, *prev; - for (prev = &dev->properties.properties; (prop = *prev); prev = &prop->next) - { - if (prop->propertyName == stuff->property) - { + + for (prev = &dev->properties.properties; (prop = *prev); + prev = &prop->next) { + if (prop->propertyName == stuff->property) { *prev = prop->next; XIDestroyDeviceProperty(prop); break; @@ -1037,9 +1004,8 @@ ProcXGetDeviceProperty (ClientPtr client) return Success; } - int -SProcXListDeviceProperties (ClientPtr client) +SProcXListDeviceProperties(ClientPtr client) { REQUEST(xListDevicePropertiesReq); @@ -1050,7 +1016,7 @@ SProcXListDeviceProperties (ClientPtr client) } int -SProcXChangeDeviceProperty (ClientPtr client) +SProcXChangeDeviceProperty(ClientPtr client) { REQUEST(xChangeDevicePropertyReq); @@ -1063,7 +1029,7 @@ SProcXChangeDeviceProperty (ClientPtr client) } int -SProcXDeleteDeviceProperty (ClientPtr client) +SProcXDeleteDeviceProperty(ClientPtr client) { REQUEST(xDeleteDevicePropertyReq); @@ -1074,7 +1040,7 @@ SProcXDeleteDeviceProperty (ClientPtr client) } int -SProcXGetDeviceProperty (ClientPtr client) +SProcXGetDeviceProperty(ClientPtr client) { REQUEST(xGetDevicePropertyReq); @@ -1087,23 +1053,22 @@ SProcXGetDeviceProperty (ClientPtr client) return (ProcXGetDeviceProperty(client)); } - /* Reply swapping */ void SRepXListDeviceProperties(ClientPtr client, int size, - xListDevicePropertiesReply *rep) + xListDevicePropertiesReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); swaps(&rep->nAtoms); /* properties will be swapped later, see ProcXListDeviceProperties */ - WriteToClient(client, size, (char*)rep); + WriteToClient(client, size, (char *) rep); } void SRepXGetDeviceProperty(ClientPtr client, int size, - xGetDevicePropertyReply *rep) + xGetDevicePropertyReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); @@ -1111,23 +1076,23 @@ SRepXGetDeviceProperty(ClientPtr client, int size, swapl(&rep->bytesAfter); swapl(&rep->nItems); /* data will be swapped, see ProcXGetDeviceProperty */ - WriteToClient(client, size, (char*)rep); + WriteToClient(client, size, (char *) rep); } /* XI2 Request/reply handling */ int ProcXIListProperties(ClientPtr client) { - Atom *atoms; - xXIListPropertiesReply rep; - int natoms; - DeviceIntPtr dev; - int rc = Success; + Atom *atoms; + xXIListPropertiesReply rep; + int natoms; + DeviceIntPtr dev; + int rc = Success; REQUEST(xXIListPropertiesReq); REQUEST_SIZE_MATCH(xXIListPropertiesReq); - rc = dixLookupDevice (&dev, stuff->deviceid, client, DixListPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixListPropAccess); if (rc != Success) return rc; @@ -1142,9 +1107,8 @@ ProcXIListProperties(ClientPtr client) rep.num_properties = natoms; WriteReplyToClient(client, sizeof(xXIListPropertiesReply), &rep); - if (natoms) - { - client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write; + if (natoms) { + client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms); free(atoms); } @@ -1154,16 +1118,16 @@ ProcXIListProperties(ClientPtr client) int ProcXIChangeProperty(ClientPtr client) { - int rc; - DeviceIntPtr dev; - int totalSize; - unsigned long len; + int rc; + DeviceIntPtr dev; + int totalSize; + unsigned long len; REQUEST(xXIChangePropertyReq); REQUEST_AT_LEAST_SIZE(xXIChangePropertyReq); UpdateCurrentTime(); - rc = dixLookupDevice (&dev, stuff->deviceid, client, DixSetPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); if (rc != Success) return rc; @@ -1173,29 +1137,29 @@ ProcXIChangeProperty(ClientPtr client) if (len > bytes_to_int32(0xffffffff - sizeof(xXIChangePropertyReq))) return BadLength; - totalSize = len * (stuff->format/8); + totalSize = len * (stuff->format / 8); REQUEST_FIXED_SIZE(xXIChangePropertyReq, totalSize); rc = change_property(client, dev, stuff->property, stuff->type, - stuff->format, stuff->mode, len, (void*)&stuff[1]); + stuff->format, stuff->mode, len, (void *) &stuff[1]); return rc; } int ProcXIDeleteProperty(ClientPtr client) { - DeviceIntPtr dev; - int rc; + DeviceIntPtr dev; + int rc; + REQUEST(xXIDeletePropertyReq); REQUEST_SIZE_MATCH(xXIDeletePropertyReq); UpdateCurrentTime(); - rc = dixLookupDevice (&dev, stuff->deviceid, client, DixSetPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, DixSetPropAccess); if (rc != Success) return rc; - if (!ValidAtom(stuff->property)) - { + if (!ValidAtom(stuff->property)) { client->errorValue = stuff->property; return BadAtom; } @@ -1204,30 +1168,28 @@ ProcXIDeleteProperty(ClientPtr client) return rc; } - int ProcXIGetProperty(ClientPtr client) { REQUEST(xXIGetPropertyReq); - DeviceIntPtr dev; - xXIGetPropertyReply reply; - int length; - int rc, format, nitems, bytes_after; - char *data; - Atom type; + DeviceIntPtr dev; + xXIGetPropertyReply reply; + int length; + int rc, format, nitems, bytes_after; + char *data; + Atom type; REQUEST_SIZE_MATCH(xXIGetPropertyReq); if (stuff->delete) UpdateCurrentTime(); - rc = dixLookupDevice (&dev, stuff->deviceid, client, - stuff->delete ? DixSetPropAccess : - DixGetPropAccess); + rc = dixLookupDevice(&dev, stuff->deviceid, client, + stuff->delete ? DixSetPropAccess : DixGetPropAccess); if (rc != Success) return rc; rc = get_property(client, dev, stuff->property, stuff->type, - stuff->delete, stuff->offset, stuff->len, - &bytes_after, &type, &format, &nitems, &length, &data); + stuff->delete, stuff->offset, stuff->len, + &bytes_after, &type, &format, &nitems, &length, &data); if (rc != Success) return rc; @@ -1246,24 +1208,28 @@ ProcXIGetProperty(ClientPtr client) WriteReplyToClient(client, sizeof(xXIGetPropertyReply), &reply); - if (length) - { + if (length) { switch (reply.format) { - case 32: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write; break; - case 16: client->pSwapReplyFunc = (ReplySwapPtr)CopySwap16Write; break; - default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break; + case 32: + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; + break; + case 16: + client->pSwapReplyFunc = (ReplySwapPtr) CopySwap16Write; + break; + default: + client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient; + break; } WriteSwappedDataToClient(client, length, data); } /* delete the Property */ - if (stuff->delete && (reply.bytes_after == 0)) - { + if (stuff->delete && (reply.bytes_after == 0)) { XIPropertyPtr prop, *prev; - for (prev = &dev->properties.properties; (prop = *prev); prev = &prop->next) - { - if (prop->propertyName == stuff->property) - { + + for (prev = &dev->properties.properties; (prop = *prev); + prev = &prop->next) { + if (prop->propertyName == stuff->property) { *prev = prop->next; XIDestroyDeviceProperty(prop); break; @@ -1327,21 +1293,18 @@ SProcXIGetProperty(ClientPtr client) return (ProcXIGetProperty(client)); } - void -SRepXIListProperties(ClientPtr client, int size, - xXIListPropertiesReply *rep) +SRepXIListProperties(ClientPtr client, int size, xXIListPropertiesReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); swaps(&rep->num_properties); /* properties will be swapped later, see ProcXIListProperties */ - WriteToClient(client, size, (char*)rep); + WriteToClient(client, size, (char *) rep); } void -SRepXIGetProperty(ClientPtr client, int size, - xXIGetPropertyReply *rep) +SRepXIGetProperty(ClientPtr client, int size, xXIGetPropertyReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); @@ -1349,5 +1312,5 @@ SRepXIGetProperty(ClientPtr client, int size, swapl(&rep->bytes_after); swapl(&rep->num_items); /* data will be swapped, see ProcXIGetProperty */ - WriteToClient(client, size, (char*)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/xiproperty.h b/xorg-server/Xi/xiproperty.h index a610e083c..482c834ed 100644 --- a/xorg-server/Xi/xiproperty.h +++ b/xorg-server/Xi/xiproperty.h @@ -1,68 +1,67 @@ -/*
- * Copyright © 2008 Peter Hutterer
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Author: Peter Hutterer
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifndef XIPROPERTY_H
-#define XIPROPERTY_H 1
-
-int ProcXListDeviceProperties (ClientPtr client);
-int ProcXChangeDeviceProperty (ClientPtr client);
-int ProcXDeleteDeviceProperty (ClientPtr client);
-int ProcXGetDeviceProperty (ClientPtr client);
-
-/* request swapping */
-int SProcXListDeviceProperties (ClientPtr client);
-int SProcXChangeDeviceProperty (ClientPtr client);
-int SProcXDeleteDeviceProperty (ClientPtr client);
-int SProcXGetDeviceProperty (ClientPtr client);
-
-/* reply swapping */
-void SRepXListDeviceProperties(ClientPtr client, int size,
- xListDevicePropertiesReply *rep);
-void SRepXGetDeviceProperty(ClientPtr client, int size,
- xGetDevicePropertyReply *rep);
-
-/* XI2 request/reply handling */
-int ProcXIListProperties (ClientPtr client);
-int ProcXIChangeProperty (ClientPtr client);
-int ProcXIDeleteProperty (ClientPtr client);
-int ProcXIGetProperty (ClientPtr client);
-
-int SProcXIListProperties (ClientPtr client);
-int SProcXIChangeProperty (ClientPtr client);
-int SProcXIDeleteProperty (ClientPtr client);
-int SProcXIGetProperty (ClientPtr client);
-
-void SRepXIListProperties(ClientPtr client, int size,
- xXIListPropertiesReply *rep);
-void SRepXIGetProperty(ClientPtr client, int size,
- xXIGetPropertyReply *rep);
-
-void XIResetProperties(void);
-
-#endif /* XIPROPERTY_H */
+/* + * Copyright © 2008 Peter Hutterer + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Peter Hutterer + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifndef XIPROPERTY_H +#define XIPROPERTY_H 1 + +int ProcXListDeviceProperties(ClientPtr client); +int ProcXChangeDeviceProperty(ClientPtr client); +int ProcXDeleteDeviceProperty(ClientPtr client); +int ProcXGetDeviceProperty(ClientPtr client); + +/* request swapping */ +int SProcXListDeviceProperties(ClientPtr client); +int SProcXChangeDeviceProperty(ClientPtr client); +int SProcXDeleteDeviceProperty(ClientPtr client); +int SProcXGetDeviceProperty(ClientPtr client); + +/* reply swapping */ +void SRepXListDeviceProperties(ClientPtr client, int size, + xListDevicePropertiesReply * rep); +void SRepXGetDeviceProperty(ClientPtr client, int size, + xGetDevicePropertyReply * rep); + +/* XI2 request/reply handling */ +int ProcXIListProperties(ClientPtr client); +int ProcXIChangeProperty(ClientPtr client); +int ProcXIDeleteProperty(ClientPtr client); +int ProcXIGetProperty(ClientPtr client); + +int SProcXIListProperties(ClientPtr client); +int SProcXIChangeProperty(ClientPtr client); +int SProcXIDeleteProperty(ClientPtr client); +int SProcXIGetProperty(ClientPtr client); + +void SRepXIListProperties(ClientPtr client, int size, + xXIListPropertiesReply * rep); +void SRepXIGetProperty(ClientPtr client, int size, xXIGetPropertyReply * rep); + +void XIResetProperties(void); + +#endif /* XIPROPERTY_H */ diff --git a/xorg-server/Xi/xiquerydevice.c b/xorg-server/Xi/xiquerydevice.c index 0879080ad..749bc24c9 100644 --- a/xorg-server/Xi/xiquerydevice.c +++ b/xorg-server/Xi/xiquerydevice.c @@ -47,9 +47,9 @@ static Bool ShouldSkipDevice(ClientPtr client, int deviceid, DeviceIntPtr d); static int -ListDeviceInfo(ClientPtr client, DeviceIntPtr dev, xXIDeviceInfo* info); + ListDeviceInfo(ClientPtr client, DeviceIntPtr dev, xXIDeviceInfo * info); static int SizeDeviceInfo(DeviceIntPtr dev); -static void SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info); +static void SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo * info); int SProcXIQueryDevice(ClientPtr client) { @@ -74,31 +74,27 @@ ProcXIQueryDevice(ClientPtr client) REQUEST(xXIQueryDeviceReq); REQUEST_SIZE_MATCH(xXIQueryDeviceReq); - if (stuff->deviceid != XIAllDevices && stuff->deviceid != XIAllMasterDevices) - { + if (stuff->deviceid != XIAllDevices && + stuff->deviceid != XIAllMasterDevices) { rc = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess); - if (rc != Success) - { + if (rc != Success) { client->errorValue = stuff->deviceid; return rc; } len += SizeDeviceInfo(dev); } - else - { + else { skip = calloc(sizeof(Bool), inputInfo.numDevices); if (!skip) return BadAlloc; - for (dev = inputInfo.devices; dev; dev = dev->next, i++) - { + for (dev = inputInfo.devices; dev; dev = dev->next, i++) { skip[i] = ShouldSkipDevice(client, stuff->deviceid, dev); if (!skip[i]) len += SizeDeviceInfo(dev); } - for (dev = inputInfo.off_devices; dev; dev = dev->next, i++) - { + for (dev = inputInfo.off_devices; dev; dev = dev->next, i++) { skip[i] = ShouldSkipDevice(client, stuff->deviceid, dev); if (!skip[i]) len += SizeDeviceInfo(dev); @@ -115,39 +111,34 @@ ProcXIQueryDevice(ClientPtr client) rep.repType = X_Reply; rep.RepType = X_XIQueryDevice; rep.sequenceNumber = client->sequence; - rep.length = len/4; + rep.length = len / 4; rep.num_devices = 0; ptr = info; - if (dev) - { - len = ListDeviceInfo(client, dev, (xXIDeviceInfo*)info); + if (dev) { + len = ListDeviceInfo(client, dev, (xXIDeviceInfo *) info); if (client->swapped) - SwapDeviceInfo(dev, (xXIDeviceInfo*)info); + SwapDeviceInfo(dev, (xXIDeviceInfo *) info); info += len; rep.num_devices = 1; - } else - { + } + else { i = 0; - for (dev = inputInfo.devices; dev; dev = dev->next, i++) - { - if (!skip[i]) - { - len = ListDeviceInfo(client, dev, (xXIDeviceInfo*)info); + for (dev = inputInfo.devices; dev; dev = dev->next, i++) { + if (!skip[i]) { + len = ListDeviceInfo(client, dev, (xXIDeviceInfo *) info); if (client->swapped) - SwapDeviceInfo(dev, (xXIDeviceInfo*)info); + SwapDeviceInfo(dev, (xXIDeviceInfo *) info); info += len; rep.num_devices++; } } - for (dev = inputInfo.off_devices; dev; dev = dev->next, i++) - { - if (!skip[i]) - { - len = ListDeviceInfo(client, dev, (xXIDeviceInfo*)info); + for (dev = inputInfo.off_devices; dev; dev = dev->next, i++) { + if (!skip[i]) { + len = ListDeviceInfo(client, dev, (xXIDeviceInfo *) info); if (client->swapped) - SwapDeviceInfo(dev, (xXIDeviceInfo*)info); + SwapDeviceInfo(dev, (xXIDeviceInfo *) info); info += len; rep.num_devices++; } @@ -163,7 +154,7 @@ ProcXIQueryDevice(ClientPtr client) } void -SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply *rep) +SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); @@ -171,10 +162,9 @@ SRepXIQueryDevice(ClientPtr client, int size, xXIQueryDeviceReply *rep) /* Device info is already swapped, see ProcXIQueryDevice */ - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } - /** * @return Whether the device should be included in the returned list. */ @@ -182,9 +172,9 @@ static Bool ShouldSkipDevice(ClientPtr client, int deviceid, DeviceIntPtr dev) { /* if all devices are not being queried, only master devices are */ - if (deviceid == XIAllDevices || IsMaster(dev)) - { + if (deviceid == XIAllDevices || IsMaster(dev)) { int rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGetAttrAccess); + if (rc == Success) return FALSE; } @@ -215,23 +205,22 @@ SizeDeviceClasses(DeviceIntPtr dev) { int len = 0; - if (dev->button) - { + if (dev->button) { len += sizeof(xXIButtonInfo); len += dev->button->numButtons * sizeof(Atom); len += pad_to_int32(bits_to_bytes(dev->button->numButtons)); } - if (dev->key) - { + if (dev->key) { XkbDescPtr xkb = dev->key->xkbInfo->desc; + len += sizeof(xXIKeyInfo); len += (xkb->max_key_code - xkb->min_key_code + 1) * sizeof(uint32_t); } - if (dev->valuator) - { + if (dev->valuator) { int i; + len += (sizeof(xXIValuatorInfo)) * dev->valuator->numAxes; for (i = 0; i < dev->valuator->numAxes; i++) { @@ -246,36 +235,35 @@ SizeDeviceClasses(DeviceIntPtr dev) return len; } - /** * Write button information into info. * @return Number of bytes written into info. */ int -ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState) +ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo * info, Bool reportState) { unsigned char *bits; int mask_len; int i; if (!dev || !dev->button) - return 0; + return 0; mask_len = bytes_to_int32(bits_to_bytes(dev->button->numButtons)); info->type = ButtonClass; info->num_buttons = dev->button->numButtons; info->length = bytes_to_int32(sizeof(xXIButtonInfo)) + - info->num_buttons + mask_len; + info->num_buttons + mask_len; info->sourceid = dev->button->sourceid; - bits = (unsigned char*)&info[1]; + bits = (unsigned char *) &info[1]; memset(bits, 0, mask_len * 4); if (reportState) - for (i = 0; i < dev->button->numButtons; i++) - if (BitIsOn(dev->button->down, i)) - SetBit(bits, i); + for (i = 0; i < dev->button->numButtons; i++) + if (BitIsOn(dev->button->down, i)) + SetBit(bits, i); bits += mask_len * 4; memcpy(bits, dev->button->labels, dev->button->numButtons * sizeof(Atom)); @@ -284,15 +272,16 @@ ListButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info, Bool reportState) } static void -SwapButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info) +SwapButtonInfo(DeviceIntPtr dev, xXIButtonInfo * info) { Atom *btn; int i; + swaps(&info->type); swaps(&info->length); swaps(&info->sourceid); - for (i = 0, btn = (Atom*)&info[1]; i < info->num_buttons; i++, btn++) + for (i = 0, btn = (Atom *) &info[1]; i < info->num_buttons; i++, btn++) swapl(btn); swaps(&info->num_buttons); @@ -303,7 +292,7 @@ SwapButtonInfo(DeviceIntPtr dev, xXIButtonInfo* info) * @return Number of bytes written into info. */ int -ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) +ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo * info) { int i; XkbDescPtr xkb = dev->key->xkbInfo->desc; @@ -311,10 +300,10 @@ ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) info->type = KeyClass; info->num_keycodes = xkb->max_key_code - xkb->min_key_code + 1; - info->length = sizeof(xXIKeyInfo)/4 + info->num_keycodes; + info->length = sizeof(xXIKeyInfo) / 4 + info->num_keycodes; info->sourceid = dev->key->sourceid; - kc = (uint32_t*)&info[1]; + kc = (uint32_t *) & info[1]; for (i = xkb->min_key_code; i <= xkb->max_key_code; i++, kc++) *kc = i; @@ -322,15 +311,17 @@ ListKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) } static void -SwapKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) +SwapKeyInfo(DeviceIntPtr dev, xXIKeyInfo * info) { uint32_t *key; int i; + swaps(&info->type); swaps(&info->length); swaps(&info->sourceid); - for (i = 0, key = (uint32_t*)&info[1]; i < info->num_keycodes; i++, key++) + for (i = 0, key = (uint32_t *) & info[1]; i < info->num_keycodes; + i++, key++) swapl(key); swaps(&info->num_keycodes); @@ -342,13 +333,13 @@ SwapKeyInfo(DeviceIntPtr dev, xXIKeyInfo* info) * @return The number of bytes written into info. */ int -ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber, - Bool reportState) +ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo * info, int axisnumber, + Bool reportState) { ValuatorClassPtr v = dev->valuator; info->type = ValuatorClass; - info->length = sizeof(xXIValuatorInfo)/4; + info->length = sizeof(xXIValuatorInfo) / 4; info->label = v->axes[axisnumber].label; info->min.integral = v->axes[axisnumber].min_value; info->min.frac = 0; @@ -361,13 +352,13 @@ ListValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info, int axisnumber, info->sourceid = v->sourceid; if (!reportState) - info->value = info->min; + info->value = info->min; return info->length * 4; } static void -SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info) +SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo * info) { swaps(&info->type); swaps(&info->length); @@ -381,7 +372,7 @@ SwapValuatorInfo(DeviceIntPtr dev, xXIValuatorInfo* info) } int -ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo *info, int axisnumber) +ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo * info, int axisnumber) { ValuatorClassPtr v = dev->valuator; AxisInfoPtr axis = &v->axes[axisnumber]; @@ -390,19 +381,19 @@ ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo *info, int axisnumber) return 0; info->type = XIScrollClass; - info->length = sizeof(xXIScrollInfo)/4; + info->length = sizeof(xXIScrollInfo) / 4; info->number = axisnumber; - switch(axis->scroll.type) - { - case SCROLL_TYPE_VERTICAL: - info->scroll_type = XIScrollTypeVertical; - break; - case SCROLL_TYPE_HORIZONTAL: - info->scroll_type = XIScrollTypeHorizontal; - break; - default: - ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", axis->scroll.type); - break; + switch (axis->scroll.type) { + case SCROLL_TYPE_VERTICAL: + info->scroll_type = XIScrollTypeVertical; + break; + case SCROLL_TYPE_HORIZONTAL: + info->scroll_type = XIScrollTypeHorizontal; + break; + default: + ErrorF("[Xi] Unknown scroll type %d. This is a bug.\n", + axis->scroll.type); + break; } info->increment = double_to_fp3232(axis->scroll.increment); info->sourceid = v->sourceid; @@ -418,7 +409,7 @@ ListScrollInfo(DeviceIntPtr dev, xXIScrollInfo *info, int axisnumber) } static void -SwapScrollInfo(DeviceIntPtr dev, xXIScrollInfo* info) +SwapScrollInfo(DeviceIntPtr dev, xXIScrollInfo * info) { swaps(&info->type); swaps(&info->length); @@ -435,7 +426,7 @@ SwapScrollInfo(DeviceIntPtr dev, xXIScrollInfo* info) * @return The number of bytes written into info. */ int -ListTouchInfo(DeviceIntPtr dev, xXITouchInfo *touch) +ListTouchInfo(DeviceIntPtr dev, xXITouchInfo * touch) { touch->type = XITouchClass; touch->length = sizeof(xXITouchInfo) >> 2; @@ -447,28 +438,30 @@ ListTouchInfo(DeviceIntPtr dev, xXITouchInfo *touch) } static void -SwapTouchInfo(DeviceIntPtr dev, xXITouchInfo* touch) +SwapTouchInfo(DeviceIntPtr dev, xXITouchInfo * touch) { swaps(&touch->type); swaps(&touch->length); swaps(&touch->sourceid); } -int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) +int +GetDeviceUse(DeviceIntPtr dev, uint16_t * attachment) { DeviceIntPtr master = GetMaster(dev, MASTER_ATTACHED); int use; - if (IsMaster(dev)) - { + if (IsMaster(dev)) { DeviceIntPtr paired = GetPairedDevice(dev); + use = IsPointerDevice(dev) ? XIMasterPointer : XIMasterKeyboard; *attachment = (paired ? paired->id : 0); - } else if (!IsFloating(dev)) - { + } + else if (!IsFloating(dev)) { use = IsPointerDevice(master) ? XISlavePointer : XISlaveKeyboard; *attachment = master->id; - } else + } + else use = XIFloatingSlave; return use; @@ -480,9 +473,9 @@ int GetDeviceUse(DeviceIntPtr dev, uint16_t *attachment) * @return The number of bytes used. */ static int -ListDeviceInfo(ClientPtr client, DeviceIntPtr dev, xXIDeviceInfo* info) +ListDeviceInfo(ClientPtr client, DeviceIntPtr dev, xXIDeviceInfo * info) { - char *any = (char*)&info[1]; + char *any = (char *) &info[1]; int len = 0, total_len = 0; info->deviceid = dev->id; @@ -509,7 +502,7 @@ ListDeviceInfo(ClientPtr client, DeviceIntPtr dev, xXIDeviceInfo* info) */ int ListDeviceClasses(ClientPtr client, DeviceIntPtr dev, - char *any, uint16_t *nclasses) + char *any, uint16_t * nclasses) { int total_len = 0; int len; @@ -519,43 +512,38 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev, /* Check if the current device state should be suppressed */ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixReadAccess); - if (dev->button) - { + if (dev->button) { (*nclasses)++; - len = ListButtonInfo(dev, (xXIButtonInfo*)any, rc == Success); + len = ListButtonInfo(dev, (xXIButtonInfo *) any, rc == Success); any += len; total_len += len; } - if (dev->key) - { + if (dev->key) { (*nclasses)++; - len = ListKeyInfo(dev, (xXIKeyInfo*)any); + len = ListKeyInfo(dev, (xXIKeyInfo *) any); any += len; total_len += len; } - for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++) - { + for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++) { (*nclasses)++; - len = ListValuatorInfo(dev, (xXIValuatorInfo*)any, i, rc == Success); + len = ListValuatorInfo(dev, (xXIValuatorInfo *) any, i, rc == Success); any += len; total_len += len; } - for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++) - { - len = ListScrollInfo(dev, (xXIScrollInfo*)any, i); + for (i = 0; dev->valuator && i < dev->valuator->numAxes; i++) { + len = ListScrollInfo(dev, (xXIScrollInfo *) any, i); if (len) (*nclasses)++; any += len; total_len += len; } - if (dev->touch) - { + if (dev->touch) { (*nclasses)++; - len = ListTouchInfo(dev, (xXITouchInfo*)any); + len = ListTouchInfo(dev, (xXITouchInfo *) any); any += len; total_len += len; } @@ -564,34 +552,33 @@ ListDeviceClasses(ClientPtr client, DeviceIntPtr dev, } static void -SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo* info) +SwapDeviceInfo(DeviceIntPtr dev, xXIDeviceInfo * info) { - char *any = (char*)&info[1]; + char *any = (char *) &info[1]; int i; /* Skip over name */ any += pad_to_int32(info->name_len); - for (i = 0; i < info->num_classes; i++) - { - int len = ((xXIAnyInfo*)any)->length; - switch(((xXIAnyInfo*)any)->type) - { - case XIButtonClass: - SwapButtonInfo(dev, (xXIButtonInfo*)any); - break; - case XIKeyClass: - SwapKeyInfo(dev, (xXIKeyInfo*)any); - break; - case XIValuatorClass: - SwapValuatorInfo(dev, (xXIValuatorInfo*)any); - break; - case XIScrollClass: - SwapScrollInfo(dev, (xXIScrollInfo*)any); - break; - case XITouchClass: - SwapTouchInfo(dev, (xXITouchInfo*)any); - break; + for (i = 0; i < info->num_classes; i++) { + int len = ((xXIAnyInfo *) any)->length; + + switch (((xXIAnyInfo *) any)->type) { + case XIButtonClass: + SwapButtonInfo(dev, (xXIButtonInfo *) any); + break; + case XIKeyClass: + SwapKeyInfo(dev, (xXIKeyInfo *) any); + break; + case XIValuatorClass: + SwapValuatorInfo(dev, (xXIValuatorInfo *) any); + break; + case XIScrollClass: + SwapScrollInfo(dev, (xXIScrollInfo *) any); + break; + case XITouchClass: + SwapTouchInfo(dev, (xXITouchInfo *) any); + break; } diff --git a/xorg-server/Xi/xiquerypointer.c b/xorg-server/Xi/xiquerypointer.c index d01a81394..a2e7442e0 100644 --- a/xorg-server/Xi/xiquerypointer.c +++ b/xorg-server/Xi/xiquerypointer.c @@ -33,10 +33,10 @@ #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> #include "extnsionst.h" @@ -78,30 +78,25 @@ ProcXIQueryPointer(ClientPtr client) SpritePtr pSprite; XkbStatePtr state; char *buttons = NULL; - int buttons_size = 0; /* size of buttons array */ + int buttons_size = 0; /* size of buttons array */ REQUEST(xXIQueryPointerReq); REQUEST_SIZE_MATCH(xXIQueryPointerReq); rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixReadAccess); - if (rc != Success) - { + if (rc != Success) { client->errorValue = stuff->deviceid; return rc; } - if (pDev->valuator == NULL || IsKeyboardDevice(pDev) || - (!IsMaster(pDev) && !IsFloating(pDev))) /* no attached devices */ - { + if (pDev->valuator == NULL || IsKeyboardDevice(pDev) || (!IsMaster(pDev) && !IsFloating(pDev))) { /* no attached devices */ client->errorValue = stuff->deviceid; return BadDevice; } rc = dixLookupWindow(&pWin, stuff->win, client, DixGetAttrAccess); - if (rc != Success) - { - SendErrorToClient(client, IReqCode, X_XIQueryPointer, - stuff->win, rc); + if (rc != Success) { + SendErrorToClient(client, IReqCode, X_XIQueryPointer, stuff->win, rc); return Success; } @@ -125,8 +120,7 @@ ProcXIQueryPointer(ClientPtr client) rep.root_y = FP1616(pSprite->hot.y, 0); rep.child = None; - if (kbd) - { + if (kbd) { state = &kbd->key->xkbInfo->state; rep.mods.base_mods = state->base_mods; rep.mods.latched_mods = state->latched_mods; @@ -137,10 +131,11 @@ ProcXIQueryPointer(ClientPtr client) rep.group.locked_group = state->locked_group; } - if (pDev->button) - { + if (pDev->button) { int i, down; - rep.buttons_len = bytes_to_int32(bits_to_bytes(pDev->button->numButtons)); + + rep.buttons_len = + bytes_to_int32(bits_to_bytes(pDev->button->numButtons)); rep.length += rep.buttons_len; buttons_size = rep.buttons_len * 4; buttons = calloc(1, buttons_size); @@ -149,41 +144,37 @@ ProcXIQueryPointer(ClientPtr client) down = pDev->button->buttonsDown; - for (i = 0; i < pDev->button->numButtons && down; i++) - { - if (BitIsOn(pDev->button->down, i)) - { + for (i = 0; i < pDev->button->numButtons && down; i++) { + if (BitIsOn(pDev->button->down, i)) { SetBit(buttons, i); down--; } } - } else + } + else rep.buttons_len = 0; - if (pSprite->hot.pScreen == pWin->drawable.pScreen) - { + if (pSprite->hot.pScreen == pWin->drawable.pScreen) { rep.same_screen = xTrue; rep.win_x = FP1616(pSprite->hot.x - pWin->drawable.x, 0); rep.win_y = FP1616(pSprite->hot.y - pWin->drawable.y, 0); for (t = pSprite->win; t; t = t->parent) - if (t->parent == pWin) - { + if (t->parent == pWin) { rep.child = t->drawable.id; break; } - } else - { + } + else { rep.same_screen = xFalse; rep.win_x = 0; rep.win_y = 0; } #ifdef PANORAMIX - if(!noPanoramiXExtension) { + if (!noPanoramiXExtension) { rep.root_x += FP1616(screenInfo.screens[0]->x, 0); rep.root_y += FP1616(screenInfo.screens[0]->y, 0); - if (stuff->win == rep.root) - { + if (stuff->win == rep.root) { rep.win_x += FP1616(screenInfo.screens[0]->x, 0); rep.win_y += FP1616(screenInfo.screens[0]->y, 0); } @@ -207,8 +198,7 @@ ProcXIQueryPointer(ClientPtr client) */ void -SRepXIQueryPointer(ClientPtr client, int size, - xXIQueryPointerReply * rep) +SRepXIQueryPointer(ClientPtr client, int size, xXIQueryPointerReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); @@ -220,6 +210,5 @@ SRepXIQueryPointer(ClientPtr client, int size, swapl(&rep->win_y); swaps(&rep->buttons_len); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } - diff --git a/xorg-server/Xi/xiqueryversion.c b/xorg-server/Xi/xiqueryversion.c index a94061432..fc0ca751b 100644 --- a/xorg-server/Xi/xiqueryversion.c +++ b/xorg-server/Xi/xiqueryversion.c @@ -33,7 +33,6 @@ #include <dix-config.h> #endif - #include "inputstr.h" #include <X11/Xmd.h> @@ -45,7 +44,8 @@ #include "xiqueryversion.h" #include "misc.h" -extern XExtensionVersion XIVersion; /* defined in getvers.c */ +extern XExtensionVersion XIVersion; /* defined in getvers.c */ + /** * Return the supported XI version. * @@ -63,21 +63,28 @@ ProcXIQueryVersion(ClientPtr client) REQUEST_SIZE_MATCH(xXIQueryVersionReq); /* This request only exists after XI2 */ - if (stuff->major_version < 2) - { + if (stuff->major_version < 2) { client->errorValue = stuff->major_version; return BadValue; } pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey); - if (version_compare(XIVersion.major_version, XIVersion.minor_version, - stuff->major_version, stuff->minor_version) > 0) + if (pXIClient->major_version && + (stuff->major_version != pXIClient->major_version || + stuff->minor_version != pXIClient->minor_version)) { + client->errorValue = stuff->major_version; + return BadValue; + } + + + if (version_compare(XIVersion.major_version, XIVersion.minor_version, + stuff->major_version, stuff->minor_version) > 0) { major = stuff->major_version; minor = stuff->minor_version; - } else - { + } + else { major = XIVersion.major_version; minor = XIVersion.minor_version; } @@ -112,11 +119,11 @@ SProcXIQueryVersion(ClientPtr client) } void -SRepXIQueryVersion(ClientPtr client, int size, xXIQueryVersionReply *rep) +SRepXIQueryVersion(ClientPtr client, int size, xXIQueryVersionReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); swaps(&rep->major_version); swaps(&rep->minor_version); - WriteToClient(client, size, (char *)rep); + WriteToClient(client, size, (char *) rep); } diff --git a/xorg-server/Xi/xiselectev.c b/xorg-server/Xi/xiselectev.c index 1b6c47a87..43a67c833 100644 --- a/xorg-server/Xi/xiselectev.c +++ b/xorg-server/Xi/xiselectev.c @@ -27,7 +27,6 @@ #include <dix-config.h> #endif - #include "dixstruct.h" #include "windowstr.h" #include "exglobals.h" @@ -43,15 +42,14 @@ * * @return BadValue if at least one invalid bit is set or Success otherwise. */ -int XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len) +int +XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len) { - if (len >= XIMaskLen(XI2LASTEVENT)) - { + if (len >= XIMaskLen(XI2LASTEVENT)) { int i; - for (i = XI2LASTEVENT + 1; i < len * 8; i++) - { - if (BitIsOn(mask, i)) - { + + for (i = XI2LASTEVENT + 1; i < len * 8; i++) { + if (BitIsOn(mask, i)) { client->errorValue = i; return BadValue; } @@ -65,7 +63,7 @@ int SProcXISelectEvents(ClientPtr client) { int i; - xXIEventMask* evmask; + xXIEventMask *evmask; REQUEST(xXISelectEventsReq); swaps(&stuff->length); @@ -73,12 +71,12 @@ SProcXISelectEvents(ClientPtr client) swapl(&stuff->win); swaps(&stuff->num_masks); - evmask = (xXIEventMask*)&stuff[1]; - for (i = 0; i < stuff->num_masks; i++) - { + evmask = (xXIEventMask *) &stuff[1]; + for (i = 0; i < stuff->num_masks; i++) { swaps(&evmask->deviceid); swaps(&evmask->mask_len); - evmask = (xXIEventMask*)(((char*)&evmask[1]) + evmask->mask_len * 4); + evmask = + (xXIEventMask *) (((char *) &evmask[1]) + evmask->mask_len * 4); } return (ProcXISelectEvents(client)); @@ -108,10 +106,9 @@ ProcXISelectEvents(ClientPtr client) len = sz_xXISelectEventsReq; /* check request validity */ - evmask = (xXIEventMask*)&stuff[1]; + evmask = (xXIEventMask *) &stuff[1]; num_masks = stuff->num_masks; - while(num_masks--) - { + while (num_masks--) { len += sizeof(xXIEventMask) + evmask->mask_len * 4; if (bytes_to_int32(len) > stuff->length) @@ -127,20 +124,19 @@ ProcXISelectEvents(ClientPtr client) return rc; /* hierarchy event mask is not allowed on devices */ - if (evmask->deviceid != XIAllDevices && evmask->mask_len >= 1) - { - unsigned char *bits = (unsigned char*)&evmask[1]; - if (BitIsOn(bits, XI_HierarchyChanged)) - { + if (evmask->deviceid != XIAllDevices && evmask->mask_len >= 1) { + unsigned char *bits = (unsigned char *) &evmask[1]; + + if (BitIsOn(bits, XI_HierarchyChanged)) { client->errorValue = XI_HierarchyChanged; return BadValue; } } /* Raw events may only be selected on root windows */ - if (win->parent && evmask->mask_len >= 1) - { - unsigned char *bits = (unsigned char*)&evmask[1]; + if (win->parent && evmask->mask_len >= 1) { + unsigned char *bits = (unsigned char *) &evmask[1]; + if (BitIsOn(bits, XI_RawKeyPress) || BitIsOn(bits, XI_RawKeyRelease) || BitIsOn(bits, XI_RawButtonPress) || @@ -148,16 +144,14 @@ ProcXISelectEvents(ClientPtr client) BitIsOn(bits, XI_RawMotion) || BitIsOn(bits, XI_RawTouchBegin) || BitIsOn(bits, XI_RawTouchUpdate) || - BitIsOn(bits, XI_RawTouchEnd)) - { + BitIsOn(bits, XI_RawTouchEnd)) { client->errorValue = XI_RawKeyPress; return BadValue; } } - if (evmask->mask_len >= 1) - { - unsigned char *bits = (unsigned char*)&evmask[1]; + if (evmask->mask_len >= 1) { + unsigned char *bits = (unsigned char *) &evmask[1]; /* All three touch events must be selected at once */ if ((BitIsOn(bits, XI_TouchBegin) || @@ -166,8 +160,7 @@ ProcXISelectEvents(ClientPtr client) BitIsOn(bits, XI_TouchEnd)) && (!BitIsOn(bits, XI_TouchBegin) || !BitIsOn(bits, XI_TouchUpdate) || - !BitIsOn(bits, XI_TouchEnd))) - { + !BitIsOn(bits, XI_TouchEnd))) { client->errorValue = XI_TouchBegin; return BadValue; } @@ -175,22 +168,22 @@ ProcXISelectEvents(ClientPtr client) /* Only one client per window may select for touch events on the * same devices, including master devices. * XXX: This breaks if a device goes from floating to attached. */ - if (BitIsOn(bits, XI_TouchBegin)) - { + if (BitIsOn(bits, XI_TouchBegin)) { OtherInputMasks *inputMasks = wOtherInputMasks(win); InputClients *iclient = NULL; + if (inputMasks) iclient = inputMasks->inputClients; - for (; iclient; iclient = iclient->next) - { + for (; iclient; iclient = iclient->next) { DeviceIntPtr dummy; if (CLIENT_ID(iclient->resource) == client->index) continue; - dixLookupDevice(&dummy, evmask->deviceid, serverClient, DixReadAccess); + dixLookupDevice(&dummy, evmask->deviceid, serverClient, + DixReadAccess); if (!dummy) - return BadImplementation; /* this shouldn't happen */ + return BadImplementation; /* this shouldn't happen */ if (xi2mask_isset(iclient->xi2mask, dummy, XI_TouchBegin)) return BadAccess; @@ -198,11 +191,13 @@ ProcXISelectEvents(ClientPtr client) } } - if (XICheckInvalidMaskBits(client, (unsigned char*)&evmask[1], + if (XICheckInvalidMaskBits(client, (unsigned char *) &evmask[1], evmask->mask_len * 4) != Success) return BadValue; - evmask = (xXIEventMask*)(((unsigned char*)evmask) + evmask->mask_len * 4); + evmask = + (xXIEventMask *) (((unsigned char *) evmask) + + evmask->mask_len * 4); evmask++; } @@ -210,21 +205,22 @@ ProcXISelectEvents(ClientPtr client) return BadLength; /* Set masks on window */ - evmask = (xXIEventMask*)&stuff[1]; + evmask = (xXIEventMask *) &stuff[1]; num_masks = stuff->num_masks; - while(num_masks--) - { + while (num_masks--) { if (evmask->deviceid == XIAllDevices || - evmask->deviceid == XIAllMasterDevices) - { + evmask->deviceid == XIAllMasterDevices) { dummy.id = evmask->deviceid; dev = &dummy; - } else + } + else dixLookupDevice(&dev, evmask->deviceid, client, DixUseAccess); if (XISetEventMask(dev, win, client, evmask->mask_len * 4, - (unsigned char*)&evmask[1]) != Success) + (unsigned char *) &evmask[1]) != Success) return BadAlloc; - evmask = (xXIEventMask*)(((unsigned char*)evmask) + evmask->mask_len * 4); + evmask = + (xXIEventMask *) (((unsigned char *) evmask) + + evmask->mask_len * 4); evmask++; } @@ -234,7 +230,6 @@ ProcXISelectEvents(ClientPtr client) return Success; } - int SProcXIGetSelectedEvents(ClientPtr client) { @@ -272,59 +267,53 @@ ProcXIGetSelectedEvents(ClientPtr client) reply.num_masks = 0; masks = wOtherInputMasks(win); - if (masks) - { - for (others = wOtherInputMasks(win)->inputClients; others; - others = others->next) { - if (SameClient(others, client)) { + if (masks) { + for (others = wOtherInputMasks(win)->inputClients; others; + others = others->next) { + if (SameClient(others, client)) { break; } } } - if (!others) - { + if (!others) { WriteReplyToClient(client, sizeof(xXIGetSelectedEventsReply), &reply); return Success; } - buffer = calloc(MAXDEVICES, sizeof(xXIEventMask) + pad_to_int32(XI2MASKSIZE)); + buffer = + calloc(MAXDEVICES, sizeof(xXIEventMask) + pad_to_int32(XI2MASKSIZE)); if (!buffer) return BadAlloc; - evmask = (xXIEventMask*)buffer; - for (i = 0; i < MAXDEVICES; i++) - { + evmask = (xXIEventMask *) buffer; + for (i = 0; i < MAXDEVICES; i++) { int j; const unsigned char *devmask = xi2mask_get_one_mask(others->xi2mask, i); - if (i > 2) - { + if (i > 2) { rc = dixLookupDevice(&dev, i, client, DixGetAttrAccess); if (rc != Success) continue; } + for (j = xi2mask_mask_size(others->xi2mask) - 1; j >= 0; j--) { + if (devmask[j] != 0) { + int mask_len = (j + 4) / 4; /* j is an index, hence + 4, not + 3 */ - for (j = xi2mask_mask_size(others->xi2mask) - 1; j >= 0; j--) - { - if (devmask[j] != 0) - { - int mask_len = (j + 4)/4; /* j is an index, hence + 4, not + 3 */ evmask->deviceid = i; evmask->mask_len = mask_len; reply.num_masks++; - reply.length += sizeof(xXIEventMask)/4 + evmask->mask_len; + reply.length += sizeof(xXIEventMask) / 4 + evmask->mask_len; - if (client->swapped) - { + if (client->swapped) { swaps(&evmask->deviceid); swaps(&evmask->mask_len); } memcpy(&evmask[1], devmask, j + 1); - evmask = (xXIEventMask*)((char*)evmask + - sizeof(xXIEventMask) + mask_len * 4); + evmask = (xXIEventMask *) ((char *) evmask + + sizeof(xXIEventMask) + mask_len * 4); break; } } @@ -339,13 +328,12 @@ ProcXIGetSelectedEvents(ClientPtr client) return Success; } -void SRepXIGetSelectedEvents(ClientPtr client, - int len, xXIGetSelectedEventsReply *rep) +void +SRepXIGetSelectedEvents(ClientPtr client, + int len, xXIGetSelectedEventsReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); swaps(&rep->num_masks); - WriteToClient(client, len, (char *)rep); + WriteToClient(client, len, (char *) rep); } - - diff --git a/xorg-server/Xi/xisetclientpointer.c b/xorg-server/Xi/xisetclientpointer.c index 934747d30..38ff51e86 100644 --- a/xorg-server/Xi/xisetclientpointer.c +++ b/xorg-server/Xi/xisetclientpointer.c @@ -30,16 +30,15 @@ * default value. */ - #ifdef HAVE_DIX_CONFIG_H #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> #include "extnsionst.h" @@ -69,36 +68,32 @@ ProcXISetClientPointer(ClientPtr client) REQUEST(xXISetClientPointerReq); REQUEST_SIZE_MATCH(xXISetClientPointerReq); - rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixManageAccess); - if (rc != Success) - { + if (rc != Success) { client->errorValue = stuff->deviceid; return rc; } - if (!IsMaster(pDev)) - { + if (!IsMaster(pDev)) { client->errorValue = stuff->deviceid; return BadDevice; } pDev = GetMaster(pDev, MASTER_POINTER); - if (stuff->win != None) - { + if (stuff->win != None) { rc = dixLookupClient(&targetClient, stuff->win, client, - DixManageAccess); + DixManageAccess); if (rc != Success) return BadWindow; - } else + } + else targetClient = client; rc = SetClientPointer(targetClient, pDev); - if (rc != Success) - { + if (rc != Success) { client->errorValue = stuff->deviceid; return rc; } diff --git a/xorg-server/Xi/xiwarppointer.c b/xorg-server/Xi/xiwarppointer.c index 11ab241b5..3f051f759 100644 --- a/xorg-server/Xi/xiwarppointer.c +++ b/xorg-server/Xi/xiwarppointer.c @@ -33,18 +33,17 @@ #include <dix-config.h> #endif -#include <X11/X.h> /* for inputstr.h */ -#include <X11/Xproto.h> /* Request macro */ -#include "inputstr.h" /* DeviceIntPtr */ -#include "windowstr.h" /* window structure */ -#include "scrnintstr.h" /* screen structure */ +#include <X11/X.h> /* for inputstr.h */ +#include <X11/Xproto.h> /* Request macro */ +#include "inputstr.h" /* DeviceIntPtr */ +#include "windowstr.h" /* window structure */ +#include "scrnintstr.h" /* screen structure */ #include <X11/extensions/XI.h> #include <X11/extensions/XI2proto.h> #include "extnsionst.h" #include "exevents.h" #include "exglobals.h" -#include "mipointer.h" /* for miPointerUpdateSprite */ - +#include "mipointer.h" /* for miPointerUpdateSprite */ #include "xiwarppointer.h" /*********************************************************************** @@ -89,24 +88,20 @@ ProcXIWarpPointer(ClientPtr client) rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess); - if (rc != Success) - { + if (rc != Success) { client->errorValue = stuff->deviceid; return rc; } if ((!IsMaster(pDev) && !IsFloating(pDev)) || - (IsMaster(pDev) && !IsPointerDevice(pDev))) - { + (IsMaster(pDev) && !IsPointerDevice(pDev))) { client->errorValue = stuff->deviceid; return BadDevice; } - if (stuff->dst_win != None) - { + if (stuff->dst_win != None) { rc = dixLookupWindow(&dest, stuff->dst_win, client, DixGetAttrAccess); - if (rc != Success) - { + if (rc != Success) { client->errorValue = stuff->dst_win; return rc; } @@ -116,19 +111,17 @@ ProcXIWarpPointer(ClientPtr client) x = pSprite->hotPhys.x; y = pSprite->hotPhys.y; - src_x = stuff->src_x / (double)(1 << 16); - src_y = stuff->src_y / (double)(1 << 16); - dst_x = stuff->dst_x / (double)(1 << 16); - dst_y = stuff->dst_y / (double)(1 << 16); + src_x = stuff->src_x / (double) (1 << 16); + src_y = stuff->src_y / (double) (1 << 16); + dst_x = stuff->dst_x / (double) (1 << 16); + dst_y = stuff->dst_y / (double) (1 << 16); - if (stuff->src_win != None) - { + if (stuff->src_win != None) { int winX, winY; WindowPtr src; rc = dixLookupWindow(&src, stuff->src_win, client, DixGetAttrAccess); - if (rc != Success) - { + if (rc != Success) { client->errorValue = stuff->src_win; return rc; } @@ -136,22 +129,22 @@ ProcXIWarpPointer(ClientPtr client) winX = src->drawable.x; winY = src->drawable.y; if (src->drawable.pScreen != pSprite->hotPhys.pScreen || - x < winX + src_x || - y < winY + src_y || - (stuff->src_width != 0 && - winX + src_x + (int)stuff->src_width < 0) || - (stuff->src_height != 0 && - winY + src_y + (int)stuff->src_height < y) || - !PointInWindowIsVisible(src, x, y)) + x < winX + src_x || + y < winY + src_y || + (stuff->src_width != 0 && + winX + src_x + (int) stuff->src_width < 0) || + (stuff->src_height != 0 && + winY + src_y + (int) stuff->src_height < y) || + !PointInWindowIsVisible(src, x, y)) return Success; } - if (dest) - { + if (dest) { x = dest->drawable.x; y = dest->drawable.y; newScreen = dest->drawable.pScreen; - } else + } + else newScreen = pSprite->hotPhys.pScreen; x += dst_x; @@ -167,8 +160,7 @@ ProcXIWarpPointer(ClientPtr client) else if (y > newScreen->height) y = newScreen->height - 1; - if (newScreen == pSprite->hotPhys.pScreen) - { + if (newScreen == pSprite->hotPhys.pScreen) { if (x < pSprite->physLimits.x1) x = pSprite->physLimits.x1; else if (x >= pSprite->physLimits.x2) @@ -181,9 +173,9 @@ ProcXIWarpPointer(ClientPtr client) if (pSprite->hotShape) ConfineToShape(pDev, pSprite->hotShape, &x, &y); - (*newScreen->SetCursorPosition)(pDev, newScreen, x, y, TRUE); - } else if (!PointerConfinedToScreen(pDev)) - { + (*newScreen->SetCursorPosition) (pDev, newScreen, x, y, TRUE); + } + else if (!PointerConfinedToScreen(pDev)) { NewCurrentScreen(pDev, newScreen, x, y); } @@ -196,4 +188,3 @@ ProcXIWarpPointer(ClientPtr client) here though. */ return Success; } - |