Add workspaces_only_on_primary preferences (default FALSE)

This adds a preference that when enabled makes all windows not on
the primary monitor be visible on all workspaces (i.e. not part of the
workspace switching handling).

https://bugzilla.gnome.org/show_bug.cgi?id=609258
This commit is contained in:
Alexander Larsson 2011-02-28 13:48:28 +01:00
parent 9d62d13f88
commit 4e28a4d654
4 changed files with 60 additions and 2 deletions

View File

@ -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)
{

View File

@ -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

View File

@ -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);

View File

@ -53,5 +53,20 @@
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/mutter/general/workspaces_only_on_primary</key>
<applyto>/apps/mutter/general/workspaces_only_on_primary</applyto>
<owner>mutter</owner>
<type>bool</type>
<default>false</default>
<locale name="C">
<short>Workspaces only on primary</short>
<long>
Determines whether workspace switching should happen for windows
on all monitors or only the primary window.
</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>