diff --git a/Xi/extinit.c b/Xi/extinit.c index c3c96dc048..5f2e313a93 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -460,9 +460,9 @@ SProcIDispatch(ClientPtr client) case X_XIAllowEvents: return ProcXIAllowEvents(client); case X_XIPassiveGrabDevice: - return SProcXIPassiveGrabDevice(client); + return ProcXIPassiveGrabDevice(client); case X_XIPassiveUngrabDevice: - return SProcXIPassiveUngrabDevice(client); + return ProcXIPassiveUngrabDevice(client); case X_XIListProperties: return ProcXIListProperties(client); case X_XIChangeProperty: diff --git a/Xi/handlers.h b/Xi/handlers.h index 03cf32584e..8afab70f3d 100644 --- a/Xi/handlers.h +++ b/Xi/handlers.h @@ -70,8 +70,6 @@ int ProcXUngrabDevice(ClientPtr client); int ProcXUngrabDeviceKey(ClientPtr client); int SProcXIGetSelectedEvents(ClientPtr client); -int SProcXIPassiveGrabDevice(ClientPtr client); -int SProcXIPassiveUngrabDevice(ClientPtr client); int SProcXIQueryPointer(ClientPtr client); int SProcXIQueryVersion(ClientPtr client); int SProcXISelectEvents(ClientPtr client); diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c index 9330f49fea..782f44cacf 100644 --- a/Xi/xipassivegrab.c +++ b/Xi/xipassivegrab.c @@ -48,37 +48,31 @@ #include "exglobals.h" /* BadDevice */ #include "misc.h" -int _X_COLD -SProcXIPassiveGrabDevice(ClientPtr client) -{ - int i; - uint32_t *mods; - - REQUEST(xXIPassiveGrabDeviceReq); - REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq); - - swaps(&stuff->deviceid); - swapl(&stuff->grab_window); - swapl(&stuff->cursor); - swapl(&stuff->time); - swapl(&stuff->detail); - swaps(&stuff->mask_len); - swaps(&stuff->num_modifiers); - - REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq, - ((uint32_t) stuff->mask_len + stuff->num_modifiers) *4); - mods = (uint32_t *) &stuff[1] + stuff->mask_len; - - for (i = 0; i < stuff->num_modifiers; i++, mods++) { - swapl(mods); - } - - return ProcXIPassiveGrabDevice(client); -} - int ProcXIPassiveGrabDevice(ClientPtr client) { + REQUEST(xXIPassiveGrabDeviceReq); + REQUEST_AT_LEAST_SIZE(xXIPassiveGrabDeviceReq); + + if (client->swapped) { + swaps(&stuff->deviceid); + swapl(&stuff->grab_window); + swapl(&stuff->cursor); + swapl(&stuff->time); + swapl(&stuff->detail); + swaps(&stuff->mask_len); + swaps(&stuff->num_modifiers); + } + + REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq, + ((uint32_t) stuff->mask_len + stuff->num_modifiers) *4); + + if (client->swapped) { + uint32_t *mods = (uint32_t *) &stuff[1] + stuff->mask_len; + for (int i = 0; i < stuff->num_modifiers; i++, mods++) + swapl(mods); + } + DeviceIntPtr dev, mod_dev; xXIPassiveGrabDeviceReply rep = { .repType = X_Reply, @@ -94,10 +88,6 @@ ProcXIPassiveGrabDevice(ClientPtr client) void *tmp; int mask_len; - REQUEST(xXIPassiveGrabDeviceReq); - REQUEST_FIXED_SIZE(xXIPassiveGrabDeviceReq, - ((uint32_t) stuff->mask_len + stuff->num_modifiers) * 4); - if (stuff->deviceid == XIAllDevices) dev = inputInfo.all_devices; else if (stuff->deviceid == XIAllMasterDevices) @@ -254,43 +244,34 @@ ProcXIPassiveGrabDevice(ClientPtr client) return ret; } -int _X_COLD -SProcXIPassiveUngrabDevice(ClientPtr client) -{ - int i; - uint32_t *modifiers; - - REQUEST(xXIPassiveUngrabDeviceReq); - REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq); - - swapl(&stuff->grab_window); - swaps(&stuff->deviceid); - swapl(&stuff->detail); - swaps(&stuff->num_modifiers); - - REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq, - ((uint32_t) stuff->num_modifiers) << 2); - modifiers = (uint32_t *) &stuff[1]; - - for (i = 0; i < stuff->num_modifiers; i++, modifiers++) - swapl(modifiers); - - return ProcXIPassiveUngrabDevice(client); -} - int ProcXIPassiveUngrabDevice(ClientPtr client) { + REQUEST(xXIPassiveUngrabDeviceReq); + REQUEST_AT_LEAST_SIZE(xXIPassiveUngrabDeviceReq); + + if (client->swapped) { + swapl(&stuff->grab_window); + swaps(&stuff->deviceid); + swapl(&stuff->detail); + swaps(&stuff->num_modifiers); + } + + REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq, + ((uint32_t) stuff->num_modifiers) << 2); + + if (client->swapped) { + uint32_t *modifiers = (uint32_t *) &stuff[1]; + for (int i = 0; i < stuff->num_modifiers; i++, modifiers++) + swapl(modifiers); + } + DeviceIntPtr dev, mod_dev; WindowPtr win; GrabPtr tempGrab; uint32_t *modifiers; int i, rc; - REQUEST(xXIPassiveUngrabDeviceReq); - REQUEST_FIXED_SIZE(xXIPassiveUngrabDeviceReq, - ((uint32_t) stuff->num_modifiers) << 2); - if (stuff->deviceid == XIAllDevices) dev = inputInfo.all_devices; else if (stuff->deviceid == XIAllMasterDevices) diff --git a/test/xi2/protocol-xigetselectedevents.c b/test/xi2/protocol-xigetselectedevents.c index 2cc6be5fbe..648b43c403 100644 --- a/test/xi2/protocol-xigetselectedevents.c +++ b/test/xi2/protocol-xigetselectedevents.c @@ -145,7 +145,7 @@ request_XIGetSelectedEvents(xXIGetSelectedEventsReq * req, int error) The handler proc's don't use that field anymore, thus also SProc's wont swap it. But this test program uses that field to initialize client->req_len (see above). We previously had to swap it here, so - that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + that ProcXIPassiveGrabDevice() will swap it back. Since that's gone now, still swapping itself would break if this function is called again and writing back a errornously swapped value */ diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c index 0df932abb2..423caeb69e 100644 --- a/test/xi2/protocol-xipassivegrabdevice.c +++ b/test/xi2/protocol-xipassivegrabdevice.c @@ -151,7 +151,7 @@ request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req, The handler proc's don't use that field anymore, thus also SProc's wont swap it. But this test program uses that field to initialize client->req_len (see above). We previously had to swap it here, so - that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + that ProcXIPassiveGrabDevice() will swap it back. Since that's gone now, still swapping itself would break if this function is called again and writing back a errornously swapped value */ @@ -172,7 +172,7 @@ request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req, swapl(mod); } - rc = SProcXIPassiveGrabDevice(&client_request); + rc = ProcXIPassiveGrabDevice(&client_request); assert(rc == error); if (rc != Success) diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c index 6f32bbad0a..b3692bc08a 100644 --- a/test/xi2/protocol-xiselectevents.c +++ b/test/xi2/protocol-xiselectevents.c @@ -114,7 +114,7 @@ request_XISelectEvent(xXISelectEventsReq * req, int error) The handler proc's don't use that field anymore, thus also SProc's wont swap it. But this test program uses that field to initialize client->req_len (see above). We previously had to swap it here, so - that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + that ProcXIPassiveGrabDevice() will swap it back. Since that's gone now, still swapping itself would break if this function is called again and writing back a errornously swapped value */ diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c index 3bff5acee3..800dd947bb 100644 --- a/test/xi2/protocol-xisetclientpointer.c +++ b/test/xi2/protocol-xisetclientpointer.c @@ -74,7 +74,7 @@ request_XISetClientPointer(xXISetClientPointerReq * req, int error) The handler proc's don't use that field anymore, thus also SProc's wont swap it. But this test program uses that field to initialize client->req_len (see above). We previously had to swap it here, so - that SProcXIPassiveGrabDevice() will swap it back. Since that's gone + that ProcXIPassiveGrabDevice() will swap it back. Since that's gone now, still swapping itself would break if this function is called again and writing back a errornously swapped value */