mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
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 "wayland-test-client-utils.h"
|
||||||
|
|
||||||
#include "xdg-shell-client-protocol.h"
|
|
||||||
|
|
||||||
static WaylandDisplay *display;
|
static WaylandDisplay *display;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -40,7 +38,7 @@ connect_to_display (void)
|
|||||||
static void
|
static void
|
||||||
clean_up_display (void)
|
clean_up_display (void)
|
||||||
{
|
{
|
||||||
g_clear_pointer (&display, wayland_display_free);
|
g_clear_object (&display);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -207,7 +207,7 @@ test_empty_window_geometry (void)
|
|||||||
|
|
||||||
g_clear_pointer (&xdg_toplevel, xdg_toplevel_destroy);
|
g_clear_pointer (&xdg_toplevel, xdg_toplevel_destroy);
|
||||||
g_clear_pointer (&xdg_surface, xdg_surface_destroy);
|
g_clear_pointer (&xdg_surface, xdg_surface_destroy);
|
||||||
g_clear_pointer (&display, wayland_display_free);
|
g_clear_object (&display);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -66,6 +66,7 @@ foreach test : wayland_test_clients
|
|||||||
c_args: tests_c_args,
|
c_args: tests_c_args,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
glib_dep,
|
glib_dep,
|
||||||
|
gobject_dep,
|
||||||
wayland_client_dep,
|
wayland_client_dep,
|
||||||
],
|
],
|
||||||
install: have_installed_tests,
|
install: have_installed_tests,
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (WaylandDisplay, wayland_display, G_TYPE_OBJECT)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
create_tmpfile_cloexec (char *tmpname)
|
create_tmpfile_cloexec (char *tmpname)
|
||||||
{
|
{
|
||||||
@ -107,7 +109,7 @@ handle_registry_global (void *user_data,
|
|||||||
const char *interface,
|
const char *interface,
|
||||||
uint32_t version)
|
uint32_t version)
|
||||||
{
|
{
|
||||||
WaylandDisplay *display = user_data;
|
WaylandDisplay *display = WAYLAND_DISPLAY (user_data);
|
||||||
|
|
||||||
if (strcmp (interface, "wl_compositor") == 0)
|
if (strcmp (interface, "wl_compositor") == 0)
|
||||||
{
|
{
|
||||||
@ -159,7 +161,7 @@ wayland_display_new (WaylandDisplayCapabilities capabilities)
|
|||||||
{
|
{
|
||||||
WaylandDisplay *display;
|
WaylandDisplay *display;
|
||||||
|
|
||||||
display = g_new0 (WaylandDisplay, 1);
|
display = g_object_new (wayland_display_get_type (), NULL);
|
||||||
|
|
||||||
display->capabilities = capabilities;
|
display->capabilities = capabilities;
|
||||||
display->display = wl_display_connect (NULL);
|
display->display = wl_display_connect (NULL);
|
||||||
@ -182,9 +184,25 @@ wayland_display_new (WaylandDisplayCapabilities capabilities)
|
|||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
wayland_display_free (WaylandDisplay *display)
|
wayland_display_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
|
WaylandDisplay *display = WAYLAND_DISPLAY (object);
|
||||||
|
|
||||||
wl_display_disconnect (display->display);
|
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
|
#ifndef WAYLAND_TEST_CLIENT_UTILS_H
|
||||||
#define WAYLAND_TEST_CLIENT_UTILS_H
|
#define WAYLAND_TEST_CLIENT_UTILS_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
|
||||||
@ -15,6 +16,8 @@ typedef enum _WaylandDisplayCapabilities
|
|||||||
|
|
||||||
typedef struct _WaylandDisplay
|
typedef struct _WaylandDisplay
|
||||||
{
|
{
|
||||||
|
GObject parent;
|
||||||
|
|
||||||
WaylandDisplayCapabilities capabilities;
|
WaylandDisplayCapabilities capabilities;
|
||||||
|
|
||||||
struct wl_display *display;
|
struct wl_display *display;
|
||||||
@ -26,10 +29,12 @@ typedef struct _WaylandDisplay
|
|||||||
struct test_driver *test_driver;
|
struct test_driver *test_driver;
|
||||||
} WaylandDisplay;
|
} WaylandDisplay;
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (WaylandDisplay, wayland_display,
|
||||||
|
WAYLAND, DISPLAY,
|
||||||
|
GObject)
|
||||||
|
|
||||||
int create_anonymous_file (off_t size);
|
int create_anonymous_file (off_t size);
|
||||||
|
|
||||||
WaylandDisplay * wayland_display_new (WaylandDisplayCapabilities capabilities);
|
WaylandDisplay * wayland_display_new (WaylandDisplayCapabilities capabilities);
|
||||||
|
|
||||||
void wayland_display_free (WaylandDisplay *display);
|
|
||||||
|
|
||||||
#endif /* WAYLAND_TEST_CLIENT_UTILS_H */
|
#endif /* WAYLAND_TEST_CLIENT_UTILS_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user