|
|
9b660f |
From 391f262aee82ac12fcf99951d6b2df362f734b31 Mon Sep 17 00:00:00 2001
|
|
|
9b660f |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
9b660f |
Date: Mon, 15 Jun 2020 20:41:45 +0200
|
|
|
9b660f |
Subject: [PATCH] shell/app: Handle workspace from startup notifications
|
|
|
9b660f |
|
|
|
9b660f |
Launching applications on a particular workspace works through
|
|
|
9b660f |
launch contexts and startup notifications. While this is no
|
|
|
9b660f |
longer required by a launcher/WM split, in theory this allows
|
|
|
9b660f |
us to reliably identify the correct window to apply startup
|
|
|
9b660f |
properties to.
|
|
|
9b660f |
|
|
|
9b660f |
However in practice we fail more often than not: Missing support in
|
|
|
9b660f |
toolkits, differences between display protocols, D-Bus activation
|
|
|
9b660f |
and single-instance applications all provide their own pitfalls.
|
|
|
9b660f |
|
|
|
9b660f |
So instead, take advantage of the fact that launcher and WM live in
|
|
|
9b660f |
the same process, and go with the unsophisticated approach: Just
|
|
|
9b660f |
remember the last workspace that was requested when launching an
|
|
|
9b660f |
app, then move the next window that is associated with the app to
|
|
|
9b660f |
that workspace.
|
|
|
9b660f |
|
|
|
9b660f |
This will break X11 applications that set an initial workspace, but
|
|
|
9b660f |
that's legacy functionality anyway (given that there's no wayland
|
|
|
9b660f |
protocol for that functionality), and seems a price worth paying
|
|
|
9b660f |
for making launching apps on workspaces more reliable.
|
|
|
9b660f |
---
|
|
|
9b660f |
src/shell-app.c | 19 +++++++++++--------
|
|
|
9b660f |
1 file changed, 11 insertions(+), 8 deletions(-)
|
|
|
9b660f |
|
|
|
9b660f |
diff --git a/src/shell-app.c b/src/shell-app.c
|
|
|
9b660f |
index 7d40186c9..f716bc5f8 100644
|
|
|
9b660f |
--- a/src/shell-app.c
|
|
|
9b660f |
+++ b/src/shell-app.c
|
|
|
9b660f |
@@ -1067,6 +1067,10 @@ _shell_app_add_window (ShellApp *app,
|
|
|
9b660f |
if (!app->running_state)
|
|
|
9b660f |
create_running_state (app);
|
|
|
9b660f |
|
|
|
9b660f |
+ if (app->started_on_workspace >= 0)
|
|
|
9b660f |
+ meta_window_change_workspace_by_index (window, app->started_on_workspace, FALSE);
|
|
|
9b660f |
+ app->started_on_workspace = -1;
|
|
|
9b660f |
+
|
|
|
9b660f |
app->running_state->window_sort_stale = TRUE;
|
|
|
9b660f |
app->running_state->windows = g_slist_prepend (app->running_state->windows, g_object_ref (window));
|
|
|
9b660f |
g_signal_connect_object (window, "unmanaged", G_CALLBACK(shell_app_on_unmanaged), app, 0);
|
|
|
9b660f |
@@ -1156,16 +1160,14 @@ _shell_app_handle_startup_sequence (ShellApp *app,
|
|
|
9b660f |
shell_app_state_transition (app, SHELL_APP_STATE_STARTING);
|
|
|
9b660f |
meta_x11_display_focus_the_no_focus_window (x11_display,
|
|
|
9b660f |
meta_startup_sequence_get_timestamp (sequence));
|
|
|
9b660f |
- app->started_on_workspace = meta_startup_sequence_get_workspace (sequence);
|
|
|
9b660f |
}
|
|
|
9b660f |
|
|
|
9b660f |
- if (!starting)
|
|
|
9b660f |
- {
|
|
|
9b660f |
- if (app->running_state && app->running_state->windows)
|
|
|
9b660f |
- shell_app_state_transition (app, SHELL_APP_STATE_RUNNING);
|
|
|
9b660f |
- else /* application have > 1 .desktop file */
|
|
|
9b660f |
- shell_app_state_transition (app, SHELL_APP_STATE_STOPPED);
|
|
|
9b660f |
- }
|
|
|
9b660f |
+ if (starting)
|
|
|
9b660f |
+ app->started_on_workspace = meta_startup_sequence_get_workspace (sequence);
|
|
|
9b660f |
+ else if (app->running_state && app->running_state->windows)
|
|
|
9b660f |
+ shell_app_state_transition (app, SHELL_APP_STATE_RUNNING);
|
|
|
9b660f |
+ else /* application have > 1 .desktop file */
|
|
|
9b660f |
+ shell_app_state_transition (app, SHELL_APP_STATE_STOPPED);
|
|
|
9b660f |
}
|
|
|
9b660f |
|
|
|
9b660f |
/**
|
|
|
9b660f |
@@ -1473,6 +1475,7 @@ static void
|
|
|
9b660f |
shell_app_init (ShellApp *self)
|
|
|
9b660f |
{
|
|
|
9b660f |
self->state = SHELL_APP_STATE_STOPPED;
|
|
|
9b660f |
+ self->started_on_workspace = -1;
|
|
|
9b660f |
}
|
|
|
9b660f |
|
|
|
9b660f |
static void
|
|
|
9b660f |
--
|
|
|
9b660f |
2.29.2
|
|
|
9b660f |
|