diff --git a/src/shell-app.c b/src/shell-app.c index 30ea6b8f7..99f51ede8 100644 --- a/src/shell-app.c +++ b/src/shell-app.c @@ -930,6 +930,37 @@ shell_app_on_user_time_changed (MetaWindow *window, } } +static void +shell_app_sync_running_state (ShellApp *app) +{ + g_return_if_fail (app->running_state != NULL); + + if (app->running_state->interesting_windows == 0) + shell_app_state_transition (app, SHELL_APP_STATE_STOPPED); + else if (app->state != SHELL_APP_STATE_STARTING) + shell_app_state_transition (app, SHELL_APP_STATE_RUNNING); +} + + +static void +shell_app_on_skip_taskbar_changed (MetaWindow *window, + GParamSpec *pspec, + ShellApp *app) +{ + g_assert (app->running_state != NULL); + + /* we rely on MetaWindow:skip-taskbar only being notified + * when it actually changes; when that assumption breaks, + * we'll have to track the "interesting" windows themselves + */ + if (meta_window_is_skip_taskbar (window)) + app->running_state->interesting_windows--; + else + app->running_state->interesting_windows++; + + shell_app_sync_running_state (app); +} + static void shell_app_on_ws_switch (MetaScreen *screen, int from, @@ -1026,16 +1057,14 @@ _shell_app_add_window (ShellApp *app, app->running_state->windows = g_slist_prepend (app->running_state->windows, g_object_ref (window)); g_signal_connect (window, "unmanaged", G_CALLBACK(shell_app_on_unmanaged), app); g_signal_connect (window, "notify::user-time", G_CALLBACK(shell_app_on_user_time_changed), app); + g_signal_connect (window, "notify::skip-taskbar", G_CALLBACK(shell_app_on_skip_taskbar_changed), app); shell_app_update_app_menu (app, window); shell_app_ensure_busy_watch (app); if (shell_window_tracker_is_window_interesting (window)) app->running_state->interesting_windows++; - - if (app->state != SHELL_APP_STATE_STARTING && - app->running_state->interesting_windows > 0) - shell_app_state_transition (app, SHELL_APP_STATE_RUNNING); + shell_app_sync_running_state (app); g_object_thaw_notify (G_OBJECT (app)); @@ -1053,14 +1082,13 @@ _shell_app_remove_window (ShellApp *app, g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_unmanaged), app); g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_user_time_changed), app); + g_signal_handlers_disconnect_by_func (window, G_CALLBACK(shell_app_on_skip_taskbar_changed), app); g_object_unref (window); app->running_state->windows = g_slist_remove (app->running_state->windows, window); if (shell_window_tracker_is_window_interesting (window)) app->running_state->interesting_windows--; - - if (app->running_state->interesting_windows == 0) - shell_app_state_transition (app, SHELL_APP_STATE_STOPPED); + shell_app_sync_running_state (app); if (app->running_state && app->running_state->windows == NULL) g_clear_pointer (&app->running_state, unref_running_state);