[PATCH 2/8] dix: fill out root_x/y for keyboard events

Peter Hutterer peter.hutterer at who-t.net
Thu Sep 8 21:20:47 PDT 2011


Switching screens relies on rootx/y to be set to the correct value. Note:
though we technically take a mask for GetKeyboardEvents we don't actually
handle it properly to move the pointer as required (and generate motion
events if needed).

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/getevents.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index 1208453..8889213 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -856,6 +856,15 @@ queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents)
         mieqEnqueue(device, &events[i]);
 }
 
+static void
+event_set_root_coordinates(DeviceEvent* event, double x, double y)
+{
+    event->root_x = trunc(x);
+    event->root_y = trunc(y);
+    event->root_x_frac = x - trunc(x);
+    event->root_y_frac = y - trunc(y);
+}
+
 /**
  * Generate internal events representing this keyboard event and enqueue
  * them on the event queue.
@@ -953,6 +962,11 @@ GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
 
     set_valuators(pDev, event, &mask);
 
+    if (!IsFloating(pDev)) {
+            DeviceIntPtr master = GetMaster(pDev, MASTER_POINTER);
+            event_set_root_coordinates(event, master->last.valuators[0], master->last.valuators[1]);
+    }
+
     return num_events;
 }
 
@@ -1165,10 +1179,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
     }
 
     /* root_x and root_y must be in screen co-ordinates */
-    event->root_x = trunc(screenx);
-    event->root_y = trunc(screeny);
-    event->root_x_frac = screenx - trunc(screenx);
-    event->root_y_frac = screeny - trunc(screeny);
+    event_set_root_coordinates(event, screenx, screeny);
 
     if (flags & POINTER_EMULATED) {
         raw->flags = XIPointerEmulated;
-- 
1.7.6



More information about the xorg-devel mailing list