summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-02-11 00:53:42 +0100
committerCarlos Garnacho <carlosg@gnome.org>2017-02-15 23:33:44 +0100
commit6b384dc8d1a96a84c4cb1c404a22aa71012dde0f (patch)
tree004d7663f7b19fd87020de7593494b246fdd968c /src
parenta25915f4f936f995dedebcde5f5d7978fa809369 (diff)
downloadmutter-6b384dc8d1a96a84c4cb1c404a22aa71012dde0f.tar.gz
wayland: Update tool cursor scale when crossing monitors
This makes tool cursors properly scaled on hidpi. https://bugzilla.gnome.org/show_bug.cgi?id=778474
Diffstat (limited to 'src')
-rw-r--r--src/wayland/meta-wayland-tablet-tool.c24
-rw-r--r--src/wayland/meta-wayland-tablet-tool.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c
index 3546bb4a9..4cd865fa8 100644
--- a/src/wayland/meta-wayland-tablet-tool.c
+++ b/src/wayland/meta-wayland-tablet-tool.c
@@ -37,6 +37,7 @@
#include "meta-wayland-tablet-seat.h"
#include "meta-wayland-tablet-tool.h"
#include "backends/meta-input-settings-private.h"
+#include "backends/meta-logical-monitor.h"
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
@@ -380,6 +381,25 @@ tablet_tool_handle_cursor_surface_destroy (struct wl_listener *listener,
meta_wayland_tablet_tool_set_cursor_surface (tool, NULL);
}
+static void
+tool_cursor_prepare_at (MetaCursorSprite *cursor_sprite,
+ int x,
+ int y,
+ MetaWaylandTabletTool *tool)
+{
+ MetaBackend *backend = meta_get_backend ();
+ MetaMonitorManager *monitor_manager =
+ meta_backend_get_monitor_manager (backend);
+ MetaLogicalMonitor *logical_monitor;
+
+ logical_monitor =
+ meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y);
+
+ /* Reload the cursor texture if the scale has changed. */
+ if (logical_monitor)
+ meta_cursor_sprite_set_theme_scale (cursor_sprite, logical_monitor->scale);
+}
+
MetaWaylandTabletTool *
meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
ClutterInputDevice *device,
@@ -398,6 +418,9 @@ meta_wayland_tablet_tool_new (MetaWaylandTabletSeat *seat,
tool->cursor_surface_destroy_listener.notify = tablet_tool_handle_cursor_surface_destroy;
tool->default_sprite = meta_cursor_sprite_from_theme (META_CURSOR_CROSSHAIR);
+ tool->prepare_at_signal_id =
+ g_signal_connect (tool->default_sprite, "prepare-at",
+ G_CALLBACK (tool_cursor_prepare_at), tool);
return tool;
}
@@ -418,6 +441,7 @@ meta_wayland_tablet_tool_free (MetaWaylandTabletTool *tool)
wl_list_init (wl_resource_get_link (resource));
}
+ g_signal_handler_disconnect (tool->default_sprite, tool->prepare_at_signal_id);
g_object_unref (tool->default_sprite);
g_slice_free (MetaWaylandTabletTool, tool);
diff --git a/src/wayland/meta-wayland-tablet-tool.h b/src/wayland/meta-wayland-tablet-tool.h
index 2e7227375..b7cfce0d6 100644
--- a/src/wayland/meta-wayland-tablet-tool.h
+++ b/src/wayland/meta-wayland-tablet-tool.h
@@ -44,6 +44,7 @@ struct _MetaWaylandTabletTool
struct wl_listener cursor_surface_destroy_listener;
MetaCursorRenderer *cursor_renderer;
MetaCursorSprite *default_sprite;
+ guint prepare_at_signal_id;
MetaWaylandSurface *current;
guint32 pressed_buttons;