diff --git a/src/tests/stacking/closed-transient-no-input-parent.metatest b/src/tests/stacking/closed-transient-no-input-parent.metatest index af24a1072..bb652c1cb 100644 --- a/src/tests/stacking/closed-transient-no-input-parent.metatest +++ b/src/tests/stacking/closed-transient-no-input-parent.metatest @@ -1,3 +1,8 @@ +new_client 2 x11 +create 2/1 +show 2/1 +wait + new_client 1 x11 create 1/1 show 1/1 @@ -14,9 +19,11 @@ set_parent 1/3 2 show 1/3 wait -assert_stacking 1/1 1/2 1/3 +assert_focused 1/3 +assert_stacking 2/1 1/1 1/2 1/3 destroy 1/3 - wait -assert_stacking 1/1 1/2 + +assert_focused 1/1 +assert_stacking 2/1 1/1 1/2 diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index bfcbc7ad5..b0b071f73 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -789,13 +789,27 @@ meta_window_x11_focus (MetaWindow *window, * Normally, we want to just leave the focus undisturbed until * the window responds to WM_TAKE_FOCUS, but if we're unmanaging * the current focus window we *need* to move the focus away, so - * we focus the no_focus_window now (and set - * display->focus_window to that) before sending WM_TAKE_FOCUS. + * we focus the default focus window excluding this one, + * before sending WM_TAKE_FOCUS. */ if (window->display->focus_window != NULL && window->display->focus_window->unmanaging) - meta_x11_display_focus_the_no_focus_window (window->display->x11_display, - timestamp); + { + MetaWindow *focus_window = window; + MetaWorkspace *workspace = window->workspace; + + do + { + focus_window = meta_stack_get_default_focus_window (workspace->display->stack, + workspace, + focus_window); + } + while (!(!focus_window || focus_window->input || + (focus_window->frame && focus_window->shaded))); + + if (focus_window) + meta_window_x11_focus (focus_window, timestamp); + } } request_take_focus (window, timestamp);