mirror of
https://github.com/brl/mutter.git
synced 2025-02-06 08:34:10 +00:00
tests/stacking: Add support for moving the cursor and clicking
Also test that clicking on a window will focus and raise it. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2748>
This commit is contained in:
parent
619fc55408
commit
f6d96a6118
@ -488,6 +488,7 @@ stacking_tests = [
|
|||||||
'always-on-top',
|
'always-on-top',
|
||||||
'focus-default-window-globally-active-input',
|
'focus-default-window-globally-active-input',
|
||||||
'workspace-unmanaging-window',
|
'workspace-unmanaging-window',
|
||||||
|
'click-to-focus-and-raise',
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach stacking_test: stacking_tests
|
foreach stacking_test: stacking_tests
|
||||||
|
33
src/tests/stacking/click-to-focus-and-raise.metatest
Normal file
33
src/tests/stacking/click-to-focus-and-raise.metatest
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
resize_monitor primary 800 600
|
||||||
|
|
||||||
|
new_client w wayland
|
||||||
|
|
||||||
|
create w/1 csd
|
||||||
|
resize w/1 100 100
|
||||||
|
show w/1
|
||||||
|
|
||||||
|
create w/2 csd
|
||||||
|
resize w/2 100 100
|
||||||
|
show w/2
|
||||||
|
|
||||||
|
wait_reconfigure
|
||||||
|
|
||||||
|
move w/1 0 0
|
||||||
|
move w/2 100 0
|
||||||
|
|
||||||
|
wait_reconfigure
|
||||||
|
|
||||||
|
assert_stacking w/1 w/2
|
||||||
|
assert_focused w/2
|
||||||
|
|
||||||
|
assert_position w/1 0 0
|
||||||
|
assert_size w/1 100 100
|
||||||
|
assert_position w/2 100 0
|
||||||
|
assert_size w/2 100 100
|
||||||
|
|
||||||
|
move_cursor_to 50 50
|
||||||
|
click
|
||||||
|
wait
|
||||||
|
|
||||||
|
assert_stacking w/2 w/1
|
||||||
|
assert_focused w/1
|
@ -43,6 +43,7 @@ typedef struct {
|
|||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
gulong x11_display_opened_handler_id;
|
gulong x11_display_opened_handler_id;
|
||||||
MetaVirtualMonitor *virtual_monitor;
|
MetaVirtualMonitor *virtual_monitor;
|
||||||
|
ClutterVirtualInputDevice *pointer;
|
||||||
} TestCase;
|
} TestCase;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -76,6 +77,8 @@ test_case_new (MetaContext *context)
|
|||||||
{
|
{
|
||||||
TestCase *test = g_new0 (TestCase, 1);
|
TestCase *test = g_new0 (TestCase, 1);
|
||||||
MetaDisplay *display = meta_context_get_display (context);
|
MetaDisplay *display = meta_context_get_display (context);
|
||||||
|
MetaBackend *backend = meta_context_get_backend (context);
|
||||||
|
ClutterSeat *seat = meta_backend_get_default_seat (backend);
|
||||||
|
|
||||||
if (display->x11_display)
|
if (display->x11_display)
|
||||||
{
|
{
|
||||||
@ -93,6 +96,8 @@ test_case_new (MetaContext *context)
|
|||||||
test->clients = g_hash_table_new (g_str_hash, g_str_equal);
|
test->clients = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
test->loop = g_main_loop_new (NULL, FALSE);
|
test->loop = g_main_loop_new (NULL, FALSE);
|
||||||
test->virtual_monitor = meta_create_test_monitor (context, 800, 600, 60.0);
|
test->virtual_monitor = meta_create_test_monitor (context, 800, 600, 60.0);
|
||||||
|
test->pointer = clutter_seat_create_virtual_device (seat,
|
||||||
|
CLUTTER_POINTER_DEVICE);
|
||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
@ -1170,6 +1175,34 @@ test_case_do (TestCase *test,
|
|||||||
|
|
||||||
meta_display_focus_default_window (display, timestamp);
|
meta_display_focus_default_window (display, timestamp);
|
||||||
}
|
}
|
||||||
|
else if (strcmp (argv[0], "move_cursor_to") == 0)
|
||||||
|
{
|
||||||
|
if (argc != 3)
|
||||||
|
BAD_COMMAND("usage: %s <x> <y>", argv[0]);
|
||||||
|
|
||||||
|
float x = atof (argv[1]);
|
||||||
|
float y = atof (argv[2]);
|
||||||
|
|
||||||
|
clutter_virtual_input_device_notify_absolute_motion (test->pointer,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
x, y);
|
||||||
|
meta_flush_input (test->context);
|
||||||
|
}
|
||||||
|
else if (strcmp (argv[0], "click") == 0)
|
||||||
|
{
|
||||||
|
if (argc != 1)
|
||||||
|
BAD_COMMAND("usage: %s", argv[0]);
|
||||||
|
|
||||||
|
clutter_virtual_input_device_notify_button (test->pointer,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
CLUTTER_BUTTON_PRIMARY,
|
||||||
|
CLUTTER_BUTTON_STATE_PRESSED);
|
||||||
|
clutter_virtual_input_device_notify_button (test->pointer,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
CLUTTER_BUTTON_PRIMARY,
|
||||||
|
CLUTTER_BUTTON_STATE_RELEASED);
|
||||||
|
meta_flush_input (test->context);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BAD_COMMAND("Unknown command %s", argv[0]);
|
BAD_COMMAND("Unknown command %s", argv[0]);
|
||||||
@ -1220,6 +1253,7 @@ test_case_destroy (TestCase *test,
|
|||||||
|
|
||||||
g_hash_table_destroy (test->clients);
|
g_hash_table_destroy (test->clients);
|
||||||
g_object_unref (test->virtual_monitor);
|
g_object_unref (test->virtual_monitor);
|
||||||
|
g_object_unref (test->pointer);
|
||||||
g_free (test);
|
g_free (test);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user