From c89bae859481347cd501ad02245cae055c8563e4 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 13 Jul 2022 18:21:56 +0200 Subject: [PATCH] tests/stacking: Alt+Tab focus+stacking test for globally active input Gnome-shell uses meta_display_focus_default_window() when shell elements loose focus which is the case with Alt+Tab window switching. Globally active input clients don't immediately gain focus though so if meta_display_focus_default_window focuses a wrong window stacking and focus don't behave as expected. Part-of: --- src/tests/meson.build | 1 + ...ault-window-globally-active-input.metatest | 20 +++++++++++++++++++ src/tests/test-runner.c | 10 ++++++++++ 3 files changed, 31 insertions(+) create mode 100644 src/tests/stacking/focus-default-window-globally-active-input.metatest diff --git a/src/tests/meson.build b/src/tests/meson.build index bc0d535c5..0ffd9a20e 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -443,6 +443,7 @@ stacking_tests = [ 'workspace-basic', 'workspace-test', 'always-on-top', + 'focus-default-window-globally-active-input', ] foreach stacking_test: stacking_tests diff --git a/src/tests/stacking/focus-default-window-globally-active-input.metatest b/src/tests/stacking/focus-default-window-globally-active-input.metatest new file mode 100644 index 000000000..5ebf2855d --- /dev/null +++ b/src/tests/stacking/focus-default-window-globally-active-input.metatest @@ -0,0 +1,20 @@ +new_client 0 x11 +create 0/1 +accept_focus 0/1 false +can_take_focus 0/1 true +accept_take_focus 0/1 true +show 0/1 + +new_client 1 wayland +create 1/1 +show 1/1 + +assert_stacking 0/1 1/1 +assert_focused 1/1 + +local_activate 0/1 +focus_default_window + +wait +assert_stacking 1/1 0/1 +assert_focused 0/1 diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index 845a5441a..c9a87516c 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -1171,6 +1171,16 @@ test_case_do (TestCase *test, else meta_window_unmake_above (window); } + else if (strcmp (argv[0], "focus_default_window") == 0) + { + if (argc != 1) + BAD_COMMAND("usage: %s", argv[0]); + + MetaDisplay *display = meta_get_display (); + uint32_t timestamp = meta_display_get_current_time_roundtrip (display); + + meta_display_focus_default_window (display, timestamp); + } else { BAD_COMMAND("Unknown command %s", argv[0]);