Skip to content

Commit 8b059f6

Browse files
committed
Restore the 'bring windows which require attention to the current
workspace' feature.
1 parent 34c8a70 commit 8b059f6

File tree

3 files changed

+57
-12
lines changed

3 files changed

+57
-12
lines changed

src/core/prefs.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#define KEY_XKB_OPTIONS "xkb-options"
6060

6161
#define KEY_MOUSEWHEEL_ZOOM_ENABLED "screen-magnifier-enabled"
62+
#define KEY_BRING_ACTIVATED_WINDOWS_TO_CURRENT_WORKSPACE "bring-windows-to-current-workspace"
6263

6364
#define KEY_OVERLAY_KEY "overlay-key"
6465
#define KEY_WORKSPACES_ONLY_ON_PRIMARY "workspaces-only-on-primary"
@@ -74,6 +75,7 @@
7475
#define SCHEMA_INPUT_SOURCES "org.cinnamon.desktop.input-sources"
7576
#define SCHEMA_MOUSE "org.cinnamon.desktop.peripherals.mouse"
7677
#define SCHEMA_A11Y_APPLICATIONS "org.cinnamon.desktop.a11y.applications"
78+
#define SCHEMA_CINNAMON "org.cinnamon"
7779

7880
#define SETTINGS(s) g_hash_table_lookup (settings_schemas, (s))
7981

@@ -141,6 +143,7 @@ static gboolean unredirect_fullscreen_windows = FALSE;
141143
static gboolean tile_maximize = FALSE;
142144
static char *gtk_theme = NULL;
143145
static char *bell_sound = NULL;
146+
static gboolean bring_user_activated_windows_to_current_workspace = FALSE;
144147

145148
static void handle_preference_update_enum (GSettings *settings,
146149
gchar *key);
@@ -461,6 +464,13 @@ static MetaBoolPreference preferences_bool[] =
461464
},
462465
&tile_maximize,
463466
},
467+
{
468+
{ "bring-windows-to-current-workspace",
469+
SCHEMA_CINNAMON,
470+
META_PREF_BRING_WINDOWS_TO_CURRENT_WORKSPACE,
471+
},
472+
&bring_user_activated_windows_to_current_workspace,
473+
},
464474
{ { NULL, 0, 0 }, NULL },
465475
};
466476

@@ -1103,9 +1113,13 @@ meta_prefs_init (void)
11031113
settings = g_settings_new (SCHEMA_A11Y_APPLICATIONS);
11041114
g_signal_connect (settings, "changed::" KEY_MOUSEWHEEL_ZOOM_ENABLED,
11051115
G_CALLBACK (settings_changed), NULL);
1106-
11071116
g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_A11Y_APPLICATIONS), settings);
11081117

1118+
settings = g_settings_new (SCHEMA_CINNAMON);
1119+
g_signal_connect (settings, "changed::" KEY_BRING_ACTIVATED_WINDOWS_TO_CURRENT_WORKSPACE,
1120+
G_CALLBACK (settings_changed), NULL);
1121+
g_hash_table_insert (settings_schemas, g_strdup (SCHEMA_CINNAMON), settings);
1122+
11091123
/* Individual keys we watch outside of our schemas */
11101124
settings = g_settings_new (SCHEMA_INTERFACE);
11111125
g_signal_connect (settings, "changed::" KEY_GNOME_ACCESSIBILITY,
@@ -1313,6 +1327,15 @@ meta_prefs_get_raise_on_click (void)
13131327
return raise_on_click;
13141328
}
13151329

1330+
gboolean
1331+
meta_prefs_get_bring_windows_to_current_workspace (void)
1332+
{
1333+
/* Windows that the user activates (with a current timestamp) will
1334+
* be brought to the currently active workspace if necessary. Normally
1335+
* the user is brought to the window's workspace instead. */
1336+
return bring_user_activated_windows_to_current_workspace;
1337+
}
1338+
13161339
gboolean
13171340
meta_prefs_get_show_fallback_app_menu (void)
13181341
{
@@ -1929,6 +1952,9 @@ meta_preference_to_string (MetaPreference pref)
19291952

19301953
case META_PREF_BELL_SOUND:
19311954
return "BELL_SOUND";
1955+
1956+
case META_PREF_BRING_WINDOWS_TO_CURRENT_WORKSPACE:
1957+
return "BRING_WINDOWS_TO_CURRENT_WORKSPACE";
19321958
}
19331959

19341960
return "(unknown)";

src/core/window.c

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,16 +3969,30 @@ meta_window_activate_full (MetaWindow *window,
39693969
if (workspace == NULL)
39703970
workspace = workspace_manager->active_workspace;
39713971

3972-
/* For non-transient windows, we just set up a pulsing indicator,
3973-
rather than move windows or workspaces.
3974-
See http://bugzilla.gnome.org/show_bug.cgi?id=482354 */
3975-
if (window->transient_for == NULL &&
3976-
!allow_workspace_switch &&
3977-
!meta_window_located_on_workspace (window, workspace))
3978-
{
3979-
meta_window_set_demands_attention (window);
3980-
/* We've marked it as demanding, don't need to do anything else. */
3981-
return;
3972+
// allow_workspace_switch == "user action"
3973+
3974+
if (window->transient_for == NULL)
3975+
{
3976+
if (!allow_workspace_switch &&
3977+
!meta_window_located_on_workspace (window, workspace))
3978+
{
3979+
meta_window_set_demands_attention (window);
3980+
return;
3981+
}
3982+
else
3983+
{
3984+
if (!meta_window_located_on_workspace (window, workspace))
3985+
{
3986+
if (meta_prefs_get_bring_windows_to_current_workspace ())
3987+
{
3988+
meta_window_change_workspace (window, workspace);
3989+
}
3990+
else
3991+
{
3992+
meta_workspace_activate (window->workspace, timestamp);
3993+
}
3994+
}
3995+
}
39823996
}
39833997
else if (window->transient_for != NULL)
39843998
{

src/meta/prefs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
* @META_PREF_LOCATE_POINTER: show pointer location
7171
* @META_PREF_GTK_THEME: gtk theme name
7272
* @META_PREF_BELL_SOUND: sound to use for audible event bell
73+
* @META_PREF_BRING_WINDOWS_TO_CURRENT_WORKSPACE: behavior when use activates an off-workspace window.
7374
*/
7475

7576
/* Keep in sync with GSettings schemas! */
@@ -119,7 +120,8 @@ typedef enum
119120
META_PREF_MOUSE_ZOOM_ENABLED,
120121
META_PREF_TILE_MAXIMIZE,
121122
META_PREF_GTK_THEME,
122-
META_PREF_BELL_SOUND
123+
META_PREF_BELL_SOUND,
124+
META_PREF_BRING_WINDOWS_TO_CURRENT_WORKSPACE
123125
} MetaPreference;
124126

125127
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
@@ -160,6 +162,9 @@ CDesktopFocusMode meta_prefs_get_focus_mode (void);
160162
META_EXPORT
161163
CDesktopFocusNewWindows meta_prefs_get_focus_new_windows (void);
162164

165+
META_EXPORT
166+
gboolean meta_prefs_get_bring_windows_to_current_workspace (void);
167+
163168
META_EXPORT
164169
gboolean meta_prefs_get_attach_modal_dialogs (void);
165170

0 commit comments

Comments
 (0)