diff --git a/src/display.c b/src/display.c index 1bcd98f09..da82c761e 100644 --- a/src/display.c +++ b/src/display.c @@ -461,6 +461,7 @@ meta_display_open (const char *name) * created in screen_new */ display->leader_window = None; + display->no_focus_window = None; display->xinerama_cache_invalidated = TRUE; @@ -711,10 +712,7 @@ meta_display_open (const char *name) * as it is the most recent timestamp. */ if (focus == None || focus == PointerRoot) - /* Just focus the no_focus_window on the first screen */ - meta_display_focus_the_no_focus_window (display, - display->screens->data, - timestamp); + meta_display_focus_the_no_focus_window (display, timestamp); else { MetaWindow * window; @@ -722,10 +720,7 @@ meta_display_open (const char *name) if (window) meta_display_set_input_focus_window (display, window, FALSE, timestamp); else - /* Just focus the no_focus_window on the first screen */ - meta_display_focus_the_no_focus_window (display, - display->screens->data, - timestamp); + meta_display_focus_the_no_focus_window (display, timestamp); } meta_error_trap_pop (display, FALSE); @@ -1875,7 +1870,6 @@ 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 && @@ -1907,8 +1901,7 @@ event_callback (XEvent *event, { meta_window_notify_focus (window, event); } - else if (meta_display_xwindow_is_a_no_focus_window (display, - event->xany.window)) + else if (event->xany.window == display->no_focus_window) { meta_topic (META_DEBUG_FOCUS, "Focus %s event received on no_focus_window 0x%lx " @@ -2998,24 +2991,6 @@ meta_display_unregister_x_window (MetaDisplay *display, 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) @@ -4846,14 +4821,13 @@ meta_display_set_input_focus_window (MetaDisplay *display, void meta_display_focus_the_no_focus_window (MetaDisplay *display, - MetaScreen *screen, Time timestamp) { if (timestamp_too_old (display, NULL, ×tamp)) return; XSetInputFocus (display->xdisplay, - screen->no_focus_window, + display->no_focus_window, RevertToPointerRoot, timestamp); display->expected_focus_window = NULL; diff --git a/src/display.h b/src/display.h index 1e6b02820..c651c5e97 100644 --- a/src/display.h +++ b/src/display.h @@ -216,6 +216,11 @@ 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; @@ -408,9 +413,6 @@ void meta_display_register_x_window (MetaDisplay *display, 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); @@ -537,7 +539,6 @@ void meta_display_set_input_focus_window (MetaDisplay *display, * 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, diff --git a/src/keybindings.c b/src/keybindings.c index a70a5359e..e1872a0e3 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -1451,15 +1451,11 @@ primary_modifier_still_pressed (MetaDisplay *display, 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, - random_xwindow, /* some random window */ + display->no_focus_window, /* some random window */ &root, &child, &root_x, &root_y, &x, &y, diff --git a/src/screen.c b/src/screen.c index 300c81f14..62a0f87a1 100644 --- a/src/screen.c +++ b/src/screen.c @@ -577,14 +577,16 @@ 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); - /* 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 */ + XSelectInput (display->xdisplay, display->no_focus_window, + FocusChangeMask | KeyPressMask | KeyReleaseMask); + XMapWindow (display->xdisplay, display->no_focus_window); + } set_wm_icon_size_hint (screen); diff --git a/src/screen.h b/src/screen.h index 29411ea9b..50cfa075b 100644 --- a/src/screen.h +++ b/src/screen.h @@ -72,11 +72,6 @@ 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; diff --git a/src/window.c b/src/window.c index f74005a6b..19bb2790c 100644 --- a/src/window.c +++ b/src/window.c @@ -241,7 +241,7 @@ meta_window_new_with_attrs (MetaDisplay *display, meta_verbose ("Attempting to manage 0x%lx\n", xwindow); - if (meta_display_xwindow_is_a_no_focus_window (display, xwindow)) + if (xwindow == display->no_focus_window) { 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, window->screen, meta_display_get_current_time_roundtrip (window->display)); + meta_display_focus_the_no_focus_window (window->display, meta_display_get_current_time_roundtrip (window->display)); } else { diff --git a/src/workspace.c b/src/workspace.c index 3988cb963..d19e6a8fb 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -925,7 +925,6 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace, "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); } } @@ -1015,7 +1014,6 @@ focus_ancestor_or_mru_window (MetaWorkspace *workspace, { 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); } }