Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.324
diff -p -u -r1.324 window.c
--- src/window.c	23 Feb 2004 01:48:29 -0000	1.324
+++ src/window.c	28 Feb 2004 02:48:14 -0000
@@ -4126,21 +4126,27 @@ meta_window_notify_focus (MetaWindow *wi
           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);
-
-	      window->screen->active_workspace->mru_list = 
-		g_list_remove_link (window->screen->active_workspace->mru_list,
-				    link);
-	      g_list_free (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_prepend (window->screen->active_workspace->mru_list, 
Index: src/workspace.c
===================================================================
RCS file: /cvs/gnome/metacity/src/workspace.c,v
retrieving revision 1.55
diff -p -u -r1.55 workspace.c
--- src/workspace.c	23 Feb 2004 01:48:29 -0000	1.55
+++ src/workspace.c	28 Feb 2004 02:48:17 -0000
@@ -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
