[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg-devel
Subject:    [PATCH] randr: Make the RRConstrainCursorHarder logic the same as
From:       Rui Matos <tiagomatos () gmail ! com>
Date:       2011-07-29 17:01:15
Message-ID: 1311958876-7043-1-git-send-email-tiagomatos () gmail ! com
[Download RAW message or body]

Some applications rely on receiving events on screen corners
(e.g. gnome-shell's message tray) but the current logic considers that the
corner is off by 1 pixel from what applications expect.

The constraining logic in RRConstrainCursorHarder allows the cursor to reach
position x = width and y = height while the constraining code in
miPointerSetPosition only allows it to reach x = width - 1 and y = height - 1
for the analogous screen case.

Signed-off-by: Rui Matos <tiagomatos@gmail.com>
---
 randr/rrcrtc.c |   29 ++++++++++-------------------
 1 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index dcff70b..12d879b 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -1463,7 +1463,7 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
 
        crtc_bounds(crtc, &left, &right, &top, &bottom);
 
-       if ((*x >= left) && (*x <= right) && (*y >= top) && (*y <= bottom))
+       if ((*x >= left) && (*x < right) && (*y >= top) && (*y < bottom))
            return;
     }
 
@@ -1479,24 +1479,15 @@ RRConstrainCursorHarder(DeviceIntPtr pDev, ScreenPtr pScreen, int mode, int *x,
        crtc_bounds(crtc, &left, &right, &top, &bottom);
        miPointerGetPosition(pDev, &nx, &ny);
 
-       if ((nx >= left) && (nx <= right) && (ny >= top) && (ny <= bottom)) {
-           if ((*x <= left) || (*x >= right)) {
-               int dx = *x - nx;
-
-               if (dx > 0)
-                   *x = right;
-               else if (dx < 0)
-                   *x = left;
-           }
-
-           if ((*y <= top) || (*y >= bottom)) {
-               int dy = *y - ny;
-
-               if (dy > 0)
-                   *y = bottom;
-               else if (dy < 0)
-                   *y = top;
-           }
+       if ((nx >= left) && (nx < right) && (ny >= top) && (ny < bottom)) {
+           if (*x < left)
+               *x = left;
+           if (*x >= right)
+               *x = right - 1;
+           if (*y < top)
+               *y = top;
+           if (*y >= bottom)
+               *y = bottom - 1;
 
            return;
        }
-- 
1.7.6

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic