1
0
Fork 0

tests/wayland: Add test for mapping clone of obstructed window

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3731>
(cherry picked from commit 52d5758f1b)
This commit is contained in:
Jonas Ådahl 2024-05-03 14:30:14 +02:00
parent 2c6993cfb6
commit ed637f63c1
2 changed files with 58 additions and 0 deletions

View file

@ -27,6 +27,7 @@ enum
XDG_TOPLEVEL_SUSPENDED_COMMAND_NEXT_WORKSPACE = 0,
XDG_TOPLEVEL_SUSPENDED_COMMAND_PREV_WORKSPACE = 1,
XDG_TOPLEVEL_SUSPENDED_COMMAND_ACTIVATE_WINDOW = 2,
XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE = 3,
};
static void
@ -155,6 +156,40 @@ test_obstructed (WaylandDisplay *display)
wait_for_no_state (surface, XDG_TOPLEVEL_STATE_SUSPENDED);
}
static void
test_obstructed_clone (WaylandDisplay *display)
{
g_autoptr (WaylandSurface) surface = NULL;
g_autoptr (WaylandSurface) cover_surface = NULL;
g_debug ("Testing suspended state when mapping a clone of an obstructed "
"window");
surface = wayland_surface_new (display, __func__, 100, 100, 0xffffffff);
wl_surface_commit (surface->wl_surface);
wait_for_window_shown (display, surface->wl_surface);
g_assert_false (wayland_surface_has_state (surface,
XDG_TOPLEVEL_STATE_SUSPENDED));
cover_surface = wayland_surface_new (display, "obstruction",
100, 100, 0xffffffff);
xdg_toplevel_set_maximized (cover_surface->xdg_toplevel);
wl_surface_commit (cover_surface->wl_surface);
wait_for_window_shown (display, cover_surface->wl_surface);
test_driver_sync_point (display->test_driver,
XDG_TOPLEVEL_SUSPENDED_COMMAND_ACTIVATE_WINDOW,
cover_surface->wl_surface);
wait_for_state (surface, XDG_TOPLEVEL_STATE_SUSPENDED);
test_driver_sync_point (display->test_driver,
XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE,
surface->wl_surface);
wait_for_no_state (surface, XDG_TOPLEVEL_STATE_SUSPENDED);
}
int
main (int argc,
char **argv)
@ -170,6 +205,7 @@ main (int argc,
test_minimized (display);
test_workspace_changes (display);
test_obstructed (display);
test_obstructed_clone (display);
return EXIT_SUCCESS;
}

View file

@ -873,6 +873,7 @@ enum
XDG_TOPLEVEL_SUSPENDED_COMMAND_NEXT_WORKSPACE = 0,
XDG_TOPLEVEL_SUSPENDED_COMMAND_PREV_WORKSPACE = 1,
XDG_TOPLEVEL_SUSPENDED_COMMAND_ACTIVATE_WINDOW = 2,
XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE = 3,
};
static void
@ -914,6 +915,27 @@ on_toplevel_suspended_sync_point (MetaWaylandTestDriver *test_driver,
now_ms = meta_display_get_current_time_roundtrip (display);
meta_window_activate (meta_wayland_surface_get_window (surface), now_ms);
break;
case XDG_TOPLEVEL_SUSPENDED_COMMAND_CLONE:
{
MetaBackend *backend = meta_context_get_backend (test_context);
ClutterActor *stage = meta_backend_get_stage (backend);
MetaWindow *window;
MetaWindowActor *window_actor;
ClutterActor *clone;
surface = wl_resource_get_user_data (surface_resource);
window = meta_wayland_surface_get_window (surface);
window_actor = meta_window_actor_from_window (window);
clone = clutter_clone_new (CLUTTER_ACTOR (window_actor));
clutter_actor_show (clone);
clutter_actor_add_child (stage, clone);
g_object_set_data_full (G_OBJECT (window), "suspend-test-clone",
clone, (GDestroyNotify) clutter_actor_destroy);
break;
}
}
}