From 607dbf0f43a59a96f6902398441efb351c4b00ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 8 Mar 2012 01:29:58 +0100 Subject: [PATCH] prefs: Add dynamic-workspaces setting We currently sync the number of workspaces with the corresponding preference. This is not really useful with GNOME Shell's dynamic handling of workspaces, not least as the setting is effectively ignored. Worse, it will trigger writes to dconf on login, slowing down startup, so add a setting to indicate that workspaces are managed dynamically and really ignore the num-workspaces setting when set. https://bugzilla.gnome.org/show_bug.cgi?id=671568 --- src/core/prefs.c | 14 ++++++++++++++ src/core/screen.c | 12 +++++++++--- src/meta/prefs.h | 2 ++ src/org.gnome.mutter.gschema.xml.in | 10 ++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/core/prefs.c b/src/core/prefs.c index 92aec455e..58ee473cf 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -82,6 +82,7 @@ static int num_workspaces = 4; static GDesktopTitlebarAction action_double_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE; static GDesktopTitlebarAction action_middle_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_LOWER; static GDesktopTitlebarAction action_right_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_MENU; +static gboolean dynamic_workspaces = FALSE; static gboolean application_based = FALSE; static gboolean disable_workarounds = FALSE; static gboolean auto_raise = FALSE; @@ -280,6 +281,13 @@ static MetaBoolPreference preferences_bool[] = }, &use_system_font, }, + { + { "dynamic-workspaces", + SCHEMA_MUTTER, + META_PREF_DYNAMIC_WORKSPACES, + }, + &dynamic_workspaces, + }, { { "application-based", SCHEMA_GENERAL, @@ -1498,6 +1506,12 @@ meta_prefs_get_num_workspaces (void) return num_workspaces; } +gboolean +meta_prefs_get_dynamic_workspaces (void) +{ + return dynamic_workspaces; +} + gboolean meta_prefs_get_application_based (void) { diff --git a/src/core/screen.c b/src/core/screen.c index 4010c7a71..ba2b96717 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -1173,7 +1173,9 @@ prefs_changed_callback (MetaPreference pref, { MetaScreen *screen = data; - if (pref == META_PREF_NUM_WORKSPACES) + if ((pref == META_PREF_NUM_WORKSPACES || + pref == META_PREF_DYNAMIC_WORKSPACES) && + !meta_prefs_get_dynamic_workspaces ()) { /* GSettings doesn't provide timestamps, but luckily update_num_workspaces * often doesn't need it... @@ -1483,7 +1485,9 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace, new_num = g_list_length (screen->workspaces); set_number_of_spaces_hint (screen, new_num); - meta_prefs_set_num_workspaces (new_num); + + if (!meta_prefs_get_dynamic_workspaces ()) + meta_prefs_set_num_workspaces (new_num); /* If deleting a workspace before the current workspace, the active * workspace index changes, so we need to update that hint */ @@ -1538,7 +1542,9 @@ meta_screen_append_new_workspace (MetaScreen *screen, gboolean activate, new_num = g_list_length (screen->workspaces); set_number_of_spaces_hint (screen, new_num); - meta_prefs_set_num_workspaces (new_num); + + if (!meta_prefs_get_dynamic_workspaces ()) + meta_prefs_set_num_workspaces (new_num); meta_screen_queue_workarea_recalc (screen); diff --git a/src/meta/prefs.h b/src/meta/prefs.h index 8232a7254..bfdc72643 100644 --- a/src/meta/prefs.h +++ b/src/meta/prefs.h @@ -47,6 +47,7 @@ typedef enum META_PREF_THEME, META_PREF_TITLEBAR_FONT, META_PREF_NUM_WORKSPACES, + META_PREF_DYNAMIC_WORKSPACES, META_PREF_APPLICATION_BASED, META_PREF_KEYBINDINGS, META_PREF_DISABLE_WORKAROUNDS, @@ -94,6 +95,7 @@ const char* meta_prefs_get_theme (void); /* returns NULL if GTK default should be used */ const PangoFontDescription* meta_prefs_get_titlebar_font (void); int meta_prefs_get_num_workspaces (void); +gboolean meta_prefs_get_dynamic_workspaces (void); gboolean meta_prefs_get_application_based (void); gboolean meta_prefs_get_disable_workarounds (void); gboolean meta_prefs_get_auto_raise (void); diff --git a/src/org.gnome.mutter.gschema.xml.in b/src/org.gnome.mutter.gschema.xml.in index 8d11154e1..e3c559049 100644 --- a/src/org.gnome.mutter.gschema.xml.in +++ b/src/org.gnome.mutter.gschema.xml.in @@ -45,6 +45,16 @@ + + false + <_summary>Workspaces are managed dynamically + <_description> + Determines whether workspaces are managed dynamically or + whether there's a static number of workspaces (determined + by the num-workspaces key in org.gnome.desktop.wm.preferences). + + + false <_summary>Workspaces only on primary