From 05c9dd98cbce59c8329e9c8d75cbe260b6a45e5e Mon Sep 17 00:00:00 2001 From: Chris Dekter Date: Wed, 28 Oct 2009 12:51:58 +1000 Subject: [PATCH] Re-enable RECORD extension. RECORD was disabled during the switch to internal events. This patch modifies the record callback to work with internal events instead of xEvents. The InternalEvents are converted to core/Xi events as needed. Since record is a loadable extension, the EventTo* calls must be externed. Signed-off-by: Peter Hutterer --- Xi/exevents.c | 9 +++------ dix/events.c | 15 +++++++-------- include/dix.h | 5 +++-- include/eventconvert.h | 6 +++--- record/record.c | 35 +++++++++++++++++++++++++---------- 5 files changed, 41 insertions(+), 29 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index cb2452b..3494ee0 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1031,16 +1031,13 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device) break; } -#if 0 - /* FIXME: I'm broken. Please fix me. Thanks */ if (DeviceEventCallback) { DeviceEventInfoRec eventinfo; - - eventinfo.events = (xEventPtr) xE; - eventinfo.count = count; + eventinfo.event = ev; + eventinfo.ismaster = IsMaster(device); CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo); } -#endif + grab = device->deviceGrab.grab; switch(event->type) diff --git a/dix/events.c b/dix/events.c index 85c8f9a..71525b2 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1131,11 +1131,10 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device) event->type == ET_KeyRelease) AccessXCancelRepeatKey(device->key->xkbInfo, event->detail.key); -#if 0 - /* FIXME: I'm broken now. Please fix me. */ if (DeviceEventCallback) { DeviceEventInfoRec eventinfo; + /* The RECORD spec says that the root window field of motion events * must be valid. At this point, it hasn't been filled in yet, so * we do it here. The long expression below is necessary to get @@ -1145,14 +1144,14 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device) * the data that GetCurrentRootWindow relies on hasn't been * updated yet. */ - if (xE->u.u.type == DeviceMotionNotify) - XE_KBPTR.root = - WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id; - eventinfo.events = xE; - eventinfo.count = nevents; + if (ev->any.type == ET_Motion) + eventinfo.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id; + + eventinfo.event = ev; + eventinfo.ismaster = IsMaster(device); CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo); } -#endif + if (event->type == ET_Motion) { #ifdef PANORAMIX diff --git a/include/dix.h b/include/dix.h index ed3acb6..c08256a 100644 --- a/include/dix.h +++ b/include/dix.h @@ -576,8 +576,9 @@ typedef struct { extern _X_EXPORT CallbackListPtr DeviceEventCallback; typedef struct { - xEventPtr events; - int count; + InternalEvent *event; + Window root; + int ismaster; } DeviceEventInfoRec; extern int XItoCoreType(int xi_type); diff --git a/include/eventconvert.h b/include/eventconvert.h index 277a6c4..b1196a0 100644 --- a/include/eventconvert.h +++ b/include/eventconvert.h @@ -30,9 +30,9 @@ #define FP1616(integral, frac) ((integral) * (1 << 16) + (frac) * (1 << 16)) -_X_INTERNAL int EventToCore(InternalEvent *event, xEvent *core); -_X_INTERNAL int EventToXI(InternalEvent *ev, xEvent **xi, int *count); -_X_INTERNAL int EventToXI2(InternalEvent *ev, xEvent **xi); +_X_EXPORT int EventToCore(InternalEvent *event, xEvent *core); +_X_EXPORT int EventToXI(InternalEvent *ev, xEvent **xi, int *count); +_X_EXPORT int EventToXI2(InternalEvent *ev, xEvent **xi); _X_INTERNAL int GetCoreType(InternalEvent* ev); _X_INTERNAL int GetXIType(InternalEvent* ev); _X_INTERNAL int GetXI2Type(InternalEvent* ev); diff --git a/record/record.c b/record/record.c index 242544f..452a938 100644 --- a/record/record.c +++ b/record/record.c @@ -42,6 +42,8 @@ and Jim Haggerty of Metheus. #include "set.h" #include "swaprep.h" #include "inputstr.h" +#include "eventconvert.h" + #include #include @@ -757,8 +759,22 @@ RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata) if (pRCAP->pDeviceEventSet) { int ev; /* event index */ - xEvent *pev = pei->events; - for (ev = 0; ev < pei->count; ev++, pev++) + int count; + xEvent xE; + xEvent *pev = &xE, *xi_events = NULL; + + /* TODO check return values */ + if (pei->ismaster) + { + EventToCore(pei->event, &xE); + count = 1; + } else + { + EventToXI(pei->event, &xi_events, &count); + pev = xi_events; + } + + for (ev = 0; ev < count; ev++, pev++) { if (RecordIsMemberOfSet(pRCAP->pDeviceEventSet, pev->u.u.type & 0177)) @@ -767,7 +783,11 @@ RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata) xEvent *pEvToRecord = pev; #ifdef PANORAMIX xEvent shiftedEvent; +#endif + if (pei->root != None) + pev->u.keyButtonPointer.root = pei->root; +#ifdef PANORAMIX if (!noPanoramiXExtension && (pev->u.u.type == MotionNotify || pev->u.u.type == ButtonPress || @@ -801,6 +821,9 @@ RecordADeviceEvent(CallbackListPtr *pcbl, pointer nulldata, pointer calldata) SetCriticalOutputPending(); } } /* end for each event */ + + xfree(xi_events); + } /* end this RCAP selects device events */ } /* end for each RCAP on this context */ } /* end for each enabled context */ @@ -2866,13 +2889,6 @@ RecordCloseDown(ExtensionEntry *extEntry) void RecordExtensionInit(void) { - /* FIXME Record is currently broken. Dont initialize it so that clients - * that require it can bail out correctly rather than waiting for stuff - * that'll never happen */ - ErrorF("record: RECORD extension enabled at configure time.\n"); - ErrorF("record: This extension is known to be broken, disabling extension now..\n"); - ErrorF("record: http://bugs.freedesktop.org/show_bug.cgi?id=20500\n"); -#if 0 ExtensionEntry *extentry; RTContext = CreateNewResourceType(RecordDeleteContext, "RecordContext"); @@ -2895,6 +2911,5 @@ RecordExtensionInit(void) } RecordErrorBase = extentry->errorBase; -#endif } /* RecordExtensionInit */ -- 1.6.5.2