/* NotificationsClient.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from NotificationsClient.vala, do not modify */

/*
 * Copyright 2024-2025 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <meta/display.h>
#include <meta/window.h>
#include <meta/meta-wayland-client.h>

#define NOTIFICATION_DATA_KEY "elementary-notification"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT (greeter_compositor_notifications_client_get_type ())
#define GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, GreeterCompositorNotificationsClient))
#define GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, GreeterCompositorNotificationsClientClass))
#define GREETER_COMPOSITOR_IS_NOTIFICATIONS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT))
#define GREETER_COMPOSITOR_IS_NOTIFICATIONS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT))
#define GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, GreeterCompositorNotificationsClientClass))

typedef struct _GreeterCompositorNotificationsClient GreeterCompositorNotificationsClient;
typedef struct _GreeterCompositorNotificationsClientClass GreeterCompositorNotificationsClientClass;
typedef struct _GreeterCompositorNotificationsClientPrivate GreeterCompositorNotificationsClientPrivate;

#define GREETER_COMPOSITOR_TYPE_MANAGED_CLIENT (greeter_compositor_managed_client_get_type ())
#define GREETER_COMPOSITOR_MANAGED_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GREETER_COMPOSITOR_TYPE_MANAGED_CLIENT, GreeterCompositorManagedClient))
#define GREETER_COMPOSITOR_MANAGED_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GREETER_COMPOSITOR_TYPE_MANAGED_CLIENT, GreeterCompositorManagedClientClass))
#define GREETER_COMPOSITOR_IS_MANAGED_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GREETER_COMPOSITOR_TYPE_MANAGED_CLIENT))
#define GREETER_COMPOSITOR_IS_MANAGED_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GREETER_COMPOSITOR_TYPE_MANAGED_CLIENT))
#define GREETER_COMPOSITOR_MANAGED_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GREETER_COMPOSITOR_TYPE_MANAGED_CLIENT, GreeterCompositorManagedClientClass))

typedef struct _GreeterCompositorManagedClient GreeterCompositorManagedClient;
typedef struct _GreeterCompositorManagedClientClass GreeterCompositorManagedClientClass;
enum  {
	GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_0_PROPERTY,
	GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY,
	GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_NUM_PROPERTIES
};
static GParamSpec* greeter_compositor_notifications_client_properties[GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GreeterCompositorNotificationsClient {
	GObject parent_instance;
	GreeterCompositorNotificationsClientPrivate * priv;
};

struct _GreeterCompositorNotificationsClientClass {
	GObjectClass parent_class;
};

struct _GreeterCompositorNotificationsClientPrivate {
	MetaDisplay* _display;
	GreeterCompositorManagedClient* client;
};

static gint GreeterCompositorNotificationsClient_private_offset;
static gpointer greeter_compositor_notifications_client_parent_class = NULL;

VALA_EXTERN GType greeter_compositor_notifications_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterCompositorNotificationsClient, g_object_unref)
VALA_EXTERN GType greeter_compositor_managed_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GreeterCompositorManagedClient, g_object_unref)
VALA_EXTERN GreeterCompositorNotificationsClient* greeter_compositor_notifications_client_new (MetaDisplay* display);
VALA_EXTERN GreeterCompositorNotificationsClient* greeter_compositor_notifications_client_construct (GType object_type,
                                                                                         MetaDisplay* display);
VALA_EXTERN MetaDisplay* greeter_compositor_notifications_client_get_display (GreeterCompositorNotificationsClient* self);
static void greeter_compositor_notifications_client_set_display (GreeterCompositorNotificationsClient* self,
                                                          MetaDisplay* value);
static GObject * greeter_compositor_notifications_client_constructor (GType type,
                                                               guint n_construct_properties,
                                                               GObjectConstructParam * construct_properties);
VALA_EXTERN GreeterCompositorManagedClient* greeter_compositor_managed_client_new (MetaDisplay* display,
                                                                       gchar** args,
                                                                       gint args_length1);
VALA_EXTERN GreeterCompositorManagedClient* greeter_compositor_managed_client_construct (GType object_type,
                                                                             MetaDisplay* display,
                                                                             gchar** args,
                                                                             gint args_length1);
static void _greeter_compositor_notifications_client___lambda85_ (GreeterCompositorNotificationsClient* self,
                                                           MetaWindow* window);
VALA_EXTERN MetaWaylandClient* greeter_compositor_managed_client_get_wayland_client (GreeterCompositorManagedClient* self);
static void __greeter_compositor_notifications_client___lambda85__greeter_compositor_managed_client_window_created (GreeterCompositorManagedClient* _sender,
                                                                                                             MetaWindow* window,
                                                                                                             gpointer self);
static void greeter_compositor_notifications_client_finalize (GObject * obj);
static GType greeter_compositor_notifications_client_get_type_once (void);
static void _vala_greeter_compositor_notifications_client_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec);
static void _vala_greeter_compositor_notifications_client_set_property (GObject * object,
                                                                 guint property_id,
                                                                 const GValue * value,
                                                                 GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
greeter_compositor_notifications_client_get_instance_private (GreeterCompositorNotificationsClient* self)
{
	return G_STRUCT_MEMBER_P (self, GreeterCompositorNotificationsClient_private_offset);
}

GreeterCompositorNotificationsClient*
greeter_compositor_notifications_client_construct (GType object_type,
                                                   MetaDisplay* display)
{
	GreeterCompositorNotificationsClient * self = NULL;
	g_return_val_if_fail (display != NULL, NULL);
	self = (GreeterCompositorNotificationsClient*) g_object_new (object_type, "display", display, NULL);
	return self;
}

GreeterCompositorNotificationsClient*
greeter_compositor_notifications_client_new (MetaDisplay* display)
{
	return greeter_compositor_notifications_client_construct (GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, display);
}

MetaDisplay*
greeter_compositor_notifications_client_get_display (GreeterCompositorNotificationsClient* self)
{
	MetaDisplay* result;
	MetaDisplay* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_display;
	result = _tmp0_;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
greeter_compositor_notifications_client_set_display (GreeterCompositorNotificationsClient* self,
                                                     MetaDisplay* value)
{
	MetaDisplay* old_value;
	g_return_if_fail (self != NULL);
	old_value = greeter_compositor_notifications_client_get_display (self);
	if (old_value != value) {
		MetaDisplay* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_display);
		self->priv->_display = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, greeter_compositor_notifications_client_properties[GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY]);
	}
}

static void
_greeter_compositor_notifications_client___lambda85_ (GreeterCompositorNotificationsClient* self,
                                                      MetaWindow* window)
{
	GreeterCompositorManagedClient* _tmp0_;
	MetaWaylandClient* _tmp1_;
	MetaWaylandClient* _tmp2_;
	g_return_if_fail (window != NULL);
	g_object_set_data_full ((GObject*) window, NOTIFICATION_DATA_KEY, (gpointer) ((gintptr) TRUE), NULL);
	meta_window_make_above (window);
	meta_window_stick (window);
	_tmp0_ = self->priv->client;
	_tmp1_ = greeter_compositor_managed_client_get_wayland_client (_tmp0_);
	_tmp2_ = _tmp1_;
	meta_wayland_client_make_dock (_tmp2_, window);
}

static void
__greeter_compositor_notifications_client___lambda85__greeter_compositor_managed_client_window_created (GreeterCompositorManagedClient* _sender,
                                                                                                        MetaWindow* window,
                                                                                                        gpointer self)
{
	_greeter_compositor_notifications_client___lambda85_ ((GreeterCompositorNotificationsClient*) self, window);
}

static GObject *
greeter_compositor_notifications_client_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GreeterCompositorNotificationsClient * self;
	MetaDisplay* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	GreeterCompositorManagedClient* _tmp4_;
	GreeterCompositorManagedClient* _tmp5_;
	parent_class = G_OBJECT_CLASS (greeter_compositor_notifications_client_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, GreeterCompositorNotificationsClient);
	_tmp0_ = self->priv->_display;
	_tmp1_ = g_strdup ("io.elementary.notifications");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	_tmp4_ = greeter_compositor_managed_client_new (_tmp0_, _tmp3_, 1);
	_g_object_unref0 (self->priv->client);
	self->priv->client = _tmp4_;
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	_tmp5_ = self->priv->client;
	g_signal_connect_object (_tmp5_, "window-created", (GCallback) __greeter_compositor_notifications_client___lambda85__greeter_compositor_managed_client_window_created, self, 0);
	return obj;
}

static void
greeter_compositor_notifications_client_class_init (GreeterCompositorNotificationsClientClass * klass,
                                                    gpointer klass_data)
{
	greeter_compositor_notifications_client_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GreeterCompositorNotificationsClient_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_greeter_compositor_notifications_client_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_greeter_compositor_notifications_client_set_property;
	G_OBJECT_CLASS (klass)->constructor = greeter_compositor_notifications_client_constructor;
	G_OBJECT_CLASS (klass)->finalize = greeter_compositor_notifications_client_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY, greeter_compositor_notifications_client_properties[GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY] = g_param_spec_object ("display", "display", "display", meta_display_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
greeter_compositor_notifications_client_instance_init (GreeterCompositorNotificationsClient * self,
                                                       gpointer klass)
{
	self->priv = greeter_compositor_notifications_client_get_instance_private (self);
}

static void
greeter_compositor_notifications_client_finalize (GObject * obj)
{
	GreeterCompositorNotificationsClient * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, GreeterCompositorNotificationsClient);
	_g_object_unref0 (self->priv->_display);
	_g_object_unref0 (self->priv->client);
	G_OBJECT_CLASS (greeter_compositor_notifications_client_parent_class)->finalize (obj);
}

static GType
greeter_compositor_notifications_client_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GreeterCompositorNotificationsClientClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) greeter_compositor_notifications_client_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GreeterCompositorNotificationsClient), 0, (GInstanceInitFunc) greeter_compositor_notifications_client_instance_init, NULL };
	GType greeter_compositor_notifications_client_type_id;
	greeter_compositor_notifications_client_type_id = g_type_register_static (G_TYPE_OBJECT, "GreeterCompositorNotificationsClient", &g_define_type_info, 0);
	GreeterCompositorNotificationsClient_private_offset = g_type_add_instance_private (greeter_compositor_notifications_client_type_id, sizeof (GreeterCompositorNotificationsClientPrivate));
	return greeter_compositor_notifications_client_type_id;
}

GType
greeter_compositor_notifications_client_get_type (void)
{
	static volatile gsize greeter_compositor_notifications_client_type_id__once = 0;
	if (g_once_init_enter (&greeter_compositor_notifications_client_type_id__once)) {
		GType greeter_compositor_notifications_client_type_id;
		greeter_compositor_notifications_client_type_id = greeter_compositor_notifications_client_get_type_once ();
		g_once_init_leave (&greeter_compositor_notifications_client_type_id__once, greeter_compositor_notifications_client_type_id);
	}
	return greeter_compositor_notifications_client_type_id__once;
}

static void
_vala_greeter_compositor_notifications_client_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec)
{
	GreeterCompositorNotificationsClient * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, GreeterCompositorNotificationsClient);
	switch (property_id) {
		case GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY:
		g_value_set_object (value, greeter_compositor_notifications_client_get_display (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_greeter_compositor_notifications_client_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec)
{
	GreeterCompositorNotificationsClient * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GREETER_COMPOSITOR_TYPE_NOTIFICATIONS_CLIENT, GreeterCompositorNotificationsClient);
	switch (property_id) {
		case GREETER_COMPOSITOR_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY:
		greeter_compositor_notifications_client_set_display (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

