Xi: fix the wrapper code for processInputProc wrapping.

Followup to [1].
If a core grab causes the device to freeze, it overwrites the processInputProc
of the device. [1] would then overwrite this while unwrapping, the device
does not thaw anymore.
Changing this to only re-wrap if the processInputProc hasn't been changed
during the event handling.

[1] 340911d724
This commit is contained in:
Peter Hutterer 2007-09-26 18:03:21 +09:30
parent e2cb851566
commit 3342b5ad47

View File

@ -104,15 +104,23 @@ typedef struct {
*/
#define WRAP_PROCESS_INPUT_PROC(device, saveprocs, newproc) \
saveprocs->processInputProc = device->public.processInputProc; \
saveprocs->processInputProc = \
saveprocs->realInputProc = device->public.realInputProc; \
device->public.processInputProc = newproc; \
device->public.realInputProc = newproc;
device->public.realInputProc = newproc
#define UNWRAP_PROCESS_INPUT_PROC(device, saveprocs) \
#define UNWRAP_PROCESS_INPUT_PROC(device, saveprocs, backupproc) \
backupproc = device->public.processInputProc; \
device->public.processInputProc = saveprocs->processInputProc; \
device->public.realInputProc = saveprocs->realInputProc;
#define REWRAP_PROCESS_INPUT_PROC(device, saveprocs, newproc) \
if (device->public.processInputProc == device->public.realInputProc) \
device->public.processInputProc = newproc; \
saveprocs->processInputProc = \
saveprocs->realInputProc = device->public.realInputProc; \
device->public.realInputProc = newproc;
void
RegisterOtherDevice(DeviceIntPtr device)
{
@ -159,11 +167,13 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
/* Handle core events. */
if (xE->u.u.type < LASTEvent && xE->u.u.type != GenericEvent)
{
ProcessInputProc backupproc;
xiDevPrivatePtr xiPrivPtr =
(xiDevPrivatePtr)device->devPrivates[xiDevPrivateIndex].ptr;
UNWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr);
UNWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, backupproc);
device->public.processInputProc(xE, device, count);
WRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, ProcessOtherEvent);
/* only rewraps is the processInputProc hasn't been modified */
REWRAP_PROCESS_INPUT_PROC(device, xiPrivPtr, backupproc);
return;
}