diff --git a/src/tests/meson.build b/src/tests/meson.build index ce128efca..7f933d357 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -708,6 +708,7 @@ stacking_tests = [ 'overview-focus', 'suspend-state-timeout', 'cloned-windows', + 'sloppy-focus', ] foreach stacking_test: stacking_tests diff --git a/src/tests/stacking/sloppy-focus.metatest b/src/tests/stacking/sloppy-focus.metatest new file mode 100644 index 000000000..a1996aded --- /dev/null +++ b/src/tests/stacking/sloppy-focus.metatest @@ -0,0 +1,62 @@ +resize_monitor default 800 600 +set_pref focus-mode sloppy +set_pref focus-change-on-pointer-rest false + +move_cursor_to 150 50 +wait + +new_client w wayland + +create w/0 csd +resize w/0 100 100 +show w/0 + +create w/1 csd +resize w/1 100 100 +show w/1 + +wait_reconfigure + +move w/0 0 0 +move w/1 100 0 + +wait_reconfigure + +assert_stacking w/0 w/1 +assert_focused w/1 + +assert_position w/0 0 0 +assert_size w/0 100 100 +assert_position w/1 100 0 +assert_size w/1 100 100 + +move_cursor_to 50 50 + +assert_stacking w/0 w/1 +assert_focused w/0 + +move_cursor_to 150 50 + +assert_stacking w/0 w/1 +assert_focused w/1 + +focus_default_window + +assert_stacking w/0 w/1 +assert_focused w/1 + +local_activate w/0 +focus_default_window + +assert_stacking w/1 w/0 +assert_focused w/0 + +move_cursor_to 50 50 + +assert_stacking w/1 w/0 +assert_focused w/0 + +move_cursor_to 150 50 + +assert_stacking w/1 w/0 +assert_focused w/1 \ No newline at end of file diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index 19df1d8f3..a4f941452 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -1301,6 +1301,21 @@ test_case_do (TestCase *test, g_assert_true (g_settings_set_boolean (wm, "raise-on-click", value)); } + else if (strcmp (argv[1], "focus-mode") == 0) + { + GDesktopFocusMode mode; + + if (g_ascii_strcasecmp (argv[2], "click") == 0) + mode = G_DESKTOP_FOCUS_MODE_CLICK; + else if (g_ascii_strcasecmp (argv[2], "sloppy") == 0) + mode = G_DESKTOP_FOCUS_MODE_SLOPPY; + else if (g_ascii_strcasecmp (argv[2], "mouse") == 0) + mode = G_DESKTOP_FOCUS_MODE_MOUSE; + else + BAD_COMMAND("usage: %s %s [click|sloppy|mouse]", argv[0], argv[1]); + + g_assert_true (g_settings_set_enum (wm, "focus-mode", mode)); + } else if (strcmp (argv[1], "workspaces-only-on-primary") == 0) { gboolean value; @@ -1309,6 +1324,14 @@ test_case_do (TestCase *test, g_assert_true (g_settings_set_boolean (mutter, "workspaces-only-on-primary", value)); } + else if (strcmp (argv[1], "focus-change-on-pointer-rest") == 0) + { + gboolean value; + if (!str_to_bool (argv[2], &value)) + BAD_COMMAND("usage: %s %s [true|false]", argv[0], argv[1]); + + g_assert_true (g_settings_set_boolean (mutter, "focus-change-on-pointer-rest", value)); + } else { BAD_COMMAND("Unknown preference %s", argv[1]); }