XKB: Fix processInputProc wrapping

If input processing is frozen, only wrap realInputProc: don't smash
processInputProc as well.  When input processing is thawed, pIP will be
rewrapped correctly.

This supersedes the previous workaround in 50e80c9.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Thomas Jaeger 2008-04-01 15:27:06 +03:00 committed by Daniel Stone
parent a4d0349411
commit 37b1258f0a
2 changed files with 16 additions and 9 deletions

View File

@ -237,6 +237,14 @@ typedef struct _XkbSrvLedInfo {
typedef struct
{
ProcessInputProc processInputProc;
/* If processInputProc is set to something different than realInputProc,
* UNWRAP and COND_WRAP will not touch processInputProc and update only
* realInputProc. This ensures that
* processInputProc == (frozen ? EnqueueEvent : realInputProc)
*
* WRAP_PROCESS_INPUT_PROC should only be called during initialization,
* since it may destroy this invariant.
*/
ProcessInputProc realInputProc;
DeviceUnwrapProc unwrapProc;
} xkbDeviceInfoRec, *xkbDeviceInfoPtr;
@ -254,14 +262,14 @@ typedef struct
device->public.processInputProc = proc; \
oldprocs->processInputProc = \
oldprocs->realInputProc = device->public.realInputProc; \
if (proc != device->public.enqueueInputProc) \
device->public.realInputProc = proc; \
device->public.realInputProc = proc; \
oldprocs->unwrapProc = device->unwrapProc; \
device->unwrapProc = unwrapproc;
#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs, backupproc) \
backupproc = device->public.processInputProc; \
device->public.processInputProc = oldprocs->processInputProc; \
backupproc = device->public.realInputProc; \
if (device->public.processInputProc == device->public.realInputProc)\
device->public.processInputProc = oldprocs->realInputProc; \
device->public.realInputProc = oldprocs->realInputProc; \
device->unwrapProc = oldprocs->unwrapProc;

View File

@ -49,15 +49,14 @@ xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
pointer data)
{
xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device);
ProcessInputProc tmp = device->public.processInputProc;
ProcessInputProc dummy; /* unused, but neede for macro */
ProcessInputProc backupproc;
if(xkbPrivPtr->unwrapProc)
xkbPrivPtr->unwrapProc = NULL;
UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, dummy);
UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, backupproc);
proc(device,data);
WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
tmp,xkbUnwrapProc);
COND_WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
backupproc,xkbUnwrapProc);
}