From 8385543e1c512680d51aa38620b347049ce385d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 15 Feb 2019 02:42:23 +0100 Subject: [PATCH] gdkdevice-wayland: Update pointer scale on tablet tool proximity events When the user approaches a tablet tool to the screen we get a proximity-in event and in this moment we need to check the surface output scale to find the scaling to be applied to the cursor. And the same should be done when the tool is detached or the monitors configuration changes. https://gitlab.gnome.org/GNOME/gtk/issues/1675 --- gdk/wayland/gdkdevice-wayland.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index f1dab93f1b..63e55c9900 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -284,6 +284,7 @@ struct _GdkWaylandDevicePadClass }; static void gdk_wayland_device_pad_iface_init (GdkDevicePadInterface *iface); +static void pointer_surface_update_scale (GdkDevice *device); #define GDK_TYPE_WAYLAND_DEVICE_PAD (gdk_wayland_device_pad_get_type ()) GType gdk_wayland_device_pad_get_type (void); @@ -3496,6 +3497,11 @@ tablet_tool_handle_proximity_in (void *data, gdk_event_set_source_device (event, tablet->current_device); gdk_event_set_device_tool (event, tool->tool); + tablet->pointer_info.pointer_surface_outputs = + g_slist_append (tablet->pointer_info.pointer_surface_outputs, + gdk_wayland_surface_get_wl_output (surface)); + pointer_surface_update_scale (tablet->master); + GDK_DISPLAY_NOTE (seat->display, EVENTS, g_message ("proximity in, seat %p surface %p tool %d", seat, tablet->pointer_info.focus, @@ -3523,7 +3529,11 @@ tablet_tool_handle_proximity_out (void *data, gdk_wayland_pointer_stop_cursor_animation (&tablet->pointer_info); - gdk_wayland_device_update_surface_cursor (tablet->master); + tablet->pointer_info.pointer_surface_outputs = + g_slist_remove (tablet->pointer_info.pointer_surface_outputs, + gdk_wayland_surface_get_wl_output (tablet->pointer_info.focus)); + pointer_surface_update_scale (tablet->master); + g_object_unref (tablet->pointer_info.focus); tablet->pointer_info.focus = NULL; @@ -4447,7 +4457,15 @@ pointer_surface_update_scale (GdkDevice *device) void gdk_wayland_seat_update_cursor_scale (GdkWaylandSeat *seat) { + GList *l; + pointer_surface_update_scale (seat->master_pointer); + + for (l = seat->tablets; l; l = l->next) + { + GdkWaylandTabletData *tablet = l->data; + pointer_surface_update_scale (tablet->master); + } } static void