prefs: Update cursor size based on xsettings

We shouldn't scale the cursor size in mutter we g-s-d exports
the correct size on hidpi so use gtk-cursor-theme-size.

This way we also catch changes on resolution updates.

https://bugzilla.gnome.org/show_bug.cgi?id=729337
This commit is contained in:
Adel Gadllah 2014-07-28 11:02:03 +02:00
parent ab40dfdd51
commit 493c0f71d2

View File

@ -137,6 +137,10 @@ static void xsettings_overrides_changed (GSettings *settings,
gchar *key, gchar *key,
gpointer data); gpointer data);
static void update_cursor_size (GtkSettings *settings,
GParamSpec *pspec,
gpointer data);
static void queue_changed (MetaPreference pref); static void queue_changed (MetaPreference pref);
static void maybe_give_disable_workarounds_warning (void); static void maybe_give_disable_workarounds_warning (void);
@ -1012,6 +1016,9 @@ meta_prefs_init (void)
xsettings_overrides_changed (settings, KEY_XSETTINGS_OVERRIDES, NULL); xsettings_overrides_changed (settings, KEY_XSETTINGS_OVERRIDES, NULL);
} }
g_signal_connect (gtk_settings_get_default (), "notify::gtk-cursor-theme-size",
G_CALLBACK (update_cursor_size), NULL);
settings = g_settings_new (SCHEMA_INPUT_SOURCES); settings = g_settings_new (SCHEMA_INPUT_SOURCES);
g_signal_connect (settings, "changed::" KEY_XKB_OPTIONS, g_signal_connect (settings, "changed::" KEY_XKB_OPTIONS,
G_CALLBACK (settings_changed), NULL); G_CALLBACK (settings_changed), NULL);
@ -1032,6 +1039,8 @@ meta_prefs_init (void)
handle_preference_init_string_array (); handle_preference_init_string_array ();
handle_preference_init_int (); handle_preference_init_int ();
update_cursor_size (gtk_settings_get_default (), NULL, NULL);
init_bindings (); init_bindings ();
} }
@ -1270,6 +1279,29 @@ out:
queue_changed (META_PREF_BUTTON_LAYOUT); queue_changed (META_PREF_BUTTON_LAYOUT);
} }
static void
update_cursor_size (GtkSettings *settings,
GParamSpec *pspec,
gpointer data)
{
GdkScreen *screen = gdk_screen_get_default ();
GValue value = G_VALUE_INIT;
int xsettings_cursor_size = 24;
g_value_init (&value, G_TYPE_INT);
if (gdk_screen_get_setting (screen, "gtk-cursor-theme-size", &value))
{
xsettings_cursor_size = g_value_get_int (&value);
}
if (xsettings_cursor_size != cursor_size)
{
cursor_size = xsettings_cursor_size;
queue_changed (META_PREF_CURSOR_SIZE);
}
}
/** /**
* maybe_give_disable_workaround_warning: * maybe_give_disable_workaround_warning:
* *