xserver: Branch 'master' - 2 commits

Adam Jackson ajax at kemper.freedesktop.org
Wed Oct 5 17:38:33 UTC 2016


 hw/xwayland/xwayland-input.c |   76 +++++++++++++++++++++++++++----------------
 1 file changed, 48 insertions(+), 28 deletions(-)

New commits:
commit bbd4854f81ebba1119202c5f6ff4679c62afec1f
Author: Carlos Garnacho <carlosg at gnome.org>
Date:   Tue Sep 27 19:03:26 2016 +0200

    xwayland: Apply touch abs axes transformation before posting events
    
    The way we map the touch absolute device to screen coordinates can't
    work across wl_output mode and geometry events. Instead, set up
    a fixed coordinate space, and transform touch events according to
    the screen coordinate space as they happen.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Carlos Garnacho <carlosg at gnome.org>

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 1872bdc..d3a8e50 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -167,7 +167,6 @@ xwl_touch_proc(DeviceIntPtr device, int what)
 #define NTOUCHPOINTS 20
 #define NBUTTONS 1
 #define NAXES 2
-    struct xwl_seat *xwl_seat = device->public.devicePrivate;
     Atom btn_labels[NBUTTONS] = { 0 };
     Atom axes_labels[NAXES] = { 0 };
     BYTE map[NBUTTONS + 1] = { 0 };
@@ -191,13 +190,10 @@ xwl_touch_proc(DeviceIntPtr device, int what)
             return BadValue;
 
         /* Valuators */
-        /* FIXME: devices might be mapped to a single wl_output */
         InitValuatorAxisStruct(device, 0, axes_labels[0],
-                               0, xwl_seat->xwl_screen->width,
-                               10000, 0, 10000, Absolute);
+                               0, 0xFFFF, 10000, 0, 10000, Absolute);
         InitValuatorAxisStruct(device, 1, axes_labels[1],
-                               0, xwl_seat->xwl_screen->height,
-                               10000, 0, 10000, Absolute);
+                               0, 0xFFFF, 10000, 0, 10000, Absolute);
         return Success;
 
     case DEVICE_ON:
@@ -640,15 +636,18 @@ static void
 xwl_touch_send_event(struct xwl_touch *xwl_touch,
                      struct xwl_seat *xwl_seat, int type)
 {
-    int32_t dx, dy;
+    double dx, dy, x, y;
     ValuatorMask mask;
 
     dx = xwl_touch->window->window->drawable.x;
     dy = xwl_touch->window->window->drawable.y;
 
+    x = (dx + xwl_touch->x) * 0xFFFF / xwl_seat->xwl_screen->width;
+    y = (dy + xwl_touch->y) * 0xFFFF / xwl_seat->xwl_screen->height;
+
     valuator_mask_zero(&mask);
-    valuator_mask_set(&mask, 0, dx + xwl_touch->x);
-    valuator_mask_set(&mask, 1, dy + xwl_touch->y);
+    valuator_mask_set_double(&mask, 0, x);
+    valuator_mask_set_double(&mask, 1, y);
     QueueTouchEvents(xwl_seat->touch, type, xwl_touch->id, 0, &mask);
 }
 
commit ee526285882995289846648f3122c4295e3e8284
Author: Carlos Garnacho <carlosg at gnome.org>
Date:   Wed Sep 28 12:35:36 2016 +0200

    xwayland: Apply "last pointer window" check only to the pointer device
    
    The checks in xwayland's XYToWindow handler pretty much assumes that the
    sprite is managed by the wl_pointer, which is not entirely right, given
    1) The Virtual Core Pointer may be controlled from other interfaces, and
    2) there may be other SpriteRecs than the VCP's.
    
    This makes XYToWindow calls return a sprite trace with just the root
    window if any of those two assumptions are broken, eg. on touch events.
    
    So turn the check upside down, first assume that the default XYToWindow
    proc behavior is right, and later cut down the spriteTrace if the
    current device happens to be the pointer and is out of focus. We work
    our way to the device's lastSlave here so as not to break assumption #1
    above.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
    Acked-by: Olivier Fourdan <ofourdan at redhat.com>

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 32cfb35..1872bdc 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -945,44 +945,65 @@ DDXRingBell(int volume, int pitch, int duration)
 {
 }
 
-static WindowPtr
-xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
+static Bool
+sprite_check_lost_focus(SpritePtr sprite, WindowPtr window)
 {
-    struct xwl_seat *xwl_seat = NULL;
-    DeviceIntPtr device;
-    WindowPtr ret;
+    DeviceIntPtr device, master;
+    struct xwl_seat *xwl_seat;
 
     for (device = inputInfo.devices; device; device = device->next) {
+        /* Ignore non-wayland devices */
         if (device->deviceProc == xwl_pointer_proc &&
-            device->spriteInfo->sprite == sprite) {
-            xwl_seat = device->public.devicePrivate;
+            device->spriteInfo->sprite == sprite)
             break;
-        }
     }
 
-    if (xwl_seat == NULL) {
-        sprite->spriteTraceGood = 1;
-        return sprite->spriteTrace[0];
-    }
+    if (!device)
+        return FALSE;
+
+    xwl_seat = device->public.devicePrivate;
+
+    master = GetMaster(device, POINTER_OR_FLOAT);
+    if (!master || !master->lastSlave)
+        return FALSE;
 
-    screen->XYToWindow = xwl_seat->xwl_screen->XYToWindow;
+    /* We do want the last active slave, we only check on slave xwayland
+     * devices so we can find out the xwl_seat, but those don't actually own
+     * their sprite, so the match doesn't mean a lot.
+     */
+    if (master->lastSlave == xwl_seat->pointer &&
+        xwl_seat->focus_window == NULL &&
+        xwl_seat->last_xwindow == window)
+        return TRUE;
+
+    xwl_seat->last_xwindow = window;
+    return FALSE;
+}
+
+static WindowPtr
+xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
+{
+    struct xwl_screen *xwl_screen;
+    WindowPtr ret;
+
+    xwl_screen = xwl_screen_get(screen);
+
+    screen->XYToWindow = xwl_screen->XYToWindow;
     ret = screen->XYToWindow(screen, sprite, x, y);
-    xwl_seat->xwl_screen->XYToWindow = screen->XYToWindow;
+    xwl_screen->XYToWindow = screen->XYToWindow;
     screen->XYToWindow = xwl_xy_to_window;
 
-    /* If the pointer has left the Wayland surface but the DIX still
-     * finds the pointer within the previous X11 window, it means that
+    /* If the device controlling the sprite has left the Wayland surface but
+     * the DIX still finds the pointer within the X11 window, it means that
      * the pointer has crossed to another native Wayland window, in this
      * case, pretend we entered the root window so that a LeaveNotify
      * event is emitted.
      */
-    if (xwl_seat->focus_window == NULL && xwl_seat->last_xwindow == ret) {
+    if (sprite_check_lost_focus(sprite, ret)) {
         sprite->spriteTraceGood = 1;
         return sprite->spriteTrace[0];
     }
 
-    xwl_seat->last_xwindow = ret;
-
     return ret;
 }
 


More information about the xorg-commit mailing list