diff options
Diffstat (limited to 'src/core/prefs.c')
-rw-r--r-- | src/core/prefs.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/core/prefs.c b/src/core/prefs.c index 4847de6be..3855dd9fc 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -55,6 +55,7 @@ #define KEY_GNOME_CURSOR_THEME "cursor-theme" #define KEY_GNOME_CURSOR_SIZE "cursor-size" #define KEY_XKB_OPTIONS "xkb-options" +#define KEY_XSETTINGS_OVERRIDES "overrides" #define KEY_OVERLAY_KEY "overlay-key" #define KEY_WORKSPACES_ONLY_ON_PRIMARY "workspaces-only-on-primary" @@ -65,6 +66,7 @@ #define SCHEMA_MUTTER "org.gnome.mutter" #define SCHEMA_INTERFACE "org.gnome.desktop.interface" #define SCHEMA_INPUT_SOURCES "org.gnome.desktop.input-sources" +#define SCHEMA_XSETTINGS "org.gnome.settings-daemon.plugins.xsettings" #define SETTINGS(s) g_hash_table_lookup (settings_schemas, (s)) @@ -104,6 +106,7 @@ static gboolean edge_tiling = FALSE; static gboolean force_fullscreen = TRUE; static gboolean ignore_request_hide_titlebar = FALSE; static gboolean auto_maximize = TRUE; +static gboolean show_fallback_app_menu = FALSE; static GDesktopVisualBellType visual_bell_type = G_DESKTOP_VISUAL_BELL_FULLSCREEN_FLASH; static MetaButtonLayout button_layout; @@ -129,6 +132,10 @@ static void bindings_changed (GSettings *settings, gchar *key, gpointer data); +static void xsettings_overrides_changed (GSettings *settings, + gchar *key, + gpointer data); + static void queue_changed (MetaPreference pref); static void maybe_give_disable_workarounds_warning (void); @@ -936,6 +943,24 @@ queue_changed (MetaPreference pref) /* Initialisation. */ /****************************************************************************/ +static GSettings * +get_xsettings_settings (void) +{ + GSettings *settings = NULL; + GSettingsSchema *schema; + + schema = g_settings_schema_source_lookup (g_settings_schema_source_get_default (), + SCHEMA_XSETTINGS, FALSE); + + if (schema) + { + settings = g_settings_new_full (schema, NULL, NULL); + g_settings_schema_unref (schema); + } + + return settings; +} + void meta_prefs_init (void) { @@ -965,6 +990,16 @@ meta_prefs_init (void) G_CALLBACK (settings_changed), NULL); g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_INTERFACE), settings); + settings = get_xsettings_settings (); + if (settings) + { + g_signal_connect (settings, "changed::" KEY_XSETTINGS_OVERRIDES, + G_CALLBACK (xsettings_overrides_changed), NULL); + g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_XSETTINGS), settings); + + xsettings_overrides_changed (settings, KEY_XSETTINGS_OVERRIDES, NULL); + } + settings = g_settings_new (SCHEMA_INPUT_SOURCES); g_signal_connect (settings, "changed::" KEY_XKB_OPTIONS, G_CALLBACK (settings_changed), NULL); @@ -1184,6 +1219,38 @@ bindings_changed (GSettings *settings, g_strfreev (strokes); } +/* The fallback app menu should be enabled if either we are not + * showing the app menu (e.g. when using the default plugin) or + * with a corresponding XSettings override; we ignore the former + * and assume that we always show the app menu, not least + * because we rely on the compositor implementation to display + * the fallback ... + */ +static void +xsettings_overrides_changed (GSettings *settings, + gchar *key, + gpointer data) +{ + GVariant *value; + GVariantDict overrides; + int shell_shows_app_menu = 1; + + if (!g_settings_get_boolean (settings, "active")) + goto out; + + value = g_settings_get_value (settings, KEY_XSETTINGS_OVERRIDES); + + g_variant_dict_init (&overrides, value); + g_variant_unref (value); + + g_variant_dict_lookup (&overrides, + "Gtk/ShellShowsAppMenu", "i", &shell_shows_app_menu); + g_variant_dict_clear (&overrides); + +out: + show_fallback_app_menu = !shell_shows_app_menu; +} + /** * maybe_give_disable_workaround_warning: * @@ -1243,6 +1310,12 @@ meta_prefs_get_raise_on_click (void) return raise_on_click || focus_mode == G_DESKTOP_FOCUS_MODE_CLICK; } +gboolean +meta_prefs_get_show_fallback_app_menu (void) +{ + return show_fallback_app_menu; +} + const char* meta_prefs_get_theme (void) { @@ -1398,6 +1471,8 @@ button_function_from_string (const char *str) { if (strcmp (str, "menu") == 0) return META_BUTTON_FUNCTION_MENU; + else if (strcmp (str, "appmenu") == 0) + return META_BUTTON_FUNCTION_APPMENU; else if (strcmp (str, "minimize") == 0) return META_BUTTON_FUNCTION_MINIMIZE; else if (strcmp (str, "maximize") == 0) |