From 191b3f2c21fbe0d0d135505c0ad39c1df97423c3 Mon Sep 17 00:00:00 2001 From: Rob Adams Date: Sun, 14 Dec 2003 19:19:40 +0000 Subject: [PATCH] set on_all_workspaces in all cases _before_ adding to the workspaces, so 2003-12-13 Rob Adams * src/window.c (meta_window_new_with_attrs): set on_all_workspaces in all cases _before_ adding to the workspaces, so that windows initially on all workspaces are added correctly to the MRU lists. Fix for #120907. * src/workspace.c (meta_workspace_add_window): handle sticky windows so that we add to add mru lists if needed (meta_workspace_remove_window): handle sticky windows so that they are removed from all mru lists if needed. --- ChangeLog | 12 ++++++++++++ src/window.c | 34 ++++++++++++++++----------------- src/workspace.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 77 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e085d493..d4ff2949d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2003-12-13 Rob Adams + + * src/window.c (meta_window_new_with_attrs): set on_all_workspaces + in all cases _before_ adding to the workspaces, so that windows + initially on all workspaces are added correctly to the MRU lists. + Fix for #120907. + + * src/workspace.c (meta_workspace_add_window): handle sticky + windows so that we add to add mru lists if needed + (meta_workspace_remove_window): handle sticky windows so that they + are removed from all mru lists if needed. + 2003-12-12 Havoc Pennington * src/window.c (meta_window_free): unstick window to get it out of diff --git a/src/window.c b/src/window.c index 55db941bf..384d790a1 100644 --- a/src/window.c +++ b/src/window.c @@ -581,6 +581,17 @@ meta_window_new_with_attrs (MetaDisplay *display, meta_window_grab_keys (window); meta_display_grab_window_buttons (window->display, window->xwindow); meta_display_grab_focus_window_button (window->display, window); + + if (window->type == META_WINDOW_DESKTOP || + window->type == META_WINDOW_DOCK) + { + /* Change the default, but don't enforce this if the user + * focuses the dock/desktop and unsticks it using key shortcuts. + * Need to set this before adding to the workspaces so the MRU + * lists will be updated. + */ + window->on_all_workspaces = TRUE; + } /* For the workspace, first honor hints, * if that fails put transients with parents, @@ -595,8 +606,11 @@ meta_window_new_with_attrs (MetaDisplay *display, "Window %s is initially on all spaces\n", window->desc); - meta_workspace_add_window (window->screen->active_workspace, window); + /* need to set on_all_workspaces first so that it will be + * added to all the MRU lists + */ window->on_all_workspaces = TRUE; + meta_workspace_add_window (window->screen->active_workspace, window); } else { @@ -636,6 +650,8 @@ meta_window_new_with_attrs (MetaDisplay *display, tmp_list = parent->workspaces; while (tmp_list != NULL) { + /* this will implicitly add to the appropriate MRU lists + */ meta_workspace_add_window (tmp_list->data, window); tmp_list = tmp_list->next; @@ -654,16 +670,6 @@ meta_window_new_with_attrs (MetaDisplay *display, meta_workspace_add_window (space, window); } - if (window->type == META_WINDOW_DESKTOP || - window->type == META_WINDOW_DOCK) - { - /* Change the default, but don't enforce this if - * the user focuses the dock/desktop and unsticks it - * using key shortcuts - */ - window->on_all_workspaces = TRUE; - } - /* for the various on_all_workspaces = TRUE possible above */ meta_window_set_current_workspace_hint (window); @@ -944,12 +950,6 @@ meta_window_free (MetaWindow *window) meta_window_unqueue_move_resize (window); meta_window_unqueue_update_icon (window); meta_window_free_delete_dialog (window); - - /* We need to unstick to remove the window from - * any workspace->mru_list for workspaces not - * in window->workspaces - */ - meta_window_unstick (window); tmp = window->workspaces; while (tmp != NULL) diff --git a/src/workspace.c b/src/workspace.c index e8a820df5..25868c1c0 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -112,11 +112,33 @@ meta_workspace_add_window (MetaWorkspace *workspace, { g_return_if_fail (!meta_workspace_contains_window (workspace, window)); + /* If the window is on all workspaces, we want to add it to all mru + * lists, otherwise just add it to this workspaces mru list + */ + if (window->on_all_workspaces) + { + if (window->workspaces == NULL) + { + GList* tmp = window->screen->workspaces; + while (tmp) + { + MetaWorkspace* work = (MetaWorkspace*) tmp->data; + if (!g_list_find (work->mru_list, window)) + work->mru_list = g_list_append (work->mru_list, window); + + tmp = tmp->next; + } + } + } + else + { + g_assert (g_list_find (workspace->mru_list, window) == NULL); + workspace->mru_list = g_list_append (workspace->mru_list, window); + } + workspace->windows = g_list_prepend (workspace->windows, window); window->workspaces = g_list_prepend (window->workspaces, workspace); - workspace->mru_list = g_list_append (workspace->mru_list, window); - meta_window_set_current_workspace_hint (window); meta_window_queue_calc_showing (window); @@ -142,7 +164,30 @@ meta_workspace_remove_window (MetaWorkspace *workspace, workspace->windows = g_list_remove (workspace->windows, window); window->workspaces = g_list_remove (window->workspaces, workspace); - workspace->mru_list = g_list_remove (workspace->mru_list, window); + + /* If the window is on all workspaces, we don't want to remove it + * from the MRU list unless this causes it to be removed from all + * workspaces + */ + if (window->on_all_workspaces) + { + if (window->workspaces == NULL) + { + GList* tmp = window->screen->workspaces; + while (tmp) + { + MetaWorkspace* work = (MetaWorkspace*) tmp->data; + work->mru_list = g_list_remove (work->mru_list, window); + + tmp = tmp->next; + } + } + } + else + { + workspace->mru_list = g_list_remove (workspace->mru_list, window); + g_assert (g_list_find (workspace->mru_list, window) == NULL); + } meta_window_set_current_workspace_hint (window);