Blame SOURCES/0001-xwayland-Keep-separate-variables-for-pointer-and-tab.patch

0c8e57
From 60f4646ae10f0b57790fce46682baa531512b53e Mon Sep 17 00:00:00 2001
0c8e57
From: Carlos Garnacho <carlosg@gnome.org>
0c8e57
Date: Mon, 4 Dec 2017 16:55:13 +0100
0c8e57
Subject: [PATCH xserver] xwayland: Keep separate variables for pointer and
0c8e57
 tablet foci
0c8e57
0c8e57
The tablet/stylus interfaces reused xwl_seat->focus_window, which
0c8e57
would leave a somewhat inconsistent state of that variable for
0c8e57
wl_pointer purposes (basically, everything) if the pointer happened
0c8e57
to lay on the same surface than the stylus while proximity_out
0c8e57
happens.
0c8e57
0c8e57
We just want the stylus xwl_window to correctly determine we have
0c8e57
stylus focus, and to correctly translate surface-local coordinates
0c8e57
to root coordinates, this can be done using a different variable.
0c8e57
0c8e57
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
0c8e57
Acked-by: Jason Gerecke <jason.gerecke@wacom.com>
0c8e57
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
0c8e57
---
0c8e57
 hw/xwayland/xwayland-input.c | 20 ++++++++++----------
0c8e57
 hw/xwayland/xwayland.c       |  2 ++
0c8e57
 hw/xwayland/xwayland.h       |  1 +
0c8e57
 3 files changed, 13 insertions(+), 10 deletions(-)
0c8e57
0c8e57
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
0c8e57
index 68e365051..439903032 100644
0c8e57
--- a/hw/xwayland/xwayland-input.c
0c8e57
+++ b/hw/xwayland/xwayland-input.c
0c8e57
@@ -1514,7 +1514,7 @@ tablet_tool_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool,
0c8e57
         return;
0c8e57
 
0c8e57
     xwl_tablet_tool->proximity_in_serial = serial;
0c8e57
-    xwl_seat->focus_window = wl_surface_get_user_data(wl_surface);
0c8e57
+    xwl_seat->tablet_focus_window = wl_surface_get_user_data(wl_surface);
0c8e57
 
0c8e57
     xwl_tablet_tool_set_cursor(xwl_tablet_tool);
0c8e57
 }
0c8e57
@@ -1526,7 +1526,7 @@ tablet_tool_proximity_out(void *data, struct zwp_tablet_tool_v2 *tool)
0c8e57
     struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
0c8e57
 
0c8e57
     xwl_tablet_tool->proximity_in_serial = 0;
0c8e57
-    xwl_seat->focus_window = NULL;
0c8e57
+    xwl_seat->tablet_focus_window = NULL;
0c8e57
 
0c8e57
     xwl_tablet_tool->pressure = 0;
0c8e57
     xwl_tablet_tool->tilt_x = 0;
0c8e57
@@ -1568,11 +1568,11 @@ tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *tool,
0c8e57
     int sx = wl_fixed_to_int(x);
0c8e57
     int sy = wl_fixed_to_int(y);
0c8e57
 
0c8e57
-    if (!xwl_seat->focus_window)
0c8e57
+    if (!xwl_seat->tablet_focus_window)
0c8e57
         return;
0c8e57
 
0c8e57
-    dx = xwl_seat->focus_window->window->drawable.x;
0c8e57
-    dy = xwl_seat->focus_window->window->drawable.y;
0c8e57
+    dx = xwl_seat->tablet_focus_window->window->drawable.x;
0c8e57
+    dy = xwl_seat->tablet_focus_window->window->drawable.y;
0c8e57
 
0c8e57
     xwl_tablet_tool->x = dx + sx;
0c8e57
     xwl_tablet_tool->y = dy + sy;
0c8e57
@@ -1585,7 +1585,7 @@ tablet_tool_pressure(void *data, struct zwp_tablet_tool_v2 *tool,
0c8e57
     struct xwl_tablet_tool *xwl_tablet_tool = data;
0c8e57
     struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
0c8e57
 
0c8e57
-    if (!xwl_seat->focus_window)
0c8e57
+    if (!xwl_seat->tablet_focus_window)
0c8e57
         return;
0c8e57
 
0c8e57
     /* normalized to 65535 already */
0c8e57
@@ -1605,7 +1605,7 @@ tablet_tool_tilt(void *data, struct zwp_tablet_tool_v2 *tool,
0c8e57
     struct xwl_tablet_tool *xwl_tablet_tool = data;
0c8e57
     struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
0c8e57
 
0c8e57
-    if (!xwl_seat->focus_window)
0c8e57
+    if (!xwl_seat->tablet_focus_window)
0c8e57
         return;
0c8e57
 
0c8e57
     xwl_tablet_tool->tilt_x = wl_fixed_to_double(tilt_x);
0c8e57
@@ -1620,7 +1620,7 @@ tablet_tool_rotation(void *data, struct zwp_tablet_tool_v2 *tool,
0c8e57
     struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
0c8e57
     double rotation = wl_fixed_to_double(angle);
0c8e57
 
0c8e57
-    if (!xwl_seat->focus_window)
0c8e57
+    if (!xwl_seat->tablet_focus_window)
0c8e57
         return;
0c8e57
 
0c8e57
     /* change origin (buttons facing right [libinput +90 degrees]) and
0c8e57
@@ -1639,7 +1639,7 @@ tablet_tool_slider(void *data, struct zwp_tablet_tool_v2 *tool,
0c8e57
     struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
0c8e57
     float position = position_raw / 65535.0;
0c8e57
 
0c8e57
-    if (!xwl_seat->focus_window)
0c8e57
+    if (!xwl_seat->tablet_focus_window)
0c8e57
         return;
0c8e57
 
0c8e57
     xwl_tablet_tool->slider = (position * 1799.0f) - 900.0f;
0c8e57
@@ -1652,7 +1652,7 @@ tablet_tool_wheel(void *data, struct zwp_tablet_tool_v2 *tool,
0c8e57
     struct xwl_tablet_tool *xwl_tablet_tool = data;
0c8e57
     struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
0c8e57
 
0c8e57
-    if (!xwl_seat->focus_window)
0c8e57
+    if (!xwl_seat->tablet_focus_window)
0c8e57
         return;
0c8e57
 
0c8e57
     xwl_tablet_tool->wheel_clicks = clicks;
0c8e57
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
0c8e57
index 79deead8d..638022180 100644
0c8e57
--- a/hw/xwayland/xwayland.c
0c8e57
+++ b/hw/xwayland/xwayland.c
0c8e57
@@ -545,6 +545,8 @@ xwl_unrealize_window(WindowPtr window)
0c8e57
     xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) {
0c8e57
         if (xwl_seat->focus_window && xwl_seat->focus_window->window == window)
0c8e57
             xwl_seat->focus_window = NULL;
0c8e57
+        if (xwl_seat->tablet_focus_window && xwl_seat->tablet_focus_window->window == window)
0c8e57
+            xwl_seat->tablet_focus_window = NULL;
0c8e57
         if (xwl_seat->last_xwindow == window)
0c8e57
             xwl_seat->last_xwindow = NullWindow;
0c8e57
         if (xwl_seat->cursor_confinement_window &&
0c8e57
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
0c8e57
index 3adee82fa..e6eb37bec 100644
0c8e57
--- a/hw/xwayland/xwayland.h
0c8e57
+++ b/hw/xwayland/xwayland.h
0c8e57
@@ -154,6 +154,7 @@ struct xwl_seat {
0c8e57
     struct zwp_tablet_seat_v2 *tablet_seat;
0c8e57
     struct wl_array keys;
0c8e57
     struct xwl_window *focus_window;
0c8e57
+    struct xwl_window *tablet_focus_window;
0c8e57
     uint32_t id;
0c8e57
     uint32_t pointer_enter_serial;
0c8e57
     struct xorg_list link;
0c8e57
-- 
0c8e57
2.14.3
0c8e57