dix, Xext, Xtrap, Xi: replace inputInfo.pointer with PickPointer where

possible. More replacements to come.
This commit is contained in:
Peter Hutterer 2007-03-02 17:14:37 +10:30 committed by Peter Hutterer
parent e43b8a4e40
commit 57aa5e908d
7 changed files with 29 additions and 18 deletions

View File

@ -97,8 +97,8 @@ int XETrapSimulateXEvent(register xXTrapInputReq *request,
xEvent xev; xEvent xev;
register int x = request->input.x; register int x = request->input.x;
register int y = request->input.y; register int y = request->input.y;
DevicePtr keydev = LookupKeyboardDevice(); DevicePtr keydev = (DevicePtr)PickKeyboard(client);
DevicePtr ptrdev = LookupPointerDevice(); DevicePtr ptrdev = (DevicePtr)PickPointer(client);
if (request->input.screen < screenInfo.numScreens) if (request->input.screen < screenInfo.numScreens)
{ {

View File

@ -316,7 +316,7 @@ ProcXTestFakeInput(client)
#ifdef XINPUT #ifdef XINPUT
if (!extension) if (!extension)
#endif /* XINPUT */ #endif /* XINPUT */
dev = (DeviceIntPtr)LookupKeyboardDevice(); dev = PickKeyboard(client);
if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode ||
ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) ev->u.u.detail > dev->key->curKeySyms.maxKeyCode)
{ {
@ -361,7 +361,7 @@ ProcXTestFakeInput(client)
} }
#endif /* XINPUT */ #endif /* XINPUT */
if (!dev) if (!dev)
dev = (DeviceIntPtr*)LookupPointerDevice(); dev = PickPointer(client);
if (ev->u.keyButtonPointer.root == None) if (ev->u.keyButtonPointer.root == None)
root = GetCurrentRootWindow(); root = GetCurrentRootWindow();
else else
@ -451,7 +451,7 @@ ProcXTestFakeInput(client)
#ifdef XINPUT #ifdef XINPUT
if (!extension) if (!extension)
#endif /* XINPUT */ #endif /* XINPUT */
dev = (DeviceIntPtr*)LookupPointerDevice(); dev = PickPointer(client);
if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons) if (!ev->u.u.detail || ev->u.u.detail > dev->button->numButtons)
{ {
client->errorValue = ev->u.u.detail; client->errorValue = ev->u.u.detail;

View File

@ -140,7 +140,7 @@ ProcXGrabDeviceButton(ClientPtr client)
return Success; return Success;
} }
} else } else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = PickKeyboard(client);
class = (XEventClass *) (&stuff[1]); /* first word of values */ class = (XEventClass *) (&stuff[1]); /* first word of values */

View File

@ -137,7 +137,7 @@ ProcXGrabDeviceKey(ClientPtr client)
return Success; return Success;
} }
} else } else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = PickKeyboard(client);
class = (XEventClass *) (&stuff[1]); /* first word of values */ class = (XEventClass *) (&stuff[1]); /* first word of values */

View File

@ -133,7 +133,7 @@ ProcXUngrabDeviceButton(ClientPtr client)
return Success; return Success;
} }
} else } else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = PickKeyboard(client);
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess); rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
if (rc != Success) { if (rc != Success) {

View File

@ -132,7 +132,7 @@ ProcXUngrabDeviceKey(ClientPtr client)
return Success; return Success;
} }
} else } else
mdev = (DeviceIntPtr) LookupKeyboardDevice(); mdev = PickKeyboard(client);
rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess); rc = dixLookupWindow(&pWin, stuff->grabWindow, client, DixUnknownAccess);
if (rc != Success) { if (rc != Success) {

View File

@ -597,6 +597,8 @@ RemoveDevice(DeviceIntPtr dev)
int int
NumMotionEvents() NumMotionEvents()
{ {
/* only called to fill data in initial connection reply.
* VCP is ok here, it is the only fixed device we have. */
return inputInfo.pointer->valuator->numMotionEvents; return inputInfo.pointer->valuator->numMotionEvents;
} }
@ -1376,6 +1378,7 @@ ProcSetPointerMapping(ClientPtr client)
REQUEST(xSetPointerMappingReq); REQUEST(xSetPointerMappingReq);
BYTE *map; BYTE *map;
int ret; int ret;
DeviceIntPtr ptr = PickPointer(client);
xSetPointerMappingReply rep; xSetPointerMappingReply rep;
REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq); REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
@ -1389,14 +1392,18 @@ ProcSetPointerMapping(ClientPtr client)
/* So we're bounded here by the number of core buttons. This check /* So we're bounded here by the number of core buttons. This check
* probably wants disabling through XFixes. */ * probably wants disabling through XFixes. */
if (stuff->nElts != inputInfo.pointer->button->numButtons) { /* MPX: With ClientPointer, we can return the right number of buttons.
* Let's just hope nobody changed ClientPointer between GetPointerMapping
* and SetPointerMapping
*/
if (stuff->nElts != ptr->button->numButtons) {
client->errorValue = stuff->nElts; client->errorValue = stuff->nElts;
return BadValue; return BadValue;
} }
if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue)) if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue))
return BadValue; return BadValue;
ret = DoSetPointerMapping(inputInfo.pointer, map, stuff->nElts); ret = DoSetPointerMapping(ptr, map, stuff->nElts);
if (ret != Success) { if (ret != Success) {
rep.success = ret; rep.success = ret;
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
@ -1404,7 +1411,7 @@ ProcSetPointerMapping(ClientPtr client)
} }
/* FIXME: Send mapping notifies for all the extended devices as well. */ /* FIXME: Send mapping notifies for all the extended devices as well. */
SendMappingNotify(inputInfo.pointer, MappingPointer, 0, 0, client); SendMappingNotify(ptr, MappingPointer, 0, 0, client);
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep); WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
return Success; return Success;
} }
@ -1414,7 +1421,8 @@ ProcGetKeyboardMapping(ClientPtr client)
{ {
xGetKeyboardMappingReply rep; xGetKeyboardMappingReply rep;
REQUEST(xGetKeyboardMappingReq); REQUEST(xGetKeyboardMappingReq);
KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms; DeviceIntPtr kbd = PickKeyboard(client);
KeySymsPtr curKeySyms = &kbd->key->curKeySyms;
REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); REQUEST_SIZE_MATCH(xGetKeyboardMappingReq);
@ -1449,7 +1457,9 @@ int
ProcGetPointerMapping(ClientPtr client) ProcGetPointerMapping(ClientPtr client)
{ {
xGetPointerMappingReply rep; xGetPointerMappingReply rep;
ButtonClassPtr butc = inputInfo.pointer->button; /* Apps may get different values each time they call GetPointerMapping as
* the ClientPointer could change. */
ButtonClassPtr butc = PickPointer(client)->button;
REQUEST_SIZE_MATCH(xReq); REQUEST_SIZE_MATCH(xReq);
rep.type = X_Reply; rep.type = X_Reply;
@ -1753,7 +1763,7 @@ ProcBell(ClientPtr client)
int int
ProcChangePointerControl(ClientPtr client) ProcChangePointerControl(ClientPtr client)
{ {
DeviceIntPtr mouse = inputInfo.pointer; DeviceIntPtr mouse = PickPointer(client);
PtrCtrl ctrl; /* might get BadValue part way through */ PtrCtrl ctrl; /* might get BadValue part way through */
REQUEST(xChangePointerControlReq); REQUEST(xChangePointerControlReq);
@ -1809,7 +1819,7 @@ ProcChangePointerControl(ClientPtr client)
for (mouse = inputInfo.devices; mouse; mouse = mouse->next) { for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
if ((mouse->coreEvents || mouse == inputInfo.pointer) && if ((mouse->coreEvents || mouse == PickPointer(client)) &&
mouse->ptrfeed && mouse->ptrfeed->CtrlProc) { mouse->ptrfeed && mouse->ptrfeed->CtrlProc) {
mouse->ptrfeed->ctrl = ctrl; mouse->ptrfeed->ctrl = ctrl;
(*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl); (*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl);
@ -1822,7 +1832,8 @@ ProcChangePointerControl(ClientPtr client)
int int
ProcGetPointerControl(ClientPtr client) ProcGetPointerControl(ClientPtr client)
{ {
register PtrCtrl *ctrl = &inputInfo.pointer->ptrfeed->ctrl; DeviceIntPtr ptr = PickPointer(client);
PtrCtrl *ctrl = &ptr->ptrfeed->ctrl;
xGetPointerControlReply rep; xGetPointerControlReply rep;
REQUEST_SIZE_MATCH(xReq); REQUEST_SIZE_MATCH(xReq);
@ -1860,7 +1871,7 @@ ProcGetMotionEvents(ClientPtr client)
xGetMotionEventsReply rep; xGetMotionEventsReply rep;
int i, count, xmin, xmax, ymin, ymax, rc; int i, count, xmin, xmax, ymin, ymax, rc;
unsigned long nEvents; unsigned long nEvents;
DeviceIntPtr mouse = inputInfo.pointer; DeviceIntPtr mouse = PickPointer(client);
TimeStamp start, stop; TimeStamp start, stop;
REQUEST(xGetMotionEventsReq); REQUEST(xGetMotionEventsReq);