mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 12:52:14 +00:00
tests/wayland-test-clients: Make WaylandSurface a GObject
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3350>
This commit is contained in:
parent
cceccc0f68
commit
8e7600322b
@ -93,6 +93,6 @@ main (int argc,
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
wayland_surface_free (surface);
|
||||
g_object_unref (surface);
|
||||
g_object_unref (display);
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ G_DEFINE_TYPE (WaylandDisplay,
|
||||
wayland_display,
|
||||
G_TYPE_OBJECT)
|
||||
|
||||
G_DEFINE_TYPE (WaylandSurface,
|
||||
wayland_surface,
|
||||
G_TYPE_OBJECT)
|
||||
|
||||
static int
|
||||
create_tmpfile_cloexec (char *tmpname)
|
||||
{
|
||||
@ -450,6 +454,31 @@ static const struct xdg_surface_listener xdg_surface_listener = {
|
||||
handle_xdg_surface_configure,
|
||||
};
|
||||
|
||||
static void
|
||||
wayland_surface_dispose (GObject *object)
|
||||
{
|
||||
WaylandSurface *surface = WAYLAND_SURFACE (object);
|
||||
|
||||
g_clear_pointer (&surface->xdg_toplevel, xdg_toplevel_destroy);
|
||||
g_clear_pointer (&surface->xdg_surface, xdg_surface_destroy);
|
||||
g_clear_pointer (&surface->wl_surface, wl_surface_destroy);
|
||||
|
||||
G_OBJECT_CLASS (wayland_surface_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
wayland_surface_class_init (WaylandSurfaceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = wayland_surface_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
wayland_surface_init (WaylandSurface *surface)
|
||||
{
|
||||
}
|
||||
|
||||
WaylandSurface *
|
||||
wayland_surface_new (WaylandDisplay *display,
|
||||
const char *title,
|
||||
@ -459,7 +488,8 @@ wayland_surface_new (WaylandDisplay *display,
|
||||
{
|
||||
WaylandSurface *surface;
|
||||
|
||||
surface = g_new0 (WaylandSurface, 1);
|
||||
surface = g_object_new (WAYLAND_TYPE_SURFACE, NULL);
|
||||
|
||||
surface->display = display;
|
||||
surface->default_width = default_width;
|
||||
surface->default_height = default_height;
|
||||
@ -477,15 +507,6 @@ wayland_surface_new (WaylandDisplay *display,
|
||||
return surface;
|
||||
}
|
||||
|
||||
void
|
||||
wayland_surface_free (WaylandSurface *surface)
|
||||
{
|
||||
g_clear_pointer (&surface->xdg_toplevel, xdg_toplevel_destroy);
|
||||
g_clear_pointer (&surface->xdg_surface, xdg_surface_destroy);
|
||||
g_clear_pointer (&surface->wl_surface, wl_surface_destroy);
|
||||
g_free (surface);
|
||||
}
|
||||
|
||||
const char *
|
||||
lookup_property_value (WaylandDisplay *display,
|
||||
const char *name)
|
||||
|
@ -60,6 +60,11 @@ typedef struct _WaylandSurface
|
||||
uint32_t color;
|
||||
} WaylandSurface;
|
||||
|
||||
#define WAYLAND_TYPE_SURFACE (wayland_surface_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (WaylandSurface, wayland_surface,
|
||||
WAYLAND, SURFACE,
|
||||
GObject)
|
||||
|
||||
int create_anonymous_file (off_t size);
|
||||
|
||||
WaylandDisplay * wayland_display_new (WaylandDisplayCapabilities capabilities);
|
||||
@ -73,8 +78,6 @@ WaylandSurface * wayland_surface_new (WaylandDisplay *display,
|
||||
int default_height,
|
||||
uint32_t color);
|
||||
|
||||
void wayland_surface_free (WaylandSurface *surface);
|
||||
|
||||
gboolean create_shm_buffer (WaylandDisplay *display,
|
||||
int width,
|
||||
int height,
|
||||
|
@ -130,10 +130,10 @@ int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
WaylandSurface *window1;
|
||||
WaylandSurface *window2;
|
||||
WaylandSurface *window3;
|
||||
WaylandSurface *window4;
|
||||
g_autoptr (WaylandSurface) window1;
|
||||
g_autoptr (WaylandSurface) window2;
|
||||
g_autoptr (WaylandSurface) window3;
|
||||
g_autoptr (WaylandSurface) window4;
|
||||
g_autofree char *handle1 = NULL;
|
||||
g_autofree char *handle3 = NULL;
|
||||
struct wl_registry *registry;
|
||||
@ -222,11 +222,6 @@ main (int argc,
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
wayland_surface_free (window1);
|
||||
wayland_surface_free (window2);
|
||||
wayland_surface_free (window3);
|
||||
wayland_surface_free (window4);
|
||||
|
||||
g_object_unref (display);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user