tests/wayland-client-utils: Add way to create display from fd

Allows for more complex connection management.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2810>
This commit is contained in:
Jonas Ådahl 2023-01-27 20:50:50 +01:00 committed by Marge Bot
parent 337ade622c
commit 5d888f2df6
2 changed files with 15 additions and 3 deletions

View File

@ -219,17 +219,19 @@ static const struct wl_registry_listener registry_listener = {
}; };
WaylandDisplay * WaylandDisplay *
wayland_display_new (WaylandDisplayCapabilities capabilities) wayland_display_new_full (WaylandDisplayCapabilities capabilities,
struct wl_display *wayland_display)
{ {
WaylandDisplay *display; WaylandDisplay *display;
g_assert_nonnull (wayland_display);
display = g_object_new (wayland_display_get_type (), NULL); display = g_object_new (wayland_display_get_type (), NULL);
display->capabilities = capabilities; display->capabilities = capabilities;
display->properties = g_hash_table_new_full (g_str_hash, g_str_equal, display->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_free); g_free, g_free);
display->display = wl_display_connect (NULL); display->display = wayland_display;
g_assert_nonnull (display->display);
display->registry = wl_display_get_registry (display->display); display->registry = wl_display_get_registry (display->display);
wl_registry_add_listener (display->registry, &registry_listener, display); wl_registry_add_listener (display->registry, &registry_listener, display);
@ -250,6 +252,13 @@ wayland_display_new (WaylandDisplayCapabilities capabilities)
return display; return display;
} }
WaylandDisplay *
wayland_display_new (WaylandDisplayCapabilities capabilities)
{
return wayland_display_new_full (capabilities,
wl_display_connect (NULL));
}
static void static void
wayland_display_finalize (GObject *object) wayland_display_finalize (GObject *object)
{ {

View File

@ -60,6 +60,9 @@ int create_anonymous_file (off_t size);
WaylandDisplay * wayland_display_new (WaylandDisplayCapabilities capabilities); WaylandDisplay * wayland_display_new (WaylandDisplayCapabilities capabilities);
WaylandDisplay * wayland_display_new_full (WaylandDisplayCapabilities capabilities,
struct wl_display *wayland_display);
WaylandSurface * wayland_surface_new (WaylandDisplay *display, WaylandSurface * wayland_surface_new (WaylandDisplay *display,
const char *title, const char *title,
int default_width, int default_width,