tests/wayland-clients: Pass WaylandDisplay as user_data
Avoids using a static and make sure things are properly freed by using g_autoptr. Also take the opportunity to add some missing NULL initialization for auto-pointers variables Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3687>
This commit is contained in:
parent
c0c0b70599
commit
4b26feafac
@ -22,7 +22,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -88,7 +87,8 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
draw_main (gboolean rotated)
|
||||
draw_main (WaylandDisplay *display,
|
||||
gboolean rotated)
|
||||
{
|
||||
static uint32_t color0 = 0xffffffff;
|
||||
static uint32_t color1 = 0xff00ffff;
|
||||
@ -139,7 +139,7 @@ draw_main (gboolean rotated)
|
||||
}
|
||||
|
||||
static void
|
||||
wait_for_configure (void)
|
||||
wait_for_configure (WaylandDisplay *display)
|
||||
{
|
||||
waiting_for_configure = TRUE;
|
||||
while (waiting_for_configure || window_width == 0)
|
||||
@ -153,6 +153,7 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
@ -163,9 +164,9 @@ main (int argc,
|
||||
|
||||
xdg_toplevel_set_fullscreen(xdg_toplevel, NULL);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_configure ();
|
||||
wait_for_configure (display);
|
||||
|
||||
draw_main (FALSE);
|
||||
draw_main (display, FALSE);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_effects_completed (display, surface);
|
||||
|
||||
@ -185,7 +186,7 @@ main (int argc,
|
||||
wl_surface_commit (surface);
|
||||
wait_for_view_verified (display, 3);
|
||||
|
||||
draw_main (TRUE);
|
||||
draw_main (display, TRUE);
|
||||
wl_surface_set_buffer_transform (surface, WL_OUTPUT_TRANSFORM_90);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_view_verified (display, 4);
|
||||
@ -202,7 +203,5 @@ main (int argc,
|
||||
wl_surface_commit (surface);
|
||||
wait_for_view_verified (display, 7);
|
||||
|
||||
g_clear_object (&display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -55,8 +55,6 @@ typedef enum
|
||||
WINDOW_STATE_FULLSCREEN,
|
||||
} WindowState;
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -92,8 +90,9 @@ init_surface (void)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_main (int width,
|
||||
int height)
|
||||
draw_main (WaylandDisplay *display,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
WaylandBuffer *buffer;
|
||||
DmaBufFormat *format;
|
||||
@ -140,9 +139,11 @@ handle_xdg_toplevel_configure (void *user_data,
|
||||
int32_t height,
|
||||
struct wl_array *states)
|
||||
{
|
||||
WaylandDisplay *display;
|
||||
g_assert (width > 0 || prev_width > 0);
|
||||
g_assert (height > 0 || prev_width > 0);
|
||||
|
||||
display = user_data;
|
||||
if (width > 0 && height > 0)
|
||||
{
|
||||
prev_width = width;
|
||||
@ -156,7 +157,7 @@ handle_xdg_toplevel_configure (void *user_data,
|
||||
|
||||
window_state = parse_xdg_toplevel_state (states);
|
||||
|
||||
draw_main (width, height);
|
||||
draw_main (display, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -196,6 +197,7 @@ handle_xdg_surface_configure (void *user_data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = user_data;
|
||||
struct wl_callback *frame_callback;
|
||||
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
@ -223,6 +225,7 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
g_signal_connect (display, "sync-event", G_CALLBACK (on_sync_event), NULL);
|
||||
wl_display_roundtrip (display->display);
|
||||
@ -230,9 +233,9 @@ main (int argc,
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, display);
|
||||
|
||||
init_surface ();
|
||||
|
||||
@ -244,7 +247,6 @@ main (int argc,
|
||||
}
|
||||
|
||||
g_list_free_full (active_buffers, (GDestroyNotify) g_object_unref);
|
||||
g_object_unref (display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -43,6 +42,8 @@ handle_frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
wl_callback_destroy (callback);
|
||||
test_driver_sync_point (display->test_driver, sync_point++, NULL);
|
||||
}
|
||||
@ -52,7 +53,7 @@ static const struct wl_callback_listener frame_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
maybe_redraw (void)
|
||||
maybe_redraw (WaylandDisplay *display)
|
||||
{
|
||||
struct wl_callback *callback;
|
||||
uint32_t buffer_width;
|
||||
@ -72,7 +73,7 @@ maybe_redraw (void)
|
||||
wp_viewport_set_destination (viewport, logical_width, logical_height);
|
||||
|
||||
callback = wl_surface_frame (surface);
|
||||
wl_callback_add_listener (callback, &frame_listener, NULL);
|
||||
wl_callback_add_listener (callback, &frame_listener, display);
|
||||
|
||||
wl_surface_commit (surface);
|
||||
|
||||
@ -112,10 +113,11 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
waiting_for_configure = FALSE;
|
||||
|
||||
maybe_redraw ();
|
||||
maybe_redraw (display);
|
||||
}
|
||||
|
||||
static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
@ -126,6 +128,7 @@ static void handle_preferred_scale (void *data,
|
||||
struct wp_fractional_scale_v1 *fractional_scale_obj,
|
||||
uint32_t wire_scale)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
float new_fractional_buffer_scale;
|
||||
|
||||
new_fractional_buffer_scale = wire_scale / 120.0;
|
||||
@ -136,7 +139,7 @@ static void handle_preferred_scale (void *data,
|
||||
|
||||
fractional_buffer_scale = new_fractional_buffer_scale;
|
||||
waiting_for_scale = FALSE;
|
||||
maybe_redraw ();
|
||||
maybe_redraw (display);
|
||||
}
|
||||
|
||||
static const struct wp_fractional_scale_v1_listener fractional_scale_listener = {
|
||||
@ -147,11 +150,12 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
xdg_toplevel_set_title (xdg_toplevel, "fractional-scale");
|
||||
@ -163,7 +167,7 @@ main (int argc,
|
||||
surface);
|
||||
wp_fractional_scale_v1_add_listener (fractional_scale_obj,
|
||||
&fractional_scale_listener,
|
||||
NULL);
|
||||
display);
|
||||
|
||||
wl_surface_commit (surface);
|
||||
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -58,6 +56,8 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
draw_surface (display, surface, 10, 10, 0x1f109f20);
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
wl_surface_commit (surface);
|
||||
@ -81,12 +81,13 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
g_signal_connect (display, "sync-event", G_CALLBACK (on_sync_event), NULL);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
xdg_toplevel_set_title (xdg_toplevel, "fullscreen");
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "idle-inhibit-unstable-v1-client-protocol.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
|
||||
|
||||
static void
|
||||
@ -59,7 +58,8 @@ main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
struct wl_registry *registry;
|
||||
WaylandSurface *surface;
|
||||
g_autoptr (WaylandSurface) surface;
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
struct zwp_idle_inhibitor_v1 *inhibitor;
|
||||
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
@ -24,33 +24,16 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static void
|
||||
connect_to_display (void)
|
||||
{
|
||||
g_assert_null (display);
|
||||
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_NONE);
|
||||
g_assert_nonnull (display);
|
||||
}
|
||||
|
||||
static void
|
||||
clean_up_display (void)
|
||||
{
|
||||
g_clear_object (&display);
|
||||
}
|
||||
|
||||
static void
|
||||
test_circular_subsurfaces1 (void)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
struct wl_surface *surface1;
|
||||
struct wl_subsurface *subsurface1;
|
||||
struct wl_surface *surface2;
|
||||
struct wl_subsurface *subsurface2;
|
||||
|
||||
connect_to_display ();
|
||||
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_NONE);
|
||||
surface1 = wl_compositor_create_surface (display->compositor);
|
||||
surface2 = wl_compositor_create_surface (display->compositor);
|
||||
g_assert_nonnull (surface1);
|
||||
@ -66,13 +49,12 @@ test_circular_subsurfaces1 (void)
|
||||
g_assert_nonnull (subsurface2);
|
||||
|
||||
g_assert_cmpint (wl_display_roundtrip (display->display), ==, -1);
|
||||
|
||||
clean_up_display ();
|
||||
}
|
||||
|
||||
static void
|
||||
test_circular_subsurfaces2 (void)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
struct wl_surface *surface1;
|
||||
struct wl_subsurface *subsurface1;
|
||||
struct wl_surface *surface2;
|
||||
@ -80,7 +62,7 @@ test_circular_subsurfaces2 (void)
|
||||
struct wl_surface *surface3;
|
||||
struct wl_subsurface *subsurface3;
|
||||
|
||||
connect_to_display ();
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_NONE);
|
||||
|
||||
surface1 = wl_compositor_create_surface (display->compositor);
|
||||
surface2 = wl_compositor_create_surface (display->compositor);
|
||||
@ -103,8 +85,6 @@ test_circular_subsurfaces2 (void)
|
||||
g_assert_nonnull (subsurface3);
|
||||
|
||||
g_assert_cmpint (wl_display_roundtrip (display->display), ==, -1);
|
||||
|
||||
clean_up_display ();
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -38,7 +36,7 @@ init_surface (void)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_main (void)
|
||||
draw_main (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, surface, 700, 500, 0xff00ff00);
|
||||
}
|
||||
@ -69,13 +67,14 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
static gboolean sent_invalid_once = FALSE;
|
||||
|
||||
if (sent_invalid_once)
|
||||
return;
|
||||
|
||||
xdg_surface_set_window_geometry (xdg_surface, 0, 0, 0, 0);
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
wl_surface_commit (surface);
|
||||
|
||||
sent_invalid_once = TRUE;
|
||||
@ -91,11 +90,12 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
static void
|
||||
test_empty_window_geometry (void)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_NONE);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
|
||||
@ -110,7 +110,6 @@ test_empty_window_geometry (void)
|
||||
|
||||
g_clear_pointer (&xdg_toplevel, xdg_toplevel_destroy);
|
||||
g_clear_pointer (&xdg_surface, xdg_surface_destroy);
|
||||
g_clear_object (&display);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_registry *wl_registry;
|
||||
static struct wl_seat *wl_seat;
|
||||
static struct wl_pointer *wl_pointer;
|
||||
@ -48,8 +46,9 @@ init_surface (void)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_main (int width,
|
||||
int height)
|
||||
draw_main (WaylandDisplay *display,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_surface (display, surface, width, height, 0xff00ff00);
|
||||
}
|
||||
@ -89,7 +88,9 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
draw_main (100, 100);
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
draw_main (display, 100, 100);
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
wl_surface_commit (surface);
|
||||
}
|
||||
@ -251,6 +252,7 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
wl_registry = wl_display_get_registry (display->display);
|
||||
wl_registry_add_listener (wl_registry, ®istry_listener, display);
|
||||
@ -260,7 +262,7 @@ main (int argc,
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -91,7 +90,7 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
wait_for_configure (void)
|
||||
wait_for_configure (WaylandDisplay *display)
|
||||
{
|
||||
waiting_for_configure = TRUE;
|
||||
while (waiting_for_configure || window_width == 0)
|
||||
@ -114,7 +113,7 @@ static const struct wl_buffer_listener buffer_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
wait_for_buffer_released (void)
|
||||
wait_for_buffer_released (WaylandDisplay *display)
|
||||
{
|
||||
while (buffer)
|
||||
{
|
||||
@ -127,6 +126,7 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
struct wp_viewport *viewport;
|
||||
struct wp_viewport *subsurface_viewport;
|
||||
|
||||
@ -140,7 +140,7 @@ main (int argc,
|
||||
|
||||
xdg_toplevel_set_fullscreen (xdg_toplevel, NULL);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_configure ();
|
||||
wait_for_configure (display);
|
||||
|
||||
viewport = wp_viewporter_get_viewport (display->viewporter, surface);
|
||||
wp_viewport_set_destination (viewport, window_width, window_height);
|
||||
@ -157,7 +157,7 @@ main (int argc,
|
||||
wait_for_effects_completed (display, surface);
|
||||
wait_for_view_verified (display, 0);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
subsurface_surface = wl_compositor_create_surface (display->compositor);
|
||||
subsurface = wl_subcompositor_get_subsurface (display->subcompositor,
|
||||
@ -184,7 +184,7 @@ main (int argc,
|
||||
wl_surface_commit (subsurface_surface);
|
||||
wait_for_view_verified (display, 1);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
buffer =
|
||||
wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_mgr,
|
||||
@ -197,7 +197,7 @@ main (int argc,
|
||||
wl_surface_commit (subsurface_surface);
|
||||
wait_for_view_verified (display, 0);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
buffer =
|
||||
wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_mgr,
|
||||
@ -210,7 +210,7 @@ main (int argc,
|
||||
wl_surface_commit (subsurface_surface);
|
||||
wait_for_view_verified (display, 2);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
buffer =
|
||||
wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_mgr,
|
||||
@ -223,7 +223,7 @@ main (int argc,
|
||||
wl_surface_commit (subsurface_surface);
|
||||
wait_for_view_verified (display, 3);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
buffer =
|
||||
wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_mgr,
|
||||
@ -236,7 +236,7 @@ main (int argc,
|
||||
wl_surface_commit (subsurface_surface);
|
||||
wait_for_view_verified (display, 4);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
buffer =
|
||||
wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_mgr,
|
||||
@ -249,7 +249,7 @@ main (int argc,
|
||||
wl_surface_commit (subsurface_surface);
|
||||
wait_for_view_verified (display, 5);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
buffer =
|
||||
wp_single_pixel_buffer_manager_v1_create_u32_rgba_buffer (display->single_pixel_mgr,
|
||||
@ -262,9 +262,7 @@ main (int argc,
|
||||
wl_surface_commit (subsurface_surface);
|
||||
wait_for_view_verified (display, 6);
|
||||
|
||||
wait_for_buffer_released ();
|
||||
|
||||
g_clear_object (&display);
|
||||
wait_for_buffer_released (display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
static struct wl_surface *toplevel_surface, *child_surface, *grandchild_surface;
|
||||
static struct wl_subsurface *child, *grandchild;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
@ -75,7 +74,7 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
draw_toplevel (void)
|
||||
draw_toplevel (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, toplevel_surface,
|
||||
window_width, window_height,
|
||||
@ -97,7 +96,7 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
draw_child (void)
|
||||
draw_child (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, child_surface,
|
||||
window_width / 2, window_height / 2,
|
||||
@ -105,7 +104,7 @@ draw_child (void)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_grandchild (void)
|
||||
draw_grandchild (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, grandchild_surface,
|
||||
window_width / 2, window_height / 2,
|
||||
@ -113,7 +112,7 @@ draw_grandchild (void)
|
||||
}
|
||||
|
||||
static void
|
||||
wait_for_configure (void)
|
||||
wait_for_configure (WaylandDisplay *display)
|
||||
{
|
||||
waiting_for_configure = TRUE;
|
||||
while (waiting_for_configure || window_width == 0)
|
||||
@ -127,6 +126,7 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
toplevel_surface = wl_compositor_create_surface (display->compositor);
|
||||
@ -138,9 +138,9 @@ main (int argc,
|
||||
|
||||
xdg_toplevel_set_fullscreen (xdg_toplevel, NULL);
|
||||
wl_surface_commit (toplevel_surface);
|
||||
wait_for_configure ();
|
||||
wait_for_configure (display);
|
||||
|
||||
draw_toplevel ();
|
||||
draw_toplevel (display);
|
||||
wl_surface_commit (toplevel_surface);
|
||||
wait_for_effects_completed (display, toplevel_surface);
|
||||
|
||||
@ -148,7 +148,7 @@ main (int argc,
|
||||
child = wl_subcompositor_get_subsurface (display->subcompositor,
|
||||
child_surface,
|
||||
toplevel_surface);
|
||||
draw_child ();
|
||||
draw_child (display);
|
||||
wl_surface_commit (child_surface);
|
||||
/* No toplevel commit → sub-surface must not be mapped yet */
|
||||
wait_for_view_verified (display, 0);
|
||||
@ -174,7 +174,7 @@ main (int argc,
|
||||
/* Toplevel commit → sub-surface must be unmapped */
|
||||
wait_for_view_verified (display, 5);
|
||||
|
||||
draw_child ();
|
||||
draw_child (display);
|
||||
wl_surface_commit (child_surface);
|
||||
wl_subsurface_set_desync (child);
|
||||
wl_surface_attach (child_surface, NULL, 0, 0);
|
||||
@ -182,7 +182,7 @@ main (int argc,
|
||||
/* Desync sub-surface must have been unmapped */
|
||||
wait_for_view_verified (display, 6);
|
||||
|
||||
draw_child ();
|
||||
draw_child (display);
|
||||
wl_surface_commit (child_surface);
|
||||
wl_subsurface_set_sync (child);
|
||||
wl_subsurface_destroy (child);
|
||||
@ -192,7 +192,7 @@ main (int argc,
|
||||
child = wl_subcompositor_get_subsurface (display->subcompositor,
|
||||
child_surface,
|
||||
toplevel_surface);
|
||||
draw_child ();
|
||||
draw_child (display);
|
||||
wl_surface_commit (child_surface);
|
||||
/* No toplevel commit → sub-surface must not be mapped yet */
|
||||
wait_for_view_verified (display, 8);
|
||||
@ -209,7 +209,7 @@ main (int argc,
|
||||
child = wl_subcompositor_get_subsurface (display->subcompositor,
|
||||
child_surface,
|
||||
toplevel_surface);
|
||||
draw_child ();
|
||||
draw_child (display);
|
||||
wl_surface_commit (child_surface);
|
||||
wl_surface_commit (toplevel_surface);
|
||||
/* New sub-surface → placement below toplevel must not have taken effect */
|
||||
@ -219,7 +219,7 @@ main (int argc,
|
||||
grandchild = wl_subcompositor_get_subsurface (display->subcompositor,
|
||||
grandchild_surface,
|
||||
child_surface);
|
||||
draw_grandchild ();
|
||||
draw_grandchild (display);
|
||||
wl_subsurface_set_position (grandchild, window_width / 4, window_height / 4);
|
||||
wl_surface_commit (grandchild_surface);
|
||||
wl_surface_commit (child_surface);
|
||||
@ -236,7 +236,7 @@ main (int argc,
|
||||
grandchild = wl_subcompositor_get_subsurface (display->subcompositor,
|
||||
grandchild_surface,
|
||||
child_surface);
|
||||
draw_grandchild ();
|
||||
draw_grandchild (display);
|
||||
wl_subsurface_set_position (grandchild, window_width / 4, window_height / 4);
|
||||
wl_surface_commit (grandchild_surface);
|
||||
wl_surface_commit (child_surface);
|
||||
@ -244,7 +244,5 @@ main (int argc,
|
||||
/* New grandchild must be placed above its parent */
|
||||
wait_for_view_verified (display, 14);
|
||||
|
||||
g_clear_object (&display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
static struct wl_registry *registry;
|
||||
static struct wl_seat *seat;
|
||||
static struct wl_pointer *pointer;
|
||||
@ -40,19 +39,19 @@ static struct wl_surface *subsurface_surface;
|
||||
static struct wl_subsurface *subsurface;
|
||||
|
||||
static void
|
||||
draw_main (void)
|
||||
draw_main (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, toplevel_surface, 200, 200, 0xff00ffff);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_popup (void)
|
||||
draw_popup (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, popup_surface, 100, 100, 0xff005500);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_subsurface (void)
|
||||
draw_subsurface (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, subsurface_surface, 100, 50, 0xff001f00);
|
||||
}
|
||||
@ -83,8 +82,10 @@ handle_toplevel_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
wl_surface_commit (toplevel_surface);
|
||||
wl_display_flush (display->display);
|
||||
}
|
||||
@ -125,6 +126,8 @@ handle_popup_frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
wl_callback_destroy (callback);
|
||||
test_driver_sync_point (display->test_driver, 0, popup_surface);
|
||||
}
|
||||
@ -138,16 +141,17 @@ handle_popup_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
struct wl_callback *frame_callback;
|
||||
|
||||
draw_popup ();
|
||||
draw_popup (display);
|
||||
|
||||
draw_subsurface ();
|
||||
draw_subsurface (display);
|
||||
wl_surface_commit (subsurface_surface);
|
||||
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
frame_callback = wl_surface_frame (popup_surface);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, NULL);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, display);
|
||||
wl_surface_commit (popup_surface);
|
||||
wl_display_flush (display->display);
|
||||
}
|
||||
@ -164,6 +168,7 @@ pointer_handle_button (void *data,
|
||||
uint32_t button,
|
||||
uint32_t state)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
struct xdg_positioner *positioner;
|
||||
static int click_count = 0;
|
||||
|
||||
@ -174,7 +179,7 @@ pointer_handle_button (void *data,
|
||||
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);
|
||||
&popup_xdg_surface_listener, display);
|
||||
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);
|
||||
@ -219,10 +224,12 @@ seat_handle_capabilities (void *data,
|
||||
struct wl_seat *wl_seat,
|
||||
enum wl_seat_capability caps)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
if (caps & WL_SEAT_CAPABILITY_POINTER)
|
||||
{
|
||||
pointer = wl_seat_get_pointer (wl_seat);
|
||||
wl_pointer_add_listener (pointer, &pointer_listener, NULL);
|
||||
wl_pointer_add_listener (pointer, &pointer_listener, display);
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,10 +270,12 @@ handle_registry_global (void *data,
|
||||
const char *interface,
|
||||
uint32_t version)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
if (strcmp (interface, "wl_seat") == 0)
|
||||
{
|
||||
seat = wl_registry_bind (registry, id, &wl_seat_interface, 1);
|
||||
wl_seat_add_listener (seat, &seat_listener, NULL);
|
||||
wl_seat_add_listener (seat, &seat_listener, display);
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,12 +295,13 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
g_signal_connect (display, "sync-event", G_CALLBACK (on_sync_event), NULL);
|
||||
|
||||
registry = wl_display_get_registry (display->display);
|
||||
wl_registry_add_listener (registry, ®istry_listener, NULL);
|
||||
wl_registry_add_listener (registry, ®istry_listener, display);
|
||||
wl_display_roundtrip (display->display);
|
||||
wl_display_roundtrip (display->display);
|
||||
|
||||
@ -311,7 +321,7 @@ main (int argc,
|
||||
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);
|
||||
&toplevel_xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (toplevel_xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
xdg_toplevel_set_title (xdg_toplevel, "subsurface-parent-unmapped");
|
||||
@ -331,7 +341,5 @@ main (int argc,
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
g_clear_object (&display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -32,8 +32,6 @@ typedef enum _State
|
||||
STATE_WAIT_FOR_FRAME_2
|
||||
} State;
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -72,7 +70,7 @@ static const struct wl_callback_listener actor_destroy_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
reset_surface (void)
|
||||
reset_surface (WaylandDisplay *display)
|
||||
{
|
||||
struct wl_callback *callback;
|
||||
|
||||
@ -86,13 +84,13 @@ reset_surface (void)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_main (void)
|
||||
draw_main (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, surface, 700, 500, 0xff00ff00);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_subsurface (void)
|
||||
draw_subsurface (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, subsurface_surface, 500, 300, 0xff007f00);
|
||||
}
|
||||
@ -123,10 +121,11 @@ handle_frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
switch (state)
|
||||
{
|
||||
case STATE_WAIT_FOR_FRAME_1:
|
||||
reset_surface ();
|
||||
reset_surface (display);
|
||||
break;
|
||||
case STATE_WAIT_FOR_FRAME_2:
|
||||
exit (EXIT_SUCCESS);
|
||||
@ -150,16 +149,17 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
switch (state)
|
||||
{
|
||||
case STATE_INIT:
|
||||
g_assert_not_reached ();
|
||||
case STATE_WAIT_FOR_CONFIGURE_1:
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
state = STATE_WAIT_FOR_FRAME_1;
|
||||
break;
|
||||
case STATE_WAIT_FOR_CONFIGURE_2:
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
state = STATE_WAIT_FOR_FRAME_2;
|
||||
break;
|
||||
case STATE_WAIT_FOR_ACTOR_DESTROYED:
|
||||
@ -172,7 +172,7 @@ handle_xdg_surface_configure (void *data,
|
||||
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
frame_callback = wl_surface_frame (surface);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, NULL);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, display);
|
||||
wl_surface_commit (surface);
|
||||
wl_display_flush (display->display);
|
||||
}
|
||||
@ -185,11 +185,12 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
|
||||
@ -198,7 +199,7 @@ main (int argc,
|
||||
subsurface_surface,
|
||||
surface);
|
||||
wl_subsurface_set_position (subsurface, 100, 100);
|
||||
draw_subsurface ();
|
||||
draw_subsurface (display);
|
||||
wl_surface_commit (subsurface_surface);
|
||||
|
||||
init_surface ();
|
||||
@ -211,7 +212,5 @@ main (int argc,
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
g_clear_object (&display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -34,8 +34,6 @@ typedef enum _State
|
||||
STATE_WAIT_FOR_FRAME_3
|
||||
} State;
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -47,16 +45,16 @@ static struct wl_callback *frame_callback;
|
||||
|
||||
static State state;
|
||||
|
||||
static void init_surfaces (void);
|
||||
static void init_surfaces (WaylandDisplay *display);
|
||||
|
||||
static void
|
||||
draw_main (void)
|
||||
draw_main (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, surface, 700, 500, 0xff00ff00);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_subsurface (void)
|
||||
draw_subsurface (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, subsurface_surface, 500, 300, 0xff007f00);
|
||||
}
|
||||
@ -87,10 +85,11 @@ actor_destroyed (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
g_assert_cmpint (state, ==, STATE_WAIT_FOR_ACTOR_DESTROYED);
|
||||
|
||||
wl_subsurface_destroy (subsurface);
|
||||
init_surfaces ();
|
||||
init_surfaces (display);
|
||||
state = STATE_WAIT_FOR_CONFIGURE_2;
|
||||
|
||||
wl_callback_destroy (callback);
|
||||
@ -101,12 +100,12 @@ static const struct wl_callback_listener actor_destroy_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
reset_surface (void)
|
||||
reset_surface (WaylandDisplay *display)
|
||||
{
|
||||
struct wl_callback *callback;
|
||||
|
||||
callback = test_driver_sync_actor_destroyed (display->test_driver, surface);
|
||||
wl_callback_add_listener (callback, &actor_destroy_listener, NULL);
|
||||
wl_callback_add_listener (callback, &actor_destroy_listener, display);
|
||||
|
||||
xdg_toplevel_destroy (xdg_toplevel);
|
||||
xdg_surface_destroy (xdg_surface);
|
||||
@ -120,10 +119,12 @@ handle_frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case STATE_WAIT_FOR_FRAME_1:
|
||||
reset_surface ();
|
||||
reset_surface (display);
|
||||
break;
|
||||
case STATE_WAIT_FOR_FRAME_2:
|
||||
exit (EXIT_SUCCESS);
|
||||
@ -141,16 +142,18 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case STATE_INIT:
|
||||
g_assert_not_reached ();
|
||||
case STATE_WAIT_FOR_CONFIGURE_1:
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
state = STATE_WAIT_FOR_FRAME_1;
|
||||
break;
|
||||
case STATE_WAIT_FOR_CONFIGURE_2:
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
state = STATE_WAIT_FOR_FRAME_2;
|
||||
break;
|
||||
default:
|
||||
@ -160,7 +163,7 @@ handle_xdg_surface_configure (void *data,
|
||||
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
frame_callback = wl_surface_frame (surface);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, NULL);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, display);
|
||||
wl_surface_commit (surface);
|
||||
wl_display_flush (display->display);
|
||||
}
|
||||
@ -170,11 +173,11 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
init_surfaces (void)
|
||||
init_surfaces (WaylandDisplay *display)
|
||||
{
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
xdg_toplevel_set_title (xdg_toplevel, "subsurface-reparenting-test");
|
||||
@ -190,13 +193,14 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
subsurface_surface = wl_compositor_create_surface (display->compositor);
|
||||
draw_subsurface ();
|
||||
draw_subsurface (display);
|
||||
wl_surface_commit (subsurface_surface);
|
||||
|
||||
init_surfaces ();
|
||||
init_surfaces (display);
|
||||
state = STATE_WAIT_FOR_CONFIGURE_1;
|
||||
|
||||
while (TRUE)
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "xdg-activation-v1-client-protocol.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
static struct wl_registry *registry;
|
||||
static struct xdg_activation_v1 *activation;
|
||||
|
||||
@ -43,7 +42,7 @@ init_surface (const char *token)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_main (void)
|
||||
draw_main (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, surface, 700, 500, 0xff00ff00);
|
||||
}
|
||||
@ -74,7 +73,9 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
draw_main ();
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
draw_main (display);
|
||||
wl_surface_commit (surface);
|
||||
|
||||
g_assert_cmpint (wl_display_roundtrip (display->display), !=, -1);
|
||||
@ -126,7 +127,7 @@ static const struct xdg_activation_token_v1_listener token_listener = {
|
||||
};
|
||||
|
||||
static char *
|
||||
get_token (void)
|
||||
get_token (WaylandDisplay *display)
|
||||
{
|
||||
struct xdg_activation_token_v1 *token;
|
||||
char *token_string = NULL;
|
||||
@ -151,6 +152,7 @@ get_token (void)
|
||||
static void
|
||||
test_startup_notifications (void)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
g_autofree char *token = NULL;
|
||||
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_NONE);
|
||||
@ -162,11 +164,11 @@ test_startup_notifications (void)
|
||||
|
||||
wl_display_roundtrip (display->display);
|
||||
|
||||
token = get_token ();
|
||||
token = get_token (display);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
|
||||
@ -185,7 +187,6 @@ test_startup_notifications (void)
|
||||
g_clear_pointer (&xdg_surface, xdg_surface_destroy);
|
||||
g_clear_pointer (&activation, xdg_activation_v1_destroy);
|
||||
g_clear_pointer (®istry, wl_registry_destroy);
|
||||
g_clear_object (&display);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -31,8 +31,6 @@ typedef enum _State
|
||||
STATE_WAIT_FOR_FRAME_2
|
||||
} State;
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -71,7 +69,7 @@ static const struct wl_callback_listener actor_destroy_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
reset_surface (void)
|
||||
reset_surface (WaylandDisplay *display)
|
||||
{
|
||||
struct wl_callback *callback;
|
||||
|
||||
@ -89,13 +87,13 @@ reset_surface (void)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_main (void)
|
||||
draw_main (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, surface, 700, 500, 0xff00ff00);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_subsurface (void)
|
||||
draw_subsurface (WaylandDisplay *display)
|
||||
{
|
||||
draw_surface (display, subsurface_surface, 500, 300, 0xff007f00);
|
||||
}
|
||||
@ -126,10 +124,12 @@ handle_frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case STATE_WAIT_FOR_FRAME_1:
|
||||
reset_surface ();
|
||||
reset_surface (display);
|
||||
test_driver_sync_point (display->test_driver, 1, NULL);
|
||||
break;
|
||||
case STATE_WAIT_FOR_FRAME_2:
|
||||
@ -154,16 +154,18 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case STATE_INIT:
|
||||
g_assert_not_reached ();
|
||||
case STATE_WAIT_FOR_CONFIGURE_1:
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
state = STATE_WAIT_FOR_FRAME_1;
|
||||
break;
|
||||
case STATE_WAIT_FOR_CONFIGURE_2:
|
||||
draw_main ();
|
||||
draw_main (display);
|
||||
state = STATE_WAIT_FOR_FRAME_2;
|
||||
break;
|
||||
case STATE_WAIT_FOR_ACTOR_DESTROYED:
|
||||
@ -176,7 +178,7 @@ handle_xdg_surface_configure (void *data,
|
||||
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
frame_callback = wl_surface_frame (surface);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, NULL);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, display);
|
||||
wl_surface_commit (surface);
|
||||
wl_display_flush (display->display);
|
||||
}
|
||||
@ -189,11 +191,12 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
|
||||
@ -202,7 +205,7 @@ main (int argc,
|
||||
subsurface_surface,
|
||||
surface);
|
||||
wl_subsurface_set_position (subsurface, 100, 100);
|
||||
draw_subsurface ();
|
||||
draw_subsurface (display);
|
||||
wl_surface_commit (subsurface_surface);
|
||||
|
||||
init_surface ();
|
||||
|
@ -24,8 +24,6 @@
|
||||
#include "xdg-foreign-unstable-v1-client-protocol.h"
|
||||
#include "xdg-foreign-unstable-v2-client-protocol.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct zxdg_exporter_v1 *exporter_v1;
|
||||
static struct zxdg_exporter_v2 *exporter_v2;
|
||||
static struct zxdg_importer_v1 *importer_v1;
|
||||
@ -130,10 +128,11 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandSurface) window1;
|
||||
g_autoptr (WaylandSurface) window2;
|
||||
g_autoptr (WaylandSurface) window3;
|
||||
g_autoptr (WaylandSurface) window4;
|
||||
g_autoptr (WaylandSurface) window1 = NULL;
|
||||
g_autoptr (WaylandSurface) window2 = NULL;
|
||||
g_autoptr (WaylandSurface) window3 = NULL;
|
||||
g_autoptr (WaylandSurface) window4 = NULL;
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
g_autofree char *handle1 = NULL;
|
||||
g_autofree char *handle3 = NULL;
|
||||
struct wl_registry *registry;
|
||||
@ -222,7 +221,5 @@ main (int argc,
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
g_object_unref (display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ typedef enum _State
|
||||
STATE_WAIT_FOR_FRAME_1,
|
||||
} State;
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -51,8 +49,9 @@ init_surface (void)
|
||||
}
|
||||
|
||||
static void
|
||||
draw_main (int width,
|
||||
int height)
|
||||
draw_main (WaylandDisplay *display,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
draw_surface (display, surface, width, height, 0xff00ff00);
|
||||
}
|
||||
@ -94,6 +93,8 @@ handle_frame_callback (void *data,
|
||||
struct wl_callback *callback,
|
||||
uint32_t time)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case STATE_WAIT_FOR_FRAME_1:
|
||||
@ -114,6 +115,8 @@ handle_xdg_surface_configure (void *data,
|
||||
struct xdg_surface *xdg_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
WaylandDisplay *display = data;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case STATE_INIT:
|
||||
@ -122,7 +125,8 @@ handle_xdg_surface_configure (void *data,
|
||||
g_assert (pending_bounds_width > 0);
|
||||
g_assert (pending_bounds_height > 0);
|
||||
|
||||
draw_main (pending_bounds_width - 10,
|
||||
draw_main (display,
|
||||
pending_bounds_width - 10,
|
||||
pending_bounds_height - 10);
|
||||
state = STATE_WAIT_FOR_FRAME_1;
|
||||
break;
|
||||
@ -132,7 +136,7 @@ handle_xdg_surface_configure (void *data,
|
||||
|
||||
xdg_surface_ack_configure (xdg_surface, serial);
|
||||
frame_callback = wl_surface_frame (surface);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, NULL);
|
||||
wl_callback_add_listener (frame_callback, &frame_listener, display);
|
||||
wl_surface_commit (surface);
|
||||
wl_display_flush (display->display);
|
||||
}
|
||||
@ -154,13 +158,14 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER |
|
||||
WAYLAND_DISPLAY_CAPABILITY_XDG_SHELL_V4);
|
||||
g_signal_connect (display, "sync-event", G_CALLBACK (on_sync_event), NULL);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
xdg_surface = xdg_wm_base_get_xdg_surface (display->xdg_wm_base, surface);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, NULL);
|
||||
xdg_surface_add_listener (xdg_surface, &xdg_surface_listener, display);
|
||||
xdg_toplevel = xdg_surface_get_toplevel (xdg_surface);
|
||||
xdg_toplevel_add_listener (xdg_toplevel, &xdg_toplevel_listener, NULL);
|
||||
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static struct wl_surface *surface;
|
||||
static struct xdg_surface *xdg_surface;
|
||||
static struct xdg_toplevel *xdg_toplevel;
|
||||
@ -63,8 +61,9 @@ typedef void (*ShaderFunc) (float x,
|
||||
float *out_cr);
|
||||
|
||||
static void
|
||||
draw (uint32_t drm_format,
|
||||
ShaderFunc shader)
|
||||
draw (WaylandDisplay *display,
|
||||
uint32_t drm_format,
|
||||
ShaderFunc shader)
|
||||
{
|
||||
WaylandBuffer *buffer;
|
||||
uint8_t *planes[4];
|
||||
@ -180,7 +179,7 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
};
|
||||
|
||||
static void
|
||||
wait_for_configure (void)
|
||||
wait_for_configure (WaylandDisplay *display)
|
||||
{
|
||||
waiting_for_configure = TRUE;
|
||||
while (waiting_for_configure)
|
||||
@ -194,6 +193,7 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_autoptr (WaylandDisplay) display = NULL;
|
||||
display = wayland_display_new (WAYLAND_DISPLAY_CAPABILITY_TEST_DRIVER);
|
||||
|
||||
surface = wl_compositor_create_surface (display->compositor);
|
||||
@ -205,27 +205,25 @@ main (int argc,
|
||||
xdg_toplevel_set_fullscreen (xdg_toplevel, NULL);
|
||||
wl_surface_commit (surface);
|
||||
|
||||
wait_for_configure ();
|
||||
wait_for_configure (display);
|
||||
|
||||
draw (DRM_FORMAT_YUYV, shader_luma_gradient);
|
||||
draw (display, DRM_FORMAT_YUYV, shader_luma_gradient);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_effects_completed (display, surface);
|
||||
wait_for_view_verified (display, 0);
|
||||
|
||||
draw (DRM_FORMAT_YUYV, shader_color_gradient);
|
||||
draw (display, DRM_FORMAT_YUYV, shader_color_gradient);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_view_verified (display, 1);
|
||||
|
||||
draw (DRM_FORMAT_YUV420, shader_luma_gradient);
|
||||
draw (display, DRM_FORMAT_YUV420, shader_luma_gradient);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_view_verified (display, 2);
|
||||
|
||||
draw (DRM_FORMAT_YUV420, shader_color_gradient);
|
||||
draw (display, DRM_FORMAT_YUV420, shader_color_gradient);
|
||||
wl_surface_commit (surface);
|
||||
wait_for_view_verified (display, 3);
|
||||
|
||||
g_clear_pointer (&xdg_toplevel, xdg_toplevel_destroy);
|
||||
g_clear_pointer (&xdg_surface, xdg_surface_destroy);
|
||||
|
||||
g_clear_object (&display);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user