diff -urN metacity-cvs-clean/src/screen.c metacity-cvs-work/src/screen.c
--- metacity-cvs-clean/src/screen.c	Sun Jun  9 15:07:12 2002
+++ metacity-cvs-work/src/screen.c	Sun Jun  9 20:01:30 2002
@@ -921,7 +921,7 @@
 }
 
 /* Focus top window on active workspace */
-void
+MetaWindow*
 meta_screen_focus_top_window (MetaScreen *screen,
                               MetaWindow *not_this_one)
 {
@@ -947,6 +947,7 @@
     {
       meta_topic (META_DEBUG_FOCUS, "No top window to focus found\n");
     }
+  return window;
 }
 
 const MetaXineramaScreenInfo*
diff -urN metacity-cvs-clean/src/screen.h metacity-cvs-work/src/screen.h
--- metacity-cvs-clean/src/screen.h	Sun Jun  9 15:07:12 2002
+++ metacity-cvs-work/src/screen.h	Sun Jun  9 20:01:33 2002
@@ -98,7 +98,7 @@
 void          meta_screen_ensure_tab_popup    (MetaScreen                 *screen,
                                                MetaTabList                 type);
 
-void          meta_screen_focus_top_window    (MetaScreen                 *screen,
+MetaWindow*   meta_screen_focus_top_window    (MetaScreen                 *screen,
                                                MetaWindow                 *not_this_one);
 
 const MetaXineramaScreenInfo* meta_screen_get_current_xinerama (MetaScreen *screen);
diff -urN metacity-cvs-clean/src/window.c metacity-cvs-work/src/window.c
--- metacity-cvs-clean/src/window.c	Sun Jun  9 15:07:12 2002
+++ metacity-cvs-work/src/window.c	Sun Jun  9 20:01:26 2002
@@ -97,6 +97,7 @@
                                            XPropertyEvent *event);
 static void     meta_window_show          (MetaWindow     *window);
 static void     meta_window_hide          (MetaWindow     *window);
+static void     set_focus_window          (MetaWindow     *window);
 
 static GList*   meta_window_get_workspaces (MetaWindow    *window);
 
@@ -738,10 +739,15 @@
    */
   if (window->has_focus)
     {
+      MetaWindow *top;
+
       meta_topic (META_DEBUG_FOCUS,
                   "Focusing top window since we're unmanaging %s\n",
                   window->desc);
-      meta_screen_focus_top_window (window->screen, window);
+
+      top = meta_screen_focus_top_window (window->screen, window);
+      if (top)
+        set_focus_window (top);
     }
   else
     {
@@ -3354,6 +3360,32 @@
   return FALSE;
 }
 
+static void
+set_focus_window (MetaWindow *window)
+{
+  g_assert (window);
+
+  if (window != window->display->focus_window)
+    {
+      meta_topic (META_DEBUG_FOCUS,
+                  "* Focus --> %s\n", window->desc);
+      window->display->focus_window = window;
+      window->has_focus = TRUE;
+      /* Move to the front of the MRU list */
+      window->display->mru_list =
+      g_list_remove (window->display->mru_list, window);
+      window->display->mru_list =
+        g_list_prepend (window->display->mru_list, window);
+      if (window->frame)
+        meta_frame_queue_draw (window->frame);
+          
+      meta_error_trap_push (window->display);
+      XInstallColormap (window->display->xdisplay,
+                        window->colormap);
+      meta_error_trap_pop (window->display);
+    }
+}
+
 gboolean
 meta_window_notify_focus (MetaWindow *window,
                           XEvent     *event)
@@ -3408,25 +3440,7 @@
     
   if (event->type == FocusIn)
     {
-      if (window != window->display->focus_window)
-        {
-          meta_topic (META_DEBUG_FOCUS,
-                      "* Focus --> %s\n", window->desc);
-          window->display->focus_window = window;
-          window->has_focus = TRUE;
-          /* Move to the front of the MRU list */
-          window->display->mru_list =
-            g_list_remove (window->display->mru_list, window);
-          window->display->mru_list =
-            g_list_prepend (window->display->mru_list, window);
-          if (window->frame)
-            meta_frame_queue_draw (window->frame);
-          
-          meta_error_trap_push (window->display);
-          XInstallColormap (window->display->xdisplay,
-                            window->colormap);
-          meta_error_trap_pop (window->display);
-        }
+      set_focus_window (window);  
     }
   else if (event->type == FocusOut ||
            event->type == UnmapNotify)
