From c50db6faba4ee1c27b735c6e9c98a4276ba3c7ff Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 6 Dec 2012 12:58:55 +1000 Subject: [PATCH] Xi: fill in barrier root x/y after clamping to RandR outputs x/y for barrier events should contain the actual pointer position. Signed-off-by: Peter Hutterer Reviewed-by: Jasper St. Pierre --- 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 104280c62..048af62a2 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 f4fbd2912..7bc09830a 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;