From 16a8add6f80eaa804315cae03d4a640d878dbeca Mon Sep 17 00:00:00 2001 From: Rob Adams Date: Sat, 28 Feb 2004 02:53:56 +0000 Subject: [PATCH] only move on MRU list if the window belongs on the workspace, since the 2004-02-27 Rob Adams * src/window.c (meta_window_notify_focus): only move on MRU list if the window belongs on the workspace, since the FocusIn event could be for a window whose workspace we've since switched away from. Possible fix for #122016. * src/workspace.c (meta_workspace_contains_window): search for the workspace in window->workspaces rather than the window in workspace->windows. Since the number of workspaces is at most 36, this is a O(1) lookup rather than a O(n) lookup. Sorry; couldn't resist. --- ChangeLog | 13 +++++++++++++ src/window.c | 30 ++++++++++++++++++------------ src/workspace.c | 2 +- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 59013337a..667ec74d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-02-27 Rob Adams + + * src/window.c (meta_window_notify_focus): only move on MRU list + if the window belongs on the workspace, since the FocusIn event + could be for a window whose workspace we've since switched away + from. Possible fix for #122016. + + * src/workspace.c (meta_workspace_contains_window): search for the + workspace in window->workspaces rather than the window in + workspace->windows. Since the number of workspaces is at most 36, + this is a O(1) lookup rather than a O(n) lookup. Sorry; couldn't + resist. + 2004-02-27 Rob Adams * src/metacity.schemas.in: Change diff --git a/src/window.c b/src/window.c index a2d0d5438..4bacd6b37 100644 --- a/src/window.c +++ b/src/window.c @@ -4126,21 +4126,27 @@ meta_window_notify_focus (MetaWindow *window, window->display->focus_window = window; window->has_focus = TRUE; - /* Move to the front of the focusing workspace's MRU list We - * should only be "removing" it from the MRU list if it's - * not already there. + /* Move to the front of the focusing workspace's MRU list. + * We should only be "removing" it from the MRU list if it's + * not already there. Note that it's possible that we might + * be processing this FocusIn after we've changed to a + * different workspace; we should therefore update the MRU + * list only if the window is actually on the active + * workspace. */ - if (window->screen->active_workspace) + if (window->screen->active_workspace && + meta_window_visible_on_workspace (window, + window->screen->active_workspace)) { - GList* link; - link = g_list_find (window->screen->active_workspace->mru_list, - window); - g_assert (link); + GList* link; + link = g_list_find (window->screen->active_workspace->mru_list, + window); + g_assert (link); - window->screen->active_workspace->mru_list = - g_list_remove_link (window->screen->active_workspace->mru_list, - link); - g_list_free (link); + window->screen->active_workspace->mru_list = + g_list_remove_link (window->screen->active_workspace->mru_list, + link); + g_list_free (link); window->screen->active_workspace->mru_list = g_list_prepend (window->screen->active_workspace->mru_list, diff --git a/src/workspace.c b/src/workspace.c index 9d69af69f..83c642c9f 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -240,7 +240,7 @@ gboolean meta_workspace_contains_window (MetaWorkspace *workspace, MetaWindow *window) { - return g_list_find (workspace->windows, window) != NULL; + return g_list_find (window->workspaces, workspace) != NULL; } void