Work around race condition focusing a window on a different workspace

When we focus a window on a different desktop, and the calc_showing
idle that hides/shows the windows gets run before we get focus events
back from X, we think that we are hiding the window with the focus
so we focus a "random" window to avoid leaving the user with no focus.

Work around this temporarily by checking display->expected_focus_window;
this isn't a perfect fix because there are cases where
display->expected_focus_window corresponds to a window we tried to
focus in the past but failed, but it makes things work fairly well.

https://bugzilla.gnome.org/show_bug.cgi?id=597352
This commit is contained in:
Owen W. Taylor 2009-10-07 13:43:33 -04:00
parent 8589e4f3d3
commit e8a29c1e82

View File

@ -2731,7 +2731,14 @@ meta_window_hide (MetaWindow *window)
invalidate_work_areas (window); invalidate_work_areas (window);
} }
if (window->has_focus) /* The check on expected_focus_window is a temporary workaround for
* https://bugzilla.gnome.org/show_bug.cgi?id=597352
* We may have already switched away from this window but not yet
* gotten FocusIn/FocusOut events. A more complete comprehensive
* fix for these type of issues is described in the bug.
*/
if (window->has_focus &&
window == window->display->expected_focus_window)
{ {
MetaWindow *not_this_one = NULL; MetaWindow *not_this_one = NULL;
MetaWorkspace *my_workspace = meta_window_get_workspace (window); MetaWorkspace *my_workspace = meta_window_get_workspace (window);