[PATCH] Re-enable the RECORD extension. (#20500)

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 7 21:27:27 PST 2010


This extension got broken with the switch to internal events (and was likely
broken since 1.6). The new approach creates an XI event from the internal
event for each SD and each MD and a core event for each MD. These events are
then passed into the old callback functions.

Eventually the callbacks should be updated to work with InternalEvents (only
RECORD actually uses the callbacks). Currently, WriteEventsToClient deals
with wire events and changing it to keep the InternalEvent constitutes an
ABI break.

Based on patches by Chris Dekter.

X.Org Bug 20500 <http://bugs.freedesktop.org/show_bug.cgi?id=20500>

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
I'd like to get more testing and review for this since it might become a
candidate for 1.7.5. First tests look like it works fine again.
This patch requires the EventToCore patch
http://lists.freedesktop.org/archives/xorg-devel/2010-January/004752.html

 Xi/exevents.c   |   37 ++++++++++++++++++++++++++++++-------
 dix/events.c    |   32 ++++++++++++++++++++++++--------
 record/record.c |    8 --------
 3 files changed, 54 insertions(+), 23 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index cb2452b..5f8e1fa 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1031,16 +1031,39 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
             break;
     }
 
-#if 0
-    /* FIXME: I'm broken. Please fix me. Thanks */
     if (DeviceEventCallback) {
-	DeviceEventInfoRec eventinfo;
+        DeviceEventInfoRec eventinfo;
+        SpritePtr pSprite = device->spriteInfo->sprite;
+        xEvent *xi_events = NULL;
+        int count;
+
+        /* see comment in EnqueueEvents regarding the next three lines */
+        if (ev->any.type == ET_Motion)
+            ev->device_event.root =
+                WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
+
+        /* SDs send XI events only. MDs send both an XI event and a core
+         * event.
+         */
+        EventToXI(ev, &xi_events, &count);
+
+        eventinfo.events = (xEventPtr)xi_events;
+        eventinfo.count = count;
+        ErrorF("POE xi root is %lx\n", xi_events->u.keyButtonPointer.root);
+        CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
+        xfree(xi_events);
+
+        if (IsMaster(device))
+        {
+            xEvent core;
+            EventToCore(ev, &core);
+            eventinfo.events = (xEventPtr)&core;
+            eventinfo.count = 1;
+            ErrorF("POE core root is %lx\n", core.u.keyButtonPointer.root);
+            CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
+        }
 
-	eventinfo.events = (xEventPtr) xE;
-	eventinfo.count = count;
-	CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
     }
-#endif
     grab = device->deviceGrab.grab;
 
     switch(event->type)
diff --git a/dix/events.c b/dix/events.c
index 85c8f9a..b5c8880 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1131,11 +1131,12 @@ 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;
+	xEvent *xi_events = NULL;
+	int count;
+
 	/*  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 +1146,29 @@ 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 =
+
+	if (ev->any.type == ET_Motion)
+	    ev->device_event.root =
 		WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
-	eventinfo.events = xE;
-	eventinfo.count = nevents;
-	CallCallbacks(&DeviceEventCallback, (pointer)&eventinfo);
+
+	EventToXI(ev, &xi_events, &count);
+
+	eventinfo.events = (xEventPtr)xi_events;
+	eventinfo.count = count;
+	CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
+	xfree(xi_events);
+
+	if (IsMaster(device))
+	{
+	    xEvent core;
+	    EventToCore(ev, &core);
+	    eventinfo.events = (xEventPtr)&core;
+	    eventinfo.count = 1;
+	    CallCallbacks(&DeviceEventCallback, (pointer) & eventinfo);
+	}
+
     }
-#endif
+
     if (event->type == ET_Motion)
     {
 #ifdef PANORAMIX
diff --git a/record/record.c b/record/record.c
index 242544f..0ec92e1 100644
--- a/record/record.c
+++ b/record/record.c
@@ -2866,13 +2866,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 +2888,5 @@ RecordExtensionInit(void)
     }
     RecordErrorBase = extentry->errorBase;
 
-#endif
 } /* RecordExtensionInit */
 
-- 
1.6.6


More information about the xorg-devel mailing list