Index: src/display.c
===================================================================
RCS file: /cvs/gnome/metacity/src/display.c,v
retrieving revision 1.262
diff -p -u -r1.262 display.c
--- src/display.c	22 Nov 2005 15:48:30 -0000	1.262
+++ src/display.c	21 Dec 2005 20:58:25 -0000
@@ -461,7 +461,6 @@ meta_display_open (const char *name)
    * created in screen_new
    */
   display->leader_window = None;
-  display->no_focus_window = None;
 
   display->xinerama_cache_invalidated = TRUE;
 
@@ -712,7 +711,10 @@ meta_display_open (const char *name)
      * as it is the most recent timestamp.
      */
     if (focus == None || focus == PointerRoot)
-      meta_display_focus_the_no_focus_window (display, timestamp);
+      /* Just focus the no_focus_window on the first screen */
+      meta_display_focus_the_no_focus_window (display,
+                                              display->screens->data,
+                                              timestamp);
     else
       {
         MetaWindow * window;
@@ -720,7 +722,10 @@ meta_display_open (const char *name)
         if (window)
           meta_display_set_input_focus_window (display, window, FALSE, timestamp);
         else
-          meta_display_focus_the_no_focus_window (display, timestamp);
+          /* Just focus the no_focus_window on the first screen */
+          meta_display_focus_the_no_focus_window (display,
+                                                  display->screens->data,
+                                                  timestamp);
       }
 
     meta_error_trap_pop (display, FALSE);
@@ -1870,6 +1875,7 @@ event_callback (XEvent   *event,
                                   "Unsetting focus from %s due to LeaveNotify\n",
                                   window->desc);
                       meta_display_focus_the_no_focus_window (display, 
+                                                              window->screen,
                                                               event->xcrossing.time);
                     }
                   if (window->type != META_WINDOW_DOCK &&
@@ -1901,7 +1907,8 @@ event_callback (XEvent   *event,
         {
           meta_window_notify_focus (window, event);
         }
-      else if (event->xany.window == display->no_focus_window)
+      else if (meta_display_xwindow_is_a_no_focus_window (display,
+                                                          event->xany.window))
         {
           meta_topic (META_DEBUG_FOCUS,
                       "Focus %s event received on no_focus_window 0x%lx "
@@ -2991,6 +2998,24 @@ meta_display_unregister_x_window (MetaDi
   remove_pending_pings_for_window (display, xwindow);
 }
 
+gboolean
+meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
+                                           Window xwindow)
+{
+  gboolean is_a_no_focus_window = FALSE;
+  GSList *temp = display->screens;
+  while (temp != NULL) {
+    MetaScreen *screen = temp->data;
+    if (screen->no_focus_window == xwindow) {
+      is_a_no_focus_window = TRUE;
+      break;
+    }
+    temp = temp->next;
+  }
+
+  return is_a_no_focus_window;
+}
+
 Cursor
 meta_display_create_x_cursor (MetaDisplay *display,
                               MetaCursor cursor)
@@ -4821,13 +4846,14 @@ meta_display_set_input_focus_window (Met
 
 void
 meta_display_focus_the_no_focus_window (MetaDisplay *display, 
+                                        MetaScreen  *screen,
                                         Time         timestamp)
 {
   if (timestamp_too_old (display, NULL, &timestamp))
     return;
 
   XSetInputFocus (display->xdisplay,
-                  display->no_focus_window,
+                  screen->no_focus_window,
                   RevertToPointerRoot,
                   timestamp);
   display->expected_focus_window = NULL;
Index: src/display.h
===================================================================
RCS file: /cvs/gnome/metacity/src/display.h,v
retrieving revision 1.136
diff -p -u -r1.136 display.h
--- src/display.h	19 Nov 2005 14:58:50 -0000	1.136
+++ src/display.h	21 Dec 2005 20:58:26 -0000
@@ -216,11 +216,6 @@ struct _MetaDisplay
                               XErrorEvent *error);  
   int server_grab_count;
 
-  /* This window holds the focus when we don't want to focus
-   * any actual clients
-   */
-  Window no_focus_window;
-  
   /* for double click */
   Time last_button_time;
   Window last_button_xwindow;
@@ -413,6 +408,9 @@ void        meta_display_register_x_wind
                                               MetaWindow  *window);
 void        meta_display_unregister_x_window (MetaDisplay *display,
                                               Window       xwindow);
+/* Return whether the xwindow is a no focus window for any of the screens */
+gboolean    meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
+                                                       Window xwindow);
 
 GSList*     meta_display_list_windows        (MetaDisplay *display);
 
@@ -539,6 +537,7 @@ void meta_display_set_input_focus_window
  * same as meta_display_set_input_focus_window
  */
 void meta_display_focus_the_no_focus_window (MetaDisplay *display, 
+                                             MetaScreen  *screen,
                                              Time         timestamp);
 
 void meta_display_queue_autoraise_callback  (MetaDisplay *display,
Index: src/keybindings.c
===================================================================
RCS file: /cvs/gnome/metacity/src/keybindings.c,v
retrieving revision 1.116
diff -p -u -r1.116 keybindings.c
--- src/keybindings.c	19 Nov 2005 14:58:50 -0000	1.116
+++ src/keybindings.c	21 Dec 2005 20:58:26 -0000
@@ -1451,11 +1451,15 @@ primary_modifier_still_pressed (MetaDisp
   int x, y, root_x, root_y;
   Window root, child;
   guint mask;
+  MetaScreen *random_screen;
+  Window      random_xwindow;
   
   primary_modifier = get_primary_modifier (display, entire_binding_mask);
   
+  random_screen = display->screens->data;
+  random_xwindow = random_screen->no_focus_window;
   XQueryPointer (display->xdisplay,
-                 display->no_focus_window, /* some random window */
+                 random_xwindow, /* some random window */
                  &root, &child,
                  &root_x, &root_y,
                  &x, &y,
Index: src/screen.c
===================================================================
RCS file: /cvs/gnome/metacity/src/screen.c,v
retrieving revision 1.144
diff -p -u -r1.144 screen.c
--- src/screen.c	19 Nov 2005 14:58:50 -0000	1.144
+++ src/screen.c	21 Dec 2005 20:58:27 -0000
@@ -577,16 +577,14 @@ meta_screen_new (MetaDisplay *display,
   reload_xinerama_infos (screen);
   
   meta_screen_set_cursor (screen, META_CURSOR_DEFAULT);
-  
-  if (display->no_focus_window == None)
-    {
-      display->no_focus_window = meta_create_offscreen_window (display->xdisplay,
-                                                               screen->xroot);
 
-      XSelectInput (display->xdisplay, display->no_focus_window,
-                    FocusChangeMask | KeyPressMask | KeyReleaseMask);
-      XMapWindow (display->xdisplay, display->no_focus_window);
-    }
+  /* Handle creating a no_focus_window for this screen */  
+  screen->no_focus_window = meta_create_offscreen_window (display->xdisplay,
+                                                          screen->xroot);
+  XSelectInput (display->xdisplay, screen->no_focus_window,
+                FocusChangeMask | KeyPressMask | KeyReleaseMask);
+  XMapWindow (display->xdisplay, screen->no_focus_window);
+  /* Done with no_focus_window stuff */
   
   set_wm_icon_size_hint (screen);
   
Index: src/screen.h
===================================================================
RCS file: /cvs/gnome/metacity/src/screen.h,v
retrieving revision 1.63
diff -p -u -r1.63 screen.h
--- src/screen.h	29 Nov 2005 21:36:12 -0000	1.63
+++ src/screen.h	21 Dec 2005 20:58:27 -0000
@@ -72,6 +72,11 @@ struct _MetaScreen
   
   MetaWorkspace *active_workspace;
 
+  /* This window holds the focus when we don't want to focus
+   * any actual clients
+   */
+  Window no_focus_window;
+  
   GList *workspaces;
 
   MetaStack *stack;
Index: src/window.c
===================================================================
RCS file: /cvs/gnome/metacity/src/window.c,v
retrieving revision 1.398
diff -p -u -r1.398 window.c
--- src/window.c	22 Nov 2005 15:48:30 -0000	1.398
+++ src/window.c	21 Dec 2005 20:58:29 -0000
@@ -241,7 +241,7 @@ meta_window_new_with_attrs (MetaDisplay 
   
   meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
 
-  if (xwindow == display->no_focus_window)
+  if (meta_display_xwindow_is_a_no_focus_window (display, xwindow))
     {
       meta_verbose ("Not managing no_focus_window 0x%lx\n",
                     xwindow);
@@ -1763,7 +1763,7 @@ meta_window_show (MetaWindow *window)
                       "ancestor.\n",
                       window->display->focus_window->desc, window->desc);
 
-          meta_display_focus_the_no_focus_window (window->display, meta_display_get_current_time_roundtrip (window->display));
+          meta_display_focus_the_no_focus_window (window->display, window->screen, meta_display_get_current_time_roundtrip (window->display));
         }
       else
         {
Index: src/workspace.c
===================================================================
RCS file: /cvs/gnome/metacity/src/workspace.c,v
retrieving revision 1.74
diff -p -u -r1.74 workspace.c
--- src/workspace.c	19 Nov 2005 14:58:50 -0000	1.74
+++ src/workspace.c	21 Dec 2005 20:58:29 -0000
@@ -925,6 +925,7 @@ meta_workspace_focus_default_window (Met
                       "Setting focus to no_focus_window, since no valid "
                       "window to focus found.\n");
           meta_display_focus_the_no_focus_window (workspace->screen->display,
+                                                  workspace->screen,
                                                   timestamp);
         }
     }
@@ -1014,6 +1015,7 @@ focus_ancestor_or_mru_window (MetaWorksp
     {
       meta_topic (META_DEBUG_FOCUS, "No MRU window to focus found; focusing no_focus_window.\n");
       meta_display_focus_the_no_focus_window (workspace->screen->display,
+                                              workspace->screen,
                                               timestamp);
     }
 }
