[PATCH xserver 2/2] xwayland: Apply touch abs axes transformation before posting events

Carlos Garnacho carlosg at gnome.org
Tue Sep 27 17:03:26 UTC 2016


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.

Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
---
 hw/xwayland/xwayland-input.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 9b385dc..678cc7e 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);
 }
 
-- 
2.10.0



More information about the xorg-devel mailing list