diff --git a/src/core/prefs.c b/src/core/prefs.c index 1d0c1183a..73d2fc336 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -67,6 +67,7 @@ #define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_" #define KEY_LIVE_HIDDEN_WINDOWS "/apps/mutter/general/live_hidden_windows" +#define KEY_WORKSPACES_ONLY_ON_PRIMARY "/apps/mutter/general/workspaces_only_on_primary" #define KEY_NO_TAB_POPUP "/apps/metacity/general/no_tab_popup" @@ -114,6 +115,7 @@ static char *terminal_command = NULL; static char *workspace_names[MAX_REASONABLE_WORKSPACES] = { NULL, }; static gboolean live_hidden_windows = FALSE; +static gboolean workspaces_only_on_primary = FALSE; static gboolean no_tab_popup = FALSE; @@ -421,6 +423,11 @@ static MetaBoolPreference preferences_bool[] = &live_hidden_windows, FALSE, }, + { "/apps/mutter/general/workspaces_only_on_primary", + META_PREF_WORKSPACES_ONLY_ON_PRIMARY, + &workspaces_only_on_primary, + FALSE, + }, { "/apps/metacity/general/no_tab_popup", META_PREF_NO_TAB_POPUP, &no_tab_popup, @@ -1973,6 +1980,9 @@ meta_preference_to_string (MetaPreference pref) case META_PREF_LIVE_HIDDEN_WINDOWS: return "LIVE_HIDDEN_WINDOWS"; + case META_PREF_WORKSPACES_ONLY_ON_PRIMARY: + return "WORKSPACES_ONLY_ON_PRIMARY"; + case META_PREF_NO_TAB_POPUP: return "NO_TAB_POPUP"; } @@ -2993,6 +3003,13 @@ meta_prefs_set_live_hidden_windows (gboolean whether) #endif } +gboolean +meta_prefs_get_workspaces_only_on_primary (void) +{ + return workspaces_only_on_primary; +} + + gboolean meta_prefs_get_no_tab_popup (void) { diff --git a/src/core/window.c b/src/core/window.c index b60821513..ca5aeb6e0 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1574,7 +1574,9 @@ should_be_on_all_workspaces (MetaWindow *window) { return window->on_all_workspaces_requested || - window->override_redirect; + window->override_redirect || + (meta_prefs_get_workspaces_only_on_primary () && + !meta_window_is_on_primary_monitor (window)); } void @@ -4081,7 +4083,28 @@ meta_window_get_monitor (MetaWindow *window) void meta_window_update_monitor (MetaWindow *window) { + const MetaMonitorInfo *old; + + old = window->monitor; window->monitor = meta_screen_get_monitor_for_window (window->screen, window); + if (old != window->monitor) + { + meta_window_update_on_all_workspaces (window); + + /* If workspaces only on primary and we moved back to primary, ensure that the + * window is now in that workspace. We do this because while the window is on a + * non-primary monitor it is always visible, so it would be very jarring if it + * disappeared when it crossed the monitor border. + * The one time we want it to both change to the primary monitor and a non-active + * workspace is when dropping the window on some other workspace thumbnail directly. + * That should be handled by explicitly moving the window before changing the + * workspace + */ + if (meta_prefs_get_workspaces_only_on_primary () && + meta_window_is_on_primary_monitor (window) && + window->screen->active_workspace != window->workspace) + meta_window_change_workspace (window, window->screen->active_workspace); + } } static void diff --git a/src/meta/prefs.h b/src/meta/prefs.h index 672a30516..8be7dcfd1 100644 --- a/src/meta/prefs.h +++ b/src/meta/prefs.h @@ -62,6 +62,7 @@ typedef enum META_PREF_EDGE_TILING, META_PREF_FORCE_FULLSCREEN, META_PREF_LIVE_HIDDEN_WINDOWS, + META_PREF_WORKSPACES_ONLY_ON_PRIMARY, META_PREF_NO_TAB_POPUP } MetaPreference; @@ -136,6 +137,8 @@ void meta_prefs_set_force_fullscreen (gboolean whether); gboolean meta_prefs_get_live_hidden_windows (void); void meta_prefs_set_live_hidden_windows (gboolean whether); +gboolean meta_prefs_get_workspaces_only_on_primary (void); + gboolean meta_prefs_get_no_tab_popup (void); void meta_prefs_set_no_tab_popup (gboolean whether); diff --git a/src/mutter.schemas.in b/src/mutter.schemas.in index 1a8fad38e..821b40f67 100644 --- a/src/mutter.schemas.in +++ b/src/mutter.schemas.in @@ -53,5 +53,20 @@ - + + + /schemas/apps/mutter/general/workspaces_only_on_primary + /apps/mutter/general/workspaces_only_on_primary + mutter + bool + false + + Workspaces only on primary + + Determines whether workspace switching should happen for windows + on all monitors or only the primary window. + + + +