From 1e6cb43815964454889825373c4e793f155265a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 6 Aug 2019 13:19:59 +0200 Subject: [PATCH] shell-app: Consider desktop actions in can_open_new_window() We currently only consider a remote "app.new-window" action when running, but not a fixed "new-window" action in the .desktop file. The latter is clearly useful as well, in particular as open_new_window() already does, so add it. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/665 --- src/shell-app.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/shell-app.c b/src/shell-app.c index b8fd9384f..7968e3358 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -601,6 +601,8 @@ shell_app_can_open_new_window (ShellApp *app) { ShellAppRunningState *state; MetaWindow *window; + GDesktopAppInfo *desktop_info; + const char * const *desktop_actions; /* Apps that are not running can always open new windows, because activating them would open the first one */ @@ -619,12 +621,18 @@ shell_app_can_open_new_window (ShellApp *app) if (!app->info) return FALSE; + desktop_info = G_DESKTOP_APP_INFO (app->info); + /* If the app is explicitly telling us, then we know for sure */ - if (g_desktop_app_info_has_key (G_DESKTOP_APP_INFO (app->info), - "X-GNOME-SingleWindow")) - return !g_desktop_app_info_get_boolean (G_DESKTOP_APP_INFO (app->info), + if (g_desktop_app_info_has_key (desktop_info, "X-GNOME-SingleWindow")) + return !g_desktop_app_info_get_boolean (desktop_info, "X-GNOME-SingleWindow"); + /* If it has a new-window desktop action, it should be able to */ + desktop_actions = g_desktop_app_info_list_actions (desktop_info); + if (desktop_actions && g_strv_contains (desktop_actions, "new-window")) + return TRUE; + /* If this is a unique GtkApplication, and we don't have a new-window, then probably we can't