From 9d1d8fa0626c6c80d32e7dc7c21c1770ecf4b212 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 24 Jun 2004 20:02:46 +0000 Subject: [PATCH] Make choice of focus window be consistent for each focus mode. Fixes 2004-06-24 Elijah Newren Make choice of focus window be consistent for each focus mode. Fixes #135810. * src/delete.c: (meta_window_delete): In some #if 0'ed code, replace meta_workspace_focus_mru_window with meta_workspace_focus_default_window (just in case the code becomes un-#if 0'ed out). * src/screen.c, src/screen.h: Change meta_screen_focus_mouse_window to meta_screen_get_mouse_window, and don't focus the window when found but rather return it. * src/window.c: (meta_window_free, meta_window_minimize): replace meta_workspace_focus_mru_window with meta_workspace_focus_default_window. * src/workspace.c: (meta_workspace_focus_default_window): Focus appropriately for the given focus method: click-to-focus: focus MRU window (== toplevel window) sloppy focus: focus the window under the pointer if there is such a window, otherwise focus the mru window mouse focus: focus the window under the pointer if there is such a window, otherwise don't focus anything --- ChangeLog | 26 ++++++++++++++++++++++++++ src/delete.c | 6 +++--- src/screen.c | 23 ++++------------------- src/screen.h | 2 +- src/window.c | 14 +++++++------- src/workspace.c | 16 +++++++++++++++- 6 files changed, 56 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 104205d9a..2481d36b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2004-06-24 Elijah Newren + + Make choice of focus window be consistent for each focus mode. + Fixes #135810. + + * src/delete.c: (meta_window_delete): In some #if 0'ed code, + replace meta_workspace_focus_mru_window with + meta_workspace_focus_default_window (just in case the code becomes + un-#if 0'ed out). + + * src/screen.c, src/screen.h: Change + meta_screen_focus_mouse_window to meta_screen_get_mouse_window, + and don't focus the window when found but rather return it. + + * src/window.c: (meta_window_free, meta_window_minimize): replace + meta_workspace_focus_mru_window with + meta_workspace_focus_default_window. + + * src/workspace.c: (meta_workspace_focus_default_window): Focus + appropriately for the given focus method: + click-to-focus: focus MRU window (== toplevel window) + sloppy focus: focus the window under the pointer if there is + such a window, otherwise focus the mru window + mouse focus: focus the window under the pointer if there is + such a window, otherwise don't focus anything + 2004-06-24 Elijah Newren * src/window.c: Avoid a race condition on the choice of window to diff --git a/src/delete.c b/src/delete.c index ced572679..881352bd5 100644 --- a/src/delete.c +++ b/src/delete.c @@ -396,10 +396,10 @@ meta_window_delete (MetaWindow *window, * I don't know how to avoid that though. */ meta_topic (META_DEBUG_FOCUS, - "Focusing MRU window because focus window %s was deleted/killed\n", + "Focusing default window because focus window %s was deleted/killed\n", window->desc); - meta_workspace_focus_mru_window (window->screen->active_workspace, - window); + meta_workspace_focus_default_window (window->screen->active_workspace, + window); #else meta_topic (META_DEBUG_FOCUS, "Not unfocusing %s on delete/kill\n", diff --git a/src/screen.c b/src/screen.c index bfc86895f..c08e957f6 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1224,9 +1224,9 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen) /* don't show tab popup, since proper space isn't selected yet */ } -void -meta_screen_focus_mouse_window (MetaScreen *screen, - MetaWindow *not_this_one) +MetaWindow* +meta_screen_get_mouse_window (MetaScreen *screen, + MetaWindow *not_this_one) { MetaWindow *window; Window root_return, child_return; @@ -1256,22 +1256,7 @@ meta_screen_focus_mouse_window (MetaScreen *screen, root_x_return, root_y_return); - /* FIXME I'm a loser on the CurrentTime front */ - if (window) - { - meta_topic (META_DEBUG_FOCUS, - "Focusing mouse window %s\n", window->desc); - - meta_window_focus (window, meta_display_get_current_time (screen->display)); - - /* Also raise the window if in click-to-focus */ - if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK) - meta_window_raise (window); - } - else - { - meta_topic (META_DEBUG_FOCUS, "No mouse window to focus found\n"); - } + return window; } const MetaXineramaScreenInfo* diff --git a/src/screen.h b/src/screen.h index ad8e34d18..f8eb7716f 100644 --- a/src/screen.h +++ b/src/screen.h @@ -148,7 +148,7 @@ void meta_screen_ensure_tab_popup (MetaScreen *scree void meta_screen_ensure_workspace_popup (MetaScreen *screen); -void meta_screen_focus_mouse_window (MetaScreen *screen, +MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen, MetaWindow *not_this_one); const MetaXineramaScreenInfo* meta_screen_get_current_xinerama (MetaScreen *screen); diff --git a/src/window.c b/src/window.c index 462fcc187..3421c3222 100644 --- a/src/window.c +++ b/src/window.c @@ -925,17 +925,17 @@ meta_window_free (MetaWindow *window) if (window->has_focus) { meta_topic (META_DEBUG_FOCUS, - "Focusing top window since we're unmanaging %s\n", + "Focusing default window since we're unmanaging %s\n", window->desc); - meta_workspace_focus_mru_window (window->screen->active_workspace, window); + meta_workspace_focus_default_window (window->screen->active_workspace, window); } else if (window->display->expected_focus_window == window) { meta_topic (META_DEBUG_FOCUS, - "Focusing top window since expected focus window freed %s\n", + "Focusing default window since expected focus window freed %s\n", window->desc); window->display->expected_focus_window = NULL; - meta_workspace_focus_mru_window (window->screen->active_workspace, window); + meta_workspace_focus_default_window (window->screen->active_workspace, window); } else { @@ -1380,7 +1380,7 @@ idle_calc_showing (gpointer data) GSList *should_hide; GSList *unplaced; GSList *displays; - + meta_topic (META_DEBUG_WINDOW_STATE, "Clearing the calc_showing queue\n"); @@ -1902,9 +1902,9 @@ meta_window_minimize (MetaWindow *window) if (window->has_focus) { meta_topic (META_DEBUG_FOCUS, - "Focusing top window due to minimization of focus window %s\n", + "Focusing default window due to minimization of focus window %s\n", window->desc); - meta_workspace_focus_mru_window (window->screen->active_workspace, window); + meta_workspace_focus_default_window (window->screen->active_workspace, window); } else { diff --git a/src/workspace.c b/src/workspace.c index 83c642c9f..095d162cd 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -784,7 +784,21 @@ meta_workspace_focus_default_window (MetaWorkspace *workspace, if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_CLICK) meta_workspace_focus_mru_window (workspace, not_this_one); else - meta_screen_focus_mouse_window (workspace->screen, not_this_one); + { + MetaWindow * window; + window = meta_screen_get_mouse_window (workspace->screen, not_this_one); + if (window) + { + meta_topic (META_DEBUG_FOCUS, + "Focusing mouse window %s\n", window->desc); + + meta_window_focus (window, meta_display_get_current_time (workspace->screen->display)); + } + else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_SLOPPY) + meta_workspace_focus_mru_window (workspace, not_this_one); + else if (meta_prefs_get_focus_mode () == META_FOCUS_MODE_MOUSE) + meta_topic (META_DEBUG_FOCUS, "No mouse window to focus found\n"); + } } /* Focus MRU window (or top window if failed) on active workspace */