summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2015-09-16 15:47:31 +0800
committerJonas Ådahl <jadahl@gmail.com>2015-10-04 14:17:14 +0800
commit130807a30803e1d691b613be074d8414c630dce9 (patch)
tree33ea7fa0c47b0ad2ffb18e02128b3744063f763c
parente84f69466830e5a3c2e6f0abc6c3f2b5f5572bb9 (diff)
downloadmutter-130807a30803e1d691b613be074d8414c630dce9.tar.gz
wayland: Don't pre-multiply root cursor sizes with primary monitor scale
We cannot use the XSETTINGS value for cursor theme size because gnome-settings-daemon already multiplies it by the primary monitor's scale. https://bugzilla.gnome.org/show_bug.cgi?id=755099
-rw-r--r--src/core/prefs.c64
1 files changed, 55 insertions, 9 deletions
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 2da8da32b..90ad10838 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -96,6 +96,10 @@ static gboolean bell_is_audible = TRUE;
static gboolean gnome_accessibility = FALSE;
static gboolean gnome_animations = TRUE;
static char *cursor_theme = NULL;
+/* cursor_size will, when running as an X11 compositing window manager, be the
+ * actual cursor size, multiplied with the global window scaling factor. On
+ * Wayland, it will be the actual cursor size retrieved from gsettings.
+ */
static int cursor_size = 24;
static int draggable_border_width = 10;
static int drag_threshold;
@@ -123,6 +127,9 @@ static gboolean update_binding (MetaKeyPref *binding,
static gboolean update_key_binding (const char *key,
gchar **strokes);
+static void wayland_settings_changed (GSettings *settings,
+ gchar *key,
+ gpointer data);
static void settings_changed (GSettings *settings,
gchar *key,
gpointer data);
@@ -134,9 +141,10 @@ static void shell_shows_app_menu_changed (GtkSettings *settings,
GParamSpec *pspec,
gpointer data);
-static void update_cursor_size (GtkSettings *settings,
- GParamSpec *pspec,
- gpointer data);
+static void update_cursor_size_from_gtk (GtkSettings *settings,
+ GParamSpec *pspec,
+ gpointer data);
+static void update_cursor_size (void);
static void queue_changed (MetaPreference pref);
@@ -963,14 +971,18 @@ meta_prefs_init (void)
G_CALLBACK (settings_changed), NULL);
g_signal_connect (settings, "changed::" KEY_GNOME_CURSOR_THEME,
G_CALLBACK (settings_changed), NULL);
+ if (meta_is_wayland_compositor ())
+ g_signal_connect (settings, "changed::cursor-size",
+ G_CALLBACK (wayland_settings_changed), NULL);
g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_INTERFACE), settings);
g_signal_connect (gtk_settings_get_default (),
"notify::gtk-shell-shows-app-menu",
G_CALLBACK (shell_shows_app_menu_changed), NULL);
- g_signal_connect (gtk_settings_get_default (), "notify::gtk-cursor-theme-size",
- G_CALLBACK (update_cursor_size), NULL);
+ if (!meta_is_wayland_compositor ())
+ g_signal_connect (gtk_settings_get_default (), "notify::gtk-cursor-theme-size",
+ G_CALLBACK (update_cursor_size_from_gtk), NULL);
settings = g_settings_new (SCHEMA_INPUT_SOURCES);
g_signal_connect (settings, "changed::" KEY_XKB_OPTIONS,
@@ -992,7 +1004,7 @@ meta_prefs_init (void)
handle_preference_init_string_array ();
handle_preference_init_int ();
- update_cursor_size (gtk_settings_get_default (), NULL, NULL);
+ update_cursor_size ();
shell_shows_app_menu_changed (gtk_settings_get_default (), NULL, NULL);
init_bindings ();
@@ -1134,6 +1146,20 @@ meta_prefs_override_preference_schema (const char *key, const char *schema)
static void
+wayland_settings_changed (GSettings *settings,
+ gchar *key,
+ gpointer data)
+{
+ GVariant *value = g_settings_get_value (settings, key);
+ const GVariantType *type = g_variant_get_type (value);
+
+ g_return_if_fail (g_variant_type_equal (type, G_VARIANT_TYPE_INT32));
+ g_return_if_fail (g_str_equal (key, "cursor-size"));
+
+ update_cursor_size ();
+}
+
+static void
settings_changed (GSettings *settings,
gchar *key,
gpointer data)
@@ -1216,9 +1242,29 @@ shell_shows_app_menu_changed (GtkSettings *settings,
}
static void
-update_cursor_size (GtkSettings *settings,
- GParamSpec *pspec,
- gpointer data)
+update_cursor_size (void)
+{
+ if (meta_is_wayland_compositor ())
+ {
+ /* When running as a Wayland compositor, since we size of the cursor
+ * depends on what output it is on, we cannot use the GTK+
+ * "gtk-cursor-theme-size" setting because it has already been multiplied
+ * by the primary monitor scale. So, instead get the non-premultiplied
+ * cursor size value directly from gsettings instead.
+ */
+ cursor_size =
+ g_settings_get_int (SETTINGS (SCHEMA_INTERFACE), "cursor-size");
+ }
+ else
+ {
+ update_cursor_size_from_gtk (gtk_settings_get_default (), NULL, NULL);
+ }
+}
+
+static void
+update_cursor_size_from_gtk (GtkSettings *settings,
+ GParamSpec *pspec,
+ gpointer data)
{
GdkScreen *screen = gdk_screen_get_default ();
GValue value = G_VALUE_INIT;