tests/wayland: Make display helper a GObject
This is in preparation for adding signals. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2416>
This commit is contained in:
parent
b0528dcd53
commit
d5367f7332
@ -24,8 +24,6 @@
|
||||
|
||||
#include "wayland-test-client-utils.h"
|
||||
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
|
||||
static WaylandDisplay *display;
|
||||
|
||||
static void
|
||||
@ -40,7 +38,7 @@ connect_to_display (void)
|
||||
static void
|
||||
clean_up_display (void)
|
||||
{
|
||||
g_clear_pointer (&display, wayland_display_free);
|
||||
g_clear_object (&display);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -207,7 +207,7 @@ test_empty_window_geometry (void)
|
||||
|
||||
g_clear_pointer (&xdg_toplevel, xdg_toplevel_destroy);
|
||||
g_clear_pointer (&xdg_surface, xdg_surface_destroy);
|
||||
g_clear_pointer (&display, wayland_display_free);
|
||||
g_clear_object (&display);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -66,6 +66,7 @@ foreach test : wayland_test_clients
|
||||
c_args: tests_c_args,
|
||||
dependencies: [
|
||||
glib_dep,
|
||||
gobject_dep,
|
||||
wayland_client_dep,
|
||||
],
|
||||
install: have_installed_tests,
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
G_DEFINE_TYPE (WaylandDisplay, wayland_display, G_TYPE_OBJECT)
|
||||
|
||||
static int
|
||||
create_tmpfile_cloexec (char *tmpname)
|
||||
{
|
||||
@ -107,7 +109,7 @@ handle_registry_global (void *user_data,
|
||||
const char *interface,
|
||||
uint32_t version)
|
||||
{
|
||||
WaylandDisplay *display = user_data;
|
||||
WaylandDisplay *display = WAYLAND_DISPLAY (user_data);
|
||||
|
||||
if (strcmp (interface, "wl_compositor") == 0)
|
||||
{
|
||||
@ -159,7 +161,7 @@ wayland_display_new (WaylandDisplayCapabilities capabilities)
|
||||
{
|
||||
WaylandDisplay *display;
|
||||
|
||||
display = g_new0 (WaylandDisplay, 1);
|
||||
display = g_object_new (wayland_display_get_type (), NULL);
|
||||
|
||||
display->capabilities = capabilities;
|
||||
display->display = wl_display_connect (NULL);
|
||||
@ -182,9 +184,25 @@ wayland_display_new (WaylandDisplayCapabilities capabilities)
|
||||
return display;
|
||||
}
|
||||
|
||||
void
|
||||
wayland_display_free (WaylandDisplay *display)
|
||||
static void
|
||||
wayland_display_finalize (GObject *object)
|
||||
{
|
||||
WaylandDisplay *display = WAYLAND_DISPLAY (object);
|
||||
|
||||
wl_display_disconnect (display->display);
|
||||
g_free (display);
|
||||
|
||||
G_OBJECT_CLASS (wayland_display_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
wayland_display_class_init (WaylandDisplayClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = wayland_display_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
wayland_display_init (WaylandDisplay *display)
|
||||
{
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef WAYLAND_TEST_CLIENT_UTILS_H
|
||||
#define WAYLAND_TEST_CLIENT_UTILS_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <stdio.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
@ -15,6 +16,8 @@ typedef enum _WaylandDisplayCapabilities
|
||||
|
||||
typedef struct _WaylandDisplay
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
WaylandDisplayCapabilities capabilities;
|
||||
|
||||
struct wl_display *display;
|
||||
@ -26,10 +29,12 @@ typedef struct _WaylandDisplay
|
||||
struct test_driver *test_driver;
|
||||
} WaylandDisplay;
|
||||
|
||||
G_DECLARE_FINAL_TYPE (WaylandDisplay, wayland_display,
|
||||
WAYLAND, DISPLAY,
|
||||
GObject)
|
||||
|
||||
int create_anonymous_file (off_t size);
|
||||
|
||||
WaylandDisplay * wayland_display_new (WaylandDisplayCapabilities capabilities);
|
||||
|
||||
void wayland_display_free (WaylandDisplay *display);
|
||||
|
||||
#endif /* WAYLAND_TEST_CLIENT_UTILS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user