[mutter] tests/wayland/subsurface-parent-unmapped: Port to WaylandDisplay
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tests/wayland/subsurface-parent-unmapped: Port to WaylandDisplay
- Date: Tue, 17 May 2022 08:41:42 +0000 (UTC)
commit 1562bcc6fde9af4a0c43ea0b499fc9e720511ff3
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed May 11 23:42:49 2022 +0200
tests/wayland/subsurface-parent-unmapped: Port to WaylandDisplay
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
.../subsurface-parent-unmapped.c | 112 +++++----------------
1 file changed, 26 insertions(+), 86 deletions(-)
---
diff --git a/src/tests/wayland-test-clients/subsurface-parent-unmapped.c
b/src/tests/wayland-test-clients/subsurface-parent-unmapped.c
index 0618e65c02..ccb61e4adf 100644
--- a/src/tests/wayland-test-clients/subsurface-parent-unmapped.c
+++ b/src/tests/wayland-test-clients/subsurface-parent-unmapped.c
@@ -25,18 +25,10 @@
#include "wayland-test-client-utils.h"
-#include "test-driver-client-protocol.h"
-#include "xdg-shell-client-protocol.h"
-
-static struct wl_display *display;
+static WaylandDisplay *display;
static struct wl_registry *registry;
-static struct wl_compositor *compositor;
-static struct wl_subcompositor *subcompositor;
-static struct xdg_wm_base *xdg_wm_base;
-static struct wl_shm *shm;
static struct wl_seat *seat;
static struct wl_pointer *pointer;
-static struct test_driver *test_driver;
static struct wl_surface *toplevel_surface;
static struct xdg_surface *toplevel_xdg_surface;
@@ -93,7 +85,7 @@ create_shm_buffer (int width,
return FALSE;
}
- pool = wl_shm_create_pool (shm, fd, size);
+ pool = wl_shm_create_pool (display->shm, fd, size);
buffer = wl_shm_pool_create_buffer (pool, 0,
width, height,
stride,
@@ -191,25 +183,13 @@ handle_toplevel_xdg_surface_configure (void *data,
xdg_surface_ack_configure (xdg_surface, serial);
draw_main ();
wl_surface_commit (toplevel_surface);
- wl_display_flush (display);
+ wl_display_flush (display->display);
}
static const struct xdg_surface_listener toplevel_xdg_surface_listener = {
handle_toplevel_xdg_surface_configure,
};
-static void
-handle_xdg_wm_base_ping (void *data,
- struct xdg_wm_base *xdg_wm_base,
- uint32_t serial)
-{
- xdg_wm_base_pong (xdg_wm_base, serial);
-}
-
-static const struct xdg_wm_base_listener xdg_wm_base_listener = {
- handle_xdg_wm_base_ping,
-};
-
static void
pointer_handle_enter (void *data,
struct wl_pointer *pointer,
@@ -243,7 +223,7 @@ handle_popup_frame_callback (void *data,
uint32_t time)
{
wl_callback_destroy (callback);
- test_driver_sync_point (test_driver, 0, popup_surface);
+ test_driver_sync_point (display->test_driver, 0, popup_surface);
}
static const struct wl_callback_listener frame_listener = {
@@ -266,7 +246,7 @@ handle_popup_xdg_surface_configure (void *data,
frame_callback = wl_surface_frame (popup_surface);
wl_callback_add_listener (frame_callback, &frame_listener, NULL);
wl_surface_commit (popup_surface);
- wl_display_flush (display);
+ wl_display_flush (display->display);
}
static const struct xdg_surface_listener popup_xdg_surface_listener = {
@@ -288,11 +268,11 @@ pointer_handle_button (void *data,
return;
/* Create a grabbing popup surface */
- popup_xdg_surface = xdg_wm_base_get_xdg_surface (xdg_wm_base,
+ popup_xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base,
popup_surface);
xdg_surface_add_listener (popup_xdg_surface,
&popup_xdg_surface_listener, NULL);
- positioner = xdg_wm_base_create_positioner (xdg_wm_base);
+ positioner = xdg_wm_base_create_positioner (display->xdg_wm_base);
xdg_positioner_set_size (positioner, 100, 100);
xdg_positioner_set_anchor_rect (positioner, 0, 0, 1, 1);
xdg_popup = xdg_surface_get_popup (popup_xdg_surface, toplevel_xdg_surface,
@@ -307,7 +287,7 @@ pointer_handle_button (void *data,
* is handled accurately. This passing verifies we don't reproduce
* https://gitlab.gnome.org/GNOME/mutter/-/issues/1828.
*/
- wl_display_roundtrip (display);
+ wl_display_roundtrip (display->display);
exit (EXIT_SUCCESS);
}
@@ -356,9 +336,8 @@ static const struct wl_seat_listener seat_listener = {
};
static void
-test_driver_handle_sync_event (void *data,
- struct test_driver *test_driver,
- uint32_t serial)
+on_sync_event (WaylandDisplay *display,
+ uint32_t serial)
{
g_assert (serial == 0);
@@ -371,13 +350,9 @@ test_driver_handle_sync_event (void *data,
g_clear_pointer (&popup_xdg_surface, xdg_surface_destroy);
/* This will trigger a click again, opening the popup a second time. */
- test_driver_sync_point (test_driver, 1, toplevel_surface);
+ test_driver_sync_point (display->test_driver, 1, toplevel_surface);
}
-static const struct test_driver_listener test_driver_listener = {
- test_driver_handle_sync_event,
-};
-
static void
handle_registry_global (void *data,
struct wl_registry *registry,
@@ -385,36 +360,11 @@ handle_registry_global (void *data,
const char *interface,
uint32_t version)
{
- if (strcmp (interface, "wl_compositor") == 0)
- {
- compositor = wl_registry_bind (registry, id, &wl_compositor_interface, 1);
- }
- else if (strcmp (interface, "wl_subcompositor") == 0)
- {
- subcompositor = wl_registry_bind (registry,
- id, &wl_subcompositor_interface, 1);
- }
- else if (strcmp (interface, "xdg_wm_base") == 0)
- {
- xdg_wm_base = wl_registry_bind (registry, id,
- &xdg_wm_base_interface, 1);
- xdg_wm_base_add_listener (xdg_wm_base, &xdg_wm_base_listener, NULL);
- }
- else if (strcmp (interface, "wl_shm") == 0)
- {
- shm = wl_registry_bind (registry,
- id, &wl_shm_interface, 1);
- }
- else if (strcmp (interface, "wl_seat") == 0)
+ if (strcmp (interface, "wl_seat") == 0)
{
seat = wl_registry_bind (registry, id, &wl_seat_interface, 1);
wl_seat_add_listener (seat, &seat_listener, NULL);
}
- else if (strcmp (interface, "test_driver") == 0)
- {
- test_driver = wl_registry_bind (registry, id, &test_driver_interface, 1);
- test_driver_add_listener (test_driver, &test_driver_listener, NULL);
- }
}
static void
@@ -433,26 +383,14 @@ int
main (int argc,
char **argv)
{
- display = wl_display_connect (NULL);
- registry = wl_display_get_registry (display);
- wl_registry_add_listener (registry, ®istry_listener, NULL);
- wl_display_roundtrip (display);
-
- if (!shm)
- {
- fprintf (stderr, "No wl_shm global\n");
- return EXIT_FAILURE;
- }
+ display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
- if (!xdg_wm_base)
- {
- fprintf (stderr, "No xdg_wm_base global\n");
- return EXIT_FAILURE;
- }
+ g_signal_connect (display, "sync-event", G_CALLBACK (on_sync_event), NULL);
- wl_display_roundtrip (display);
-
- g_assert_nonnull (test_driver);
+ registry = wl_display_get_registry (display->display);
+ wl_registry_add_listener (registry, ®istry_listener, NULL);
+ wl_display_roundtrip (display->display);
+ wl_display_roundtrip (display->display);
/*
* This test case does the following:
@@ -466,8 +404,8 @@ main (int argc,
* subsurface association set up.
*/
- toplevel_surface = wl_compositor_create_surface (compositor);
- toplevel_xdg_surface = xdg_wm_base_get_xdg_surface (xdg_wm_base,
+ toplevel_surface = wl_compositor_create_surface (display->compositor);
+ toplevel_xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base,
toplevel_surface);
xdg_surface_add_listener (toplevel_xdg_surface,
&toplevel_xdg_surface_listener, NULL);
@@ -476,9 +414,9 @@ main (int argc,
xdg_toplevel_set_title (xdg_toplevel, "subsurface-parent-unmapped");
wl_surface_commit (toplevel_surface);
- popup_surface = wl_compositor_create_surface (compositor);
- subsurface_surface = wl_compositor_create_surface (compositor);
- subsurface = wl_subcompositor_get_subsurface (subcompositor,
+ popup_surface = wl_compositor_create_surface (display->compositor);
+ subsurface_surface = wl_compositor_create_surface (display->compositor);
+ subsurface = wl_subcompositor_get_subsurface (display->subcompositor,
subsurface_surface,
popup_surface);
wl_subsurface_set_position (subsurface, 0, 0);
@@ -486,9 +424,11 @@ main (int argc,
while (TRUE)
{
- if (wl_display_dispatch (display) == -1)
+ if (wl_display_dispatch (display->display) == -1)
return EXIT_FAILURE;
}
+ g_clear_object (&display);
+
return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]