[gnome-shell] shell/app: Handle workspace from startup notifications
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] shell/app: Handle workspace from startup notifications
- Date: Tue, 2 Mar 2021 22:23:30 +0000 (UTC)
commit 9a273e1db22ad873f8e683c66ee59c2bcdf7b390
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Jun 15 20:41:45 2020 +0200
shell/app: Handle workspace from startup notifications
Launching applications on a particular workspace works through
launch contexts and startup notifications. While this is no
longer required by a launcher/WM split, in theory this allows
us to reliably identify the correct window to apply startup
properties to.
However in practice we fail more often than not: Missing support in
toolkits, differences between display protocols, D-Bus activation
and single-instance applications all provide their own pitfalls.
So instead, take advantage of the fact that launcher and WM live in
the same process, and go with the unsophisticated approach: Just
remember the last workspace that was requested when launching an
app, then move the next window that is associated with the app to
that workspace.
This will break X11 applications that set an initial workspace, but
that's legacy functionality anyway (given that there's no wayland
protocol for that functionality), and seems a price worth paying
for making launching apps on workspaces more reliable.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1316>
src/shell-app.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/shell-app.c b/src/shell-app.c
index 4fd69e6f13..7d7b5510d6 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -1081,6 +1081,10 @@ _shell_app_add_window (ShellApp *app,
if (!app->running_state)
create_running_state (app);
+ if (app->started_on_workspace >= 0)
+ meta_window_change_workspace_by_index (window, app->started_on_workspace, FALSE);
+ app->started_on_workspace = -1;
+
app->running_state->window_sort_stale = TRUE;
app->running_state->windows = g_slist_prepend (app->running_state->windows, g_object_ref (window));
g_signal_connect_object (window, "unmanaged", G_CALLBACK(shell_app_on_unmanaged), app, 0);
@@ -1173,16 +1177,14 @@ _shell_app_handle_startup_sequence (ShellApp *app,
shell_app_state_transition (app, SHELL_APP_STATE_STARTING);
meta_display_unset_input_focus (display,
meta_startup_sequence_get_timestamp (sequence));
- app->started_on_workspace = meta_startup_sequence_get_workspace (sequence);
}
- if (!starting)
- {
- if (app->running_state && app->running_state->windows)
- shell_app_state_transition (app, SHELL_APP_STATE_RUNNING);
- else /* application have > 1 .desktop file */
- shell_app_state_transition (app, SHELL_APP_STATE_STOPPED);
- }
+ if (starting)
+ app->started_on_workspace = meta_startup_sequence_get_workspace (sequence);
+ else if (app->running_state && app->running_state->windows)
+ shell_app_state_transition (app, SHELL_APP_STATE_RUNNING);
+ else /* application have > 1 .desktop file */
+ shell_app_state_transition (app, SHELL_APP_STATE_STOPPED);
}
/**
@@ -1550,6 +1552,7 @@ static void
shell_app_init (ShellApp *self)
{
self->state = SHELL_APP_STATE_STOPPED;
+ self->started_on_workspace = -1;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]