diff options
author | Keith Packard <keithp@keithp.com> | 2012-03-21 12:55:09 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-03-21 13:54:42 -0700 |
commit | 9838b7032ea9792bec21af424c53c07078636d21 (patch) | |
tree | b72d0827dac50f0f3b8eab29b3b7639546d735d7 /Xext/xtest.c | |
parent | 75199129c603fc8567185ac31866c9518193cb78 (diff) |
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:
-bap
-psl
-T PrivatePtr
-T pmWait
-T _XFUNCPROTOBEGIN
-T _XFUNCPROTOEND
-T _X_EXPORT
The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.
The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.
The comparison was done with this script:
dir1=$1
dir2=$2
for dir in $dir1 $dir2; do
(cd $dir && find . -name '*.o' | while read file; do
dir=`dirname $file`
base=`basename $file .o`
dump=$dir/$base.dump
objdump -d $file > $dump
done)
done
find $dir1 -name '*.dump' | while read dump; do
otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
diff -u $dump $otherdump
done
Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'Xext/xtest.c')
-rw-r--r-- | Xext/xtest.c | 459 |
1 files changed, 221 insertions, 238 deletions
diff --git a/Xext/xtest.c b/Xext/xtest.c index bd8e1d3a7..241445759 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -62,7 +62,7 @@ extern int DeviceValuator; /* XTest events are sent during request processing and may be interruped by * a SIGIO. We need a separate event list to avoid events overwriting each * other's memory */ -static InternalEvent* xtest_evlist; +static InternalEvent *xtest_evlist; /** * xtestpointer @@ -81,11 +81,9 @@ DeviceIntPtr xtestpointer, xtestkeyboard; #include "panoramiXsrv.h" #endif -static int XTestSwapFakeInput( - ClientPtr /* client */, - xReq * /* req */ - ); - +static int XTestSwapFakeInput(ClientPtr /* client */ , + xReq * /* req */ + ); static int ProcXTestGetVersion(ClientPtr client) @@ -102,7 +100,7 @@ ProcXTestGetVersion(ClientPtr client) swaps(&rep.sequenceNumber); swaps(&rep.minorVersion); } - WriteToClient(client, sizeof(xXTestGetVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xXTestGetVersionReply), (char *) &rep); return Success; } @@ -125,10 +123,9 @@ ProcXTestCompareCursor(ClientPtr client) else if (stuff->cursor == XTestCurrentCursor) pCursor = GetSpriteCursor(ptr); else { - rc = dixLookupResourceByType((pointer *)&pCursor, stuff->cursor, RT_CURSOR, - client, DixReadAccess); - if (rc != Success) - { + rc = dixLookupResourceByType((pointer *) &pCursor, stuff->cursor, + RT_CURSOR, client, DixReadAccess); + if (rc != Success) { client->errorValue = stuff->cursor; return rc; } @@ -140,7 +137,7 @@ ProcXTestCompareCursor(ClientPtr client) if (client->swapped) { swaps(&rep.sequenceNumber); } - WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *)&rep); + WriteToClient(client, sizeof(xXTestCompareCursorReply), (char *) &rep); return Success; } @@ -155,7 +152,7 @@ ProcXTestFakeInput(ClientPtr client) Bool extension = FALSE; deviceValuator *dv = NULL; ValuatorMask mask; - int valuators[MAX_VALUATORS] = {0}; + int valuators[MAX_VALUATORS] = { 0 }; int numValuators = 0; int firstValuator = 0; int nevents = 0; @@ -169,18 +166,16 @@ ProcXTestFakeInput(ClientPtr client) return BadLength; nev /= sizeof(xEvent); UpdateCurrentTime(); - ev = (xEvent *)&((xReq *)stuff)[1]; + ev = (xEvent *) &((xReq *) stuff)[1]; type = ev->u.u.type & 0177; - if (type >= EXTENSION_EVENT_BASE) - { + if (type >= EXTENSION_EVENT_BASE) { extension = TRUE; /* check device */ rc = dixLookupDevice(&dev, stuff->deviceid & 0177, client, - DixWriteAccess); - if (rc != Success) - { + DixWriteAccess); + if (rc != Success) { client->errorValue = stuff->deviceid & 0177; return rc; } @@ -188,144 +183,135 @@ ProcXTestFakeInput(ClientPtr client) /* check type */ type -= DeviceValuator; switch (type) { - case XI_DeviceKeyPress: - case XI_DeviceKeyRelease: - if (!dev->key) - { - client->errorValue = ev->u.u.type; - return BadValue; - } - break; - case XI_DeviceButtonPress: - case XI_DeviceButtonRelease: - if (!dev->button) - { - client->errorValue = ev->u.u.type; - return BadValue; - } - break; - case XI_DeviceMotionNotify: - if (!dev->valuator) - { - client->errorValue = ev->u.u.type; - return BadValue; - } - break; - case XI_ProximityIn: - case XI_ProximityOut: - if (!dev->proximity) - { - client->errorValue = ev->u.u.type; - return BadValue; - } - break; - default: + case XI_DeviceKeyPress: + case XI_DeviceKeyRelease: + if (!dev->key) { client->errorValue = ev->u.u.type; return BadValue; + } + break; + case XI_DeviceButtonPress: + case XI_DeviceButtonRelease: + if (!dev->button) { + client->errorValue = ev->u.u.type; + return BadValue; + } + break; + case XI_DeviceMotionNotify: + if (!dev->valuator) { + client->errorValue = ev->u.u.type; + return BadValue; + } + break; + case XI_ProximityIn: + case XI_ProximityOut: + if (!dev->proximity) { + client->errorValue = ev->u.u.type; + return BadValue; + } + break; + default: + client->errorValue = ev->u.u.type; + return BadValue; } /* check validity */ if (nev == 1 && type == XI_DeviceMotionNotify) - return BadLength; /* DevMotion must be followed by DevValuator */ + return BadLength; /* DevMotion must be followed by DevValuator */ - if (type == XI_DeviceMotionNotify) - { - firstValuator = ((deviceValuator *)(ev+1))->first_valuator; - if (firstValuator > dev->valuator->numAxes) - { + if (type == XI_DeviceMotionNotify) { + firstValuator = ((deviceValuator *) (ev + 1))->first_valuator; + if (firstValuator > dev->valuator->numAxes) { client->errorValue = ev->u.u.type; return BadValue; } if (ev->u.u.detail == xFalse) flags |= POINTER_ABSOLUTE; - } else - { + } + else { firstValuator = 0; flags |= POINTER_ABSOLUTE; } - if (nev > 1 && !dev->valuator) - { + if (nev > 1 && !dev->valuator) { client->errorValue = dv->first_valuator; return BadValue; } - /* check validity of valuator events */ base = firstValuator; - for (n = 1; n < nev; n++) - { - dv = (deviceValuator *)(ev + n); - if (dv->type != DeviceValuator) - { + for (n = 1; n < nev; n++) { + dv = (deviceValuator *) (ev + n); + if (dv->type != DeviceValuator) { client->errorValue = dv->type; return BadValue; } - if (dv->first_valuator != base) - { + if (dv->first_valuator != base) { client->errorValue = dv->first_valuator; return BadValue; } - switch(dv->num_valuators) - { - case 6: valuators[base + 5] = dv->valuator5; - case 5: valuators[base + 4] = dv->valuator4; - case 4: valuators[base + 3] = dv->valuator3; - case 3: valuators[base + 2] = dv->valuator2; - case 2: valuators[base + 1] = dv->valuator1; - case 1: valuators[base] = dv->valuator0; - break; - default: - client->errorValue = dv->num_valuators; - return BadValue; + switch (dv->num_valuators) { + case 6: + valuators[base + 5] = dv->valuator5; + case 5: + valuators[base + 4] = dv->valuator4; + case 4: + valuators[base + 3] = dv->valuator3; + case 3: + valuators[base + 2] = dv->valuator2; + case 2: + valuators[base + 1] = dv->valuator1; + case 1: + valuators[base] = dv->valuator0; + break; + default: + client->errorValue = dv->num_valuators; + return BadValue; } base += dv->num_valuators; numValuators += dv->num_valuators; - if (firstValuator + numValuators > dev->valuator->numAxes) - { + if (firstValuator + numValuators > dev->valuator->numAxes) { client->errorValue = dv->num_valuators; return BadValue; } } type = type - XI_DeviceKeyPress + KeyPress; - } else - { + } + else { if (nev != 1) return BadLength; - switch (type) - { - case KeyPress: - case KeyRelease: - dev = PickKeyboard(client); - break; - case ButtonPress: - case ButtonRelease: - dev = PickPointer(client); - break; - case MotionNotify: - dev = PickPointer(client); - valuators[0] = ev->u.keyButtonPointer.rootX; - valuators[1] = ev->u.keyButtonPointer.rootY; - numValuators = 2; - firstValuator = 0; - if (ev->u.u.detail == xFalse) - flags = POINTER_ABSOLUTE | POINTER_SCREEN; - break; - default: - client->errorValue = ev->u.u.type; - return BadValue; + switch (type) { + case KeyPress: + case KeyRelease: + dev = PickKeyboard(client); + break; + case ButtonPress: + case ButtonRelease: + dev = PickPointer(client); + break; + case MotionNotify: + dev = PickPointer(client); + valuators[0] = ev->u.keyButtonPointer.rootX; + valuators[1] = ev->u.keyButtonPointer.rootY; + numValuators = 2; + firstValuator = 0; + if (ev->u.u.detail == xFalse) + flags = POINTER_ABSOLUTE | POINTER_SCREEN; + break; + default: + client->errorValue = ev->u.u.type; + return BadValue; } dev = GetXTestDevice(dev); } /* If the event has a time set, wait for it to pass */ - if (ev->u.keyButtonPointer.time) - { + if (ev->u.keyButtonPointer.time) { TimeStamp activateTime; CARD32 ms; @@ -339,92 +325,85 @@ ProcXTestFakeInput(ClientPtr client) /* see mbuf.c:QueueDisplayRequest (from the deprecated Multibuffer * extension) for code similar to this */ - if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) - { + if (!ClientSleepUntil(client, &activateTime, NULL, NULL)) { return BadAlloc; } /* swap the request back so we can simply re-execute it */ - if (client->swapped) - { - (void) XTestSwapFakeInput(client, (xReq *)stuff); + if (client->swapped) { + (void) XTestSwapFakeInput(client, (xReq *) stuff); swaps(&stuff->length); } - ResetCurrentRequest (client); + ResetCurrentRequest(client); client->sequence--; return Success; } - switch (type) - { - case KeyPress: - case KeyRelease: - if (!dev->key) - return BadDevice; + switch (type) { + case KeyPress: + case KeyRelease: + if (!dev->key) + return BadDevice; - if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code || - ev->u.u.detail > dev->key->xkbInfo->desc->max_key_code) - { - client->errorValue = ev->u.u.detail; - return BadValue; - } + if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code || + ev->u.u.detail > dev->key->xkbInfo->desc->max_key_code) { + client->errorValue = ev->u.u.detail; + return BadValue; + } - need_ptr_update = 0; - break; - case MotionNotify: - if (!dev->valuator) - return BadDevice; - - if (!(extension || ev->u.keyButtonPointer.root == None)) - { - rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root, - client, DixGetAttrAccess); - if (rc != Success) - return rc; - if (root->parent) - { - client->errorValue = ev->u.keyButtonPointer.root; - return BadValue; - } - } - if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse) - { - client->errorValue = ev->u.u.detail; + need_ptr_update = 0; + break; + case MotionNotify: + if (!dev->valuator) + return BadDevice; + + if (!(extension || ev->u.keyButtonPointer.root == None)) { + rc = dixLookupWindow(&root, ev->u.keyButtonPointer.root, + client, DixGetAttrAccess); + if (rc != Success) + return rc; + if (root->parent) { + client->errorValue = ev->u.keyButtonPointer.root; return BadValue; } + } + if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse) { + client->errorValue = ev->u.u.detail; + return BadValue; + } - /* FIXME: Xinerama! */ + /* FIXME: Xinerama! */ - break; - case ButtonPress: - case ButtonRelease: - if (!dev->button) - return BadDevice; + break; + case ButtonPress: + case ButtonRelease: + if (!dev->button) + return BadDevice; - if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) - { - client->errorValue = ev->u.u.detail; - return BadValue; - } - break; + if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) { + client->errorValue = ev->u.u.detail; + return BadValue; + } + break; } if (screenIsSaved == SCREEN_SAVER_ON) dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset); - switch(type) { - case MotionNotify: - valuator_mask_set_range(&mask, firstValuator, numValuators, valuators); - nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags, &mask); - break; - case ButtonPress: - case ButtonRelease: - valuator_mask_set_range(&mask, firstValuator, numValuators, valuators); - nevents = GetPointerEvents(xtest_evlist, dev, type, ev->u.u.detail, - flags, &mask); - break; - case KeyPress: - case KeyRelease: - nevents = GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail, NULL); - break; + switch (type) { + case MotionNotify: + valuator_mask_set_range(&mask, firstValuator, numValuators, valuators); + nevents = GetPointerEvents(xtest_evlist, dev, type, 0, flags, &mask); + break; + case ButtonPress: + case ButtonRelease: + valuator_mask_set_range(&mask, firstValuator, numValuators, valuators); + nevents = GetPointerEvents(xtest_evlist, dev, type, ev->u.u.detail, + flags, &mask); + break; + case KeyPress: + case KeyRelease: + nevents = + GetKeyboardEvents(xtest_evlist, dev, type, ev->u.u.detail, NULL); + break; } for (i = 0; i < nevents; i++) @@ -441,8 +420,7 @@ ProcXTestGrabControl(ClientPtr client) REQUEST(xXTestGrabControlReq); REQUEST_SIZE_MATCH(xXTestGrabControlReq); - if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) - { + if ((stuff->impervious != xTrue) && (stuff->impervious != xFalse)) { client->errorValue = stuff->impervious; return BadValue; } @@ -454,21 +432,20 @@ ProcXTestGrabControl(ClientPtr client) } static int -ProcXTestDispatch (ClientPtr client) +ProcXTestDispatch(ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { - case X_XTestGetVersion: - return ProcXTestGetVersion(client); - case X_XTestCompareCursor: - return ProcXTestCompareCursor(client); - case X_XTestFakeInput: - return ProcXTestFakeInput(client); - case X_XTestGrabControl: - return ProcXTestGrabControl(client); - default: - return BadRequest; + switch (stuff->data) { + case X_XTestGetVersion: + return ProcXTestGetVersion(client); + case X_XTestCompareCursor: + return ProcXTestCompareCursor(client); + case X_XTestFakeInput: + return ProcXTestFakeInput(client); + case X_XTestGrabControl: + return ProcXTestGrabControl(client); + default: + return BadRequest; } } @@ -496,7 +473,7 @@ SProcXTestCompareCursor(ClientPtr client) } static int -XTestSwapFakeInput(ClientPtr client, xReq *req) +XTestSwapFakeInput(ClientPtr client, xReq * req) { int nev; xEvent *ev; @@ -504,16 +481,15 @@ XTestSwapFakeInput(ClientPtr client, xReq *req) EventSwapPtr proc; nev = ((req->length << 2) - sizeof(xReq)) / sizeof(xEvent); - for (ev = (xEvent *)&req[1]; --nev >= 0; ev++) - { + for (ev = (xEvent *) &req[1]; --nev >= 0; ev++) { /* Swap event */ proc = EventSwapVector[ev->u.u.type & 0177]; /* no swapping proc; invalid event type? */ - if (!proc || proc == NotImplemented) { + if (!proc || proc == NotImplemented) { client->errorValue = ev->u.u.type; return BadValue; } - (*proc)(ev, &sev); + (*proc) (ev, &sev); *ev = sev; } return Success; @@ -522,7 +498,8 @@ XTestSwapFakeInput(ClientPtr client, xReq *req) static int SProcXTestFakeInput(ClientPtr client) { - int n; + int n; + REQUEST(xReq); swaps(&stuff->length); @@ -543,21 +520,20 @@ SProcXTestGrabControl(ClientPtr client) } static int -SProcXTestDispatch (ClientPtr client) +SProcXTestDispatch(ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { - case X_XTestGetVersion: - return SProcXTestGetVersion(client); - case X_XTestCompareCursor: - return SProcXTestCompareCursor(client); - case X_XTestFakeInput: - return SProcXTestFakeInput(client); - case X_XTestGrabControl: - return SProcXTestGrabControl(client); - default: - return BadRequest; + switch (stuff->data) { + case X_XTestGetVersion: + return SProcXTestGetVersion(client); + case X_XTestCompareCursor: + return SProcXTestCompareCursor(client); + case X_XTestFakeInput: + return SProcXTestFakeInput(client); + case X_XTestGrabControl: + return SProcXTestGrabControl(client); + default: + return BadRequest; } } @@ -565,21 +541,22 @@ SProcXTestDispatch (ClientPtr client) * Allocate an virtual slave device for xtest events, this * is a slave device to inputInfo master devices */ -void InitXTestDevices(void) +void +InitXTestDevices(void) { - if(AllocXTestDevice(serverClient, "Virtual core", - &xtestpointer, &xtestkeyboard, - inputInfo.pointer, inputInfo.keyboard) != Success) - FatalError("Failed to allocate XTest devices"); + if (AllocXTestDevice(serverClient, "Virtual core", + &xtestpointer, &xtestkeyboard, + inputInfo.pointer, inputInfo.keyboard) != Success) + FatalError("Failed to allocate XTest devices"); if (ActivateDevice(xtestpointer, TRUE) != Success || ActivateDevice(xtestkeyboard, TRUE) != Success) FatalError("Failed to activate XTest core devices."); - if (!EnableDevice(xtestpointer, TRUE) || - !EnableDevice(xtestkeyboard, TRUE)) + if (!EnableDevice(xtestpointer, TRUE) || !EnableDevice(xtestkeyboard, TRUE)) FatalError("Failed to enable XTest core devices."); AttachDevice(NULL, xtestpointer, inputInfo.pointer); + AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard); } @@ -588,7 +565,7 @@ void InitXTestDevices(void) */ static int DeviceSetXTestProperty(DeviceIntPtr dev, Atom property, - XIPropertyValuePtr prop, BOOL checkonly) + XIPropertyValuePtr prop, BOOL checkonly) { if (property == XIGetKnownProperty(XI_PROP_XTEST_DEVICE)) return BadAccess; @@ -603,35 +580,42 @@ DeviceSetXTestProperty(DeviceIntPtr dev, Atom property, * This only creates the pair, Activate/Enable Device * still need to be called. */ -int AllocXTestDevice (ClientPtr client, const char* name, - DeviceIntPtr* ptr, DeviceIntPtr* keybd, - DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) +int +AllocXTestDevice(ClientPtr client, const char *name, + DeviceIntPtr *ptr, DeviceIntPtr *keybd, + DeviceIntPtr master_ptr, DeviceIntPtr master_keybd) { int retval; char *xtestname; char dummy = 1; if (asprintf(&xtestname, "%s XTEST", name) == -1) - return BadAlloc; + return BadAlloc; - retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE); - if ( retval == Success ){ - (*ptr)->xtest_master_id = master_ptr->id; - (*keybd)->xtest_master_id = master_keybd->id; + retval = + AllocDevicePair(client, xtestname, ptr, keybd, CorePointerProc, + CoreKeyboardProc, FALSE); + if (retval == Success) { + (*ptr)->xtest_master_id = master_ptr->id; + (*keybd)->xtest_master_id = master_keybd->id; XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), - XA_INTEGER, 8, PropModeReplace, 1, &dummy, - FALSE); - XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); + XA_INTEGER, 8, PropModeReplace, 1, &dummy, + FALSE); + XISetDevicePropertyDeletable(*ptr, + XIGetKnownProperty(XI_PROP_XTEST_DEVICE), + FALSE); XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL); XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), - XA_INTEGER, 8, PropModeReplace, 1, &dummy, - FALSE); - XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE); + XA_INTEGER, 8, PropModeReplace, 1, &dummy, + FALSE); + XISetDevicePropertyDeletable(*keybd, + XIGetKnownProperty(XI_PROP_XTEST_DEVICE), + FALSE); XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL); } - free( xtestname ); + free(xtestname); return retval; } @@ -651,7 +635,7 @@ IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master) /* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest * device */ if (master) - return dev->xtest_master_id == master->id; + return dev->xtest_master_id == master->id; return dev->xtest_master_id != 0; } @@ -664,8 +648,7 @@ GetXTestDevice(DeviceIntPtr master) { DeviceIntPtr it; - for (it = inputInfo.devices; it; it = it->next) - { + for (it = inputInfo.devices; it; it = it->next) { if (IsXTestDevice(it, master)) return it; } @@ -675,7 +658,7 @@ GetXTestDevice(DeviceIntPtr master) } static void -XTestExtensionTearDown(ExtensionEntry *e) +XTestExtensionTearDown(ExtensionEntry * e) { FreeEventList(xtest_evlist, GetMaximumEventsNum()); xtest_evlist = NULL; @@ -685,8 +668,8 @@ void XTestExtensionInit(INITARGS) { AddExtension(XTestExtensionName, 0, 0, - ProcXTestDispatch, SProcXTestDispatch, - XTestExtensionTearDown, StandardMinorOpcode); + ProcXTestDispatch, SProcXTestDispatch, + XTestExtensionTearDown, StandardMinorOpcode); xtest_evlist = InitEventList(GetMaximumEventsNum()); } |