window-x11: Focus the default window waiting for take focus

It's not guaranteed that a focus window will require the focus (this doesn't
happen for no-input gtk windows in fact [to be fixed there too]).
And in such case instead of unsetting the focus, while waiting the take focus
request to arrive, we should focus the current workspace default focus window
instead.
This commit is contained in:
Marco Trevisan (Treviño) 2018-11-13 17:08:34 -06:00
parent 4c607164fd
commit 8652ec9ee2
2 changed files with 28 additions and 7 deletions

View File

@ -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

View File

@ -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);