x/y for barrier events should contain the actual pointer position.

Signed-off-by: Peter Hutterer <[email protected]>
---
 Xi/xibarriers.c |  4 ++++
 mi/mipointer.c  | 18 +++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/Xi/xibarriers.c b/Xi/xibarriers.c
index 104280c..048af62 100644
--- a/Xi/xibarriers.c
+++ b/Xi/xibarriers.c
@@ -407,6 +407,8 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
         ev.window = c->window->drawable.id;
         c->last_timestamp = ms;
 
+        /* root x/y is filled in later */
+
         barrier_events->barrier_event = ev;
         barrier_events++;
         *nevents += 1;
@@ -436,6 +438,8 @@ input_constrain_cursor(DeviceIntPtr dev, ScreenPtr screen,
         ev.window = c->window->drawable.id;
         c->last_timestamp = ms;
 
+        /* root x/y is filled in later */
+
         barrier_events->barrier_event = ev;
         barrier_events++;
         *nevents += 1;
diff --git a/mi/mipointer.c b/mi/mipointer.c
index f4fbd29..7bc0983 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -573,6 +573,8 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double 
*screenx,
     ScreenPtr newScreen;
     int x, y;
     Bool switch_screen = FALSE;
+    Bool should_constrain_barriers = FALSE;
+    int i;
 
     miPointerPtr pPointer;
 
@@ -589,7 +591,9 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double 
*screenx,
     x -= pScreen->x;
     y -= pScreen->y;
 
-    if (mode == Relative) {
+    should_constrain_barriers = (mode == Relative);
+
+    if (should_constrain_barriers) {
         /* coordinates after clamped to a barrier */
         int constrained_x, constrained_y;
         int current_x, current_y; /* current position in per-screen coord */
@@ -637,6 +641,18 @@ miPointerSetPosition(DeviceIntPtr pDev, int mode, double 
*screenx,
     if (pPointer->x != x || pPointer->y != y || pPointer->pScreen != pScreen)
         miPointerMoveNoEvent(pDev, pScreen, x, y);
 
+    /* check if we generated any barrier events and if so, update root x/y
+     * to the fully constrained coords */
+    if (should_constrain_barriers) {
+        for (i = 0; i < *nevents; i++) {
+            if (events[i].any.type == ET_BarrierHit ||
+                events[i].any.type == ET_BarrierLeave) {
+                events[i].barrier_event.root_x = x;
+                events[i].barrier_event.root_y = y;
+            }
+        }
+    }
+
     /* Convert to desktop coordinates again */
     x += pScreen->x;
     y += pScreen->y;
-- 
1.8.0.1

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to