/* screen-overlay-manager.c generated by valac 0.56.19, the Vala compiler
 * generated from screen-overlay-manager.vala, do not modify */

/*
 * Copyright (c) 2026 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_core.h"
#include <glib.h>
#include <glib-object.h>
#include <string.h>

#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

enum  {
	FT_SCREEN_OVERLAY_PROVIDER_OPENED_SIGNAL,
	FT_SCREEN_OVERLAY_PROVIDER_CLOSED_SIGNAL,
	FT_SCREEN_OVERLAY_PROVIDER_NUM_SIGNALS
};
static guint ft_screen_overlay_provider_signals[FT_SCREEN_OVERLAY_PROVIDER_NUM_SIGNALS] = {0};
enum  {
	FT_SCREEN_OVERLAY_MANAGER_0_PROPERTY,
	FT_SCREEN_OVERLAY_MANAGER_PROVIDER_PROPERTY,
	FT_SCREEN_OVERLAY_MANAGER_NUM_PROPERTIES
};
static GParamSpec* ft_screen_overlay_manager_properties[FT_SCREEN_OVERLAY_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _FtScreenOverlayManagerPrivate {
	FtProviderSet* providers;
	FtScreenOverlayProvider* _provider;
	FtNotificationManager* notification_manager;
};

static gint FtScreenOverlayManager_private_offset;
static gpointer ft_screen_overlay_manager_parent_class = NULL;

static GType ft_screen_overlay_provider_get_type_once (void);
static void ft_screen_overlay_manager_on_request_screen_overlay_open (FtScreenOverlayManager* self);
static void ft_screen_overlay_manager_on_request_screen_overlay_close (FtScreenOverlayManager* self);
static void ft_screen_overlay_manager_on_screen_overlay_opened (FtScreenOverlayManager* self,
                                                         FtScreenOverlayProvider* provider);
static void ft_screen_overlay_manager_on_screen_overlay_closed (FtScreenOverlayManager* self,
                                                         FtScreenOverlayProvider* provider);
static void ft_screen_overlay_manager_on_provider_selected (FtScreenOverlayManager* self,
                                                     FtScreenOverlayProvider* provider);
static void _ft_screen_overlay_manager_on_screen_overlay_opened_ft_screen_overlay_provider_opened (FtScreenOverlayProvider* _sender,
                                                                                            gpointer self);
static void _ft_screen_overlay_manager_on_screen_overlay_closed_ft_screen_overlay_provider_closed (FtScreenOverlayProvider* _sender,
                                                                                            gpointer self);
static void ft_screen_overlay_manager_on_provider_unselected (FtScreenOverlayManager* self,
                                                       FtScreenOverlayProvider* provider);
static void ft_screen_overlay_manager_real_dispose (GObject* base);
static void _ft_screen_overlay_manager_on_request_screen_overlay_open_ft_notification_manager_request_screen_overlay_open (FtNotificationManager* _sender,
                                                                                                                    gpointer self);
static void _ft_screen_overlay_manager_on_request_screen_overlay_close_ft_notification_manager_request_screen_overlay_close (FtNotificationManager* _sender,
                                                                                                                      gpointer self);
static GObject * ft_screen_overlay_manager_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void _ft_screen_overlay_manager_on_provider_selected_ft_provider_set_provider_selected (FtProviderSet* _sender,
                                                                                        gconstpointer provider,
                                                                                        gpointer self);
static void _ft_screen_overlay_manager_on_provider_unselected_ft_provider_set_provider_unselected (FtProviderSet* _sender,
                                                                                            gconstpointer provider,
                                                                                            gpointer self);
static void ft_screen_overlay_manager_finalize (GObject * obj);
static GType ft_screen_overlay_manager_get_type_once (void);
static void _vala_ft_screen_overlay_manager_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
ft_screen_overlay_provider_open (FtScreenOverlayProvider* self)
{
	FtScreenOverlayProviderIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = FT_SCREEN_OVERLAY_PROVIDER_GET_INTERFACE (self);
	if (_iface_->open) {
		_iface_->open (self);
	}
}

void
ft_screen_overlay_provider_close (FtScreenOverlayProvider* self)
{
	FtScreenOverlayProviderIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = FT_SCREEN_OVERLAY_PROVIDER_GET_INTERFACE (self);
	if (_iface_->close) {
		_iface_->close (self);
	}
}

static void
ft_screen_overlay_provider_default_init (FtScreenOverlayProviderIface * iface,
                                         gpointer iface_data)
{
	ft_screen_overlay_provider_signals[FT_SCREEN_OVERLAY_PROVIDER_OPENED_SIGNAL] = g_signal_new ("opened", FT_TYPE_SCREEN_OVERLAY_PROVIDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	ft_screen_overlay_provider_signals[FT_SCREEN_OVERLAY_PROVIDER_CLOSED_SIGNAL] = g_signal_new ("closed", FT_TYPE_SCREEN_OVERLAY_PROVIDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static GType
ft_screen_overlay_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtScreenOverlayProviderIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_screen_overlay_provider_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType ft_screen_overlay_provider_type_id;
	ft_screen_overlay_provider_type_id = g_type_register_static (G_TYPE_INTERFACE, "FtScreenOverlayProvider", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (ft_screen_overlay_provider_type_id, FT_TYPE_PROVIDER);
	return ft_screen_overlay_provider_type_id;
}

GType
ft_screen_overlay_provider_get_type (void)
{
	static volatile gsize ft_screen_overlay_provider_type_id__once = 0;
	if (g_once_init_enter (&ft_screen_overlay_provider_type_id__once)) {
		GType ft_screen_overlay_provider_type_id;
		ft_screen_overlay_provider_type_id = ft_screen_overlay_provider_get_type_once ();
		g_once_init_leave (&ft_screen_overlay_provider_type_id__once, ft_screen_overlay_provider_type_id);
	}
	return ft_screen_overlay_provider_type_id__once;
}

static inline gpointer
ft_screen_overlay_manager_get_instance_private (FtScreenOverlayManager* self)
{
	return G_STRUCT_MEMBER_P (self, FtScreenOverlayManager_private_offset);
}

void
ft_screen_overlay_manager_add_provider (FtScreenOverlayManager* self,
                                        FtScreenOverlayProvider* provider,
                                        FtPriority priority)
{
	FtProviderSet* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (provider != NULL);
	_tmp0_ = self->priv->providers;
	ft_provider_set_add (_tmp0_, provider, priority);
}

void
ft_screen_overlay_manager_open (FtScreenOverlayManager* self)
{
	FtScreenOverlayProvider* _tmp0_ = NULL;
	FtScreenOverlayProvider* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->_provider;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ft_screen_overlay_provider_open (_tmp0_);
	}
}

void
ft_screen_overlay_manager_close (FtScreenOverlayManager* self)
{
	FtScreenOverlayProvider* _tmp0_ = NULL;
	FtScreenOverlayProvider* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->_provider;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ft_screen_overlay_provider_close (_tmp0_);
	}
}

static void
ft_screen_overlay_manager_on_request_screen_overlay_open (FtScreenOverlayManager* self)
{
	g_return_if_fail (self != NULL);
	ft_screen_overlay_manager_open (self);
}

static void
ft_screen_overlay_manager_on_request_screen_overlay_close (FtScreenOverlayManager* self)
{
	g_return_if_fail (self != NULL);
	ft_screen_overlay_manager_close (self);
}

static void
ft_screen_overlay_manager_on_screen_overlay_opened (FtScreenOverlayManager* self,
                                                    FtScreenOverlayProvider* provider)
{
	FtNotificationManager* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (provider != NULL);
	_tmp0_ = self->priv->notification_manager;
	ft_notification_manager_emit_screen_overlay_opened (_tmp0_);
}

static void
ft_screen_overlay_manager_on_screen_overlay_closed (FtScreenOverlayManager* self,
                                                    FtScreenOverlayProvider* provider)
{
	FtNotificationManager* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (provider != NULL);
	_tmp0_ = self->priv->notification_manager;
	ft_notification_manager_emit_screen_overlay_closed (_tmp0_);
}

static void
_ft_screen_overlay_manager_on_screen_overlay_opened_ft_screen_overlay_provider_opened (FtScreenOverlayProvider* _sender,
                                                                                       gpointer self)
{
	ft_screen_overlay_manager_on_screen_overlay_opened ((FtScreenOverlayManager*) self, _sender);
}

static void
_ft_screen_overlay_manager_on_screen_overlay_closed_ft_screen_overlay_provider_closed (FtScreenOverlayProvider* _sender,
                                                                                       gpointer self)
{
	ft_screen_overlay_manager_on_screen_overlay_closed ((FtScreenOverlayManager*) self, _sender);
}

static void
ft_screen_overlay_manager_on_provider_selected (FtScreenOverlayManager* self,
                                                FtScreenOverlayProvider* provider)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (provider != NULL);
	g_signal_connect_object (provider, "opened", (GCallback) _ft_screen_overlay_manager_on_screen_overlay_opened_ft_screen_overlay_provider_opened, self, 0);
	g_signal_connect_object (provider, "closed", (GCallback) _ft_screen_overlay_manager_on_screen_overlay_closed_ft_screen_overlay_provider_closed, self, 0);
	self->priv->_provider = provider;
	g_object_notify ((GObject*) self, "provider");
}

static void
ft_screen_overlay_manager_on_provider_unselected (FtScreenOverlayManager* self,
                                                  FtScreenOverlayProvider* provider)
{
	guint _tmp0_;
	guint _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (provider != NULL);
	g_signal_parse_name ("opened", FT_TYPE_SCREEN_OVERLAY_PROVIDER, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _ft_screen_overlay_manager_on_screen_overlay_opened_ft_screen_overlay_provider_opened, self);
	g_signal_parse_name ("closed", FT_TYPE_SCREEN_OVERLAY_PROVIDER, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _ft_screen_overlay_manager_on_screen_overlay_closed_ft_screen_overlay_provider_closed, self);
}

static void
_ft_screen_overlay_manager_on_request_screen_overlay_open_ft_notification_manager_request_screen_overlay_open (FtNotificationManager* _sender,
                                                                                                               gpointer self)
{
	ft_screen_overlay_manager_on_request_screen_overlay_open ((FtScreenOverlayManager*) self);
}

static void
_ft_screen_overlay_manager_on_request_screen_overlay_close_ft_notification_manager_request_screen_overlay_close (FtNotificationManager* _sender,
                                                                                                                 gpointer self)
{
	ft_screen_overlay_manager_on_request_screen_overlay_close ((FtScreenOverlayManager*) self);
}

static void
ft_screen_overlay_manager_real_dispose (GObject* base)
{
	FtScreenOverlayManager * self;
	FtNotificationManager* _tmp0_;
	self = (FtScreenOverlayManager*) base;
	_tmp0_ = self->priv->notification_manager;
	if (_tmp0_ != NULL) {
		FtNotificationManager* _tmp1_;
		guint _tmp2_;
		FtNotificationManager* _tmp3_;
		guint _tmp4_;
		_tmp1_ = self->priv->notification_manager;
		g_signal_parse_name ("request-screen-overlay-open", FT_TYPE_NOTIFICATION_MANAGER, &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_screen_overlay_manager_on_request_screen_overlay_open_ft_notification_manager_request_screen_overlay_open, self);
		_tmp3_ = self->priv->notification_manager;
		g_signal_parse_name ("request-screen-overlay-close", FT_TYPE_NOTIFICATION_MANAGER, &_tmp4_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp3_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _ft_screen_overlay_manager_on_request_screen_overlay_close_ft_notification_manager_request_screen_overlay_close, self);
		_g_object_unref0 (self->priv->notification_manager);
		self->priv->notification_manager = NULL;
	}
	self->priv->_provider = NULL;
	_g_object_unref0 (self->priv->providers);
	self->priv->providers = NULL;
	G_OBJECT_CLASS (ft_screen_overlay_manager_parent_class)->dispose (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject));
}

FtScreenOverlayManager*
ft_screen_overlay_manager_construct (GType object_type)
{
	FtScreenOverlayManager * self = NULL;
	self = (FtScreenOverlayManager*) g_object_new (object_type, NULL);
	return self;
}

FtScreenOverlayManager*
ft_screen_overlay_manager_new (void)
{
	return ft_screen_overlay_manager_construct (FT_TYPE_SCREEN_OVERLAY_MANAGER);
}

FtScreenOverlayProvider*
ft_screen_overlay_manager_get_provider (FtScreenOverlayManager* self)
{
	FtScreenOverlayProvider* result;
	FtScreenOverlayProvider* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_provider;
	result = _tmp0_;
	return result;
}

static void
_ft_screen_overlay_manager_on_provider_selected_ft_provider_set_provider_selected (FtProviderSet* _sender,
                                                                                   gconstpointer provider,
                                                                                   gpointer self)
{
	ft_screen_overlay_manager_on_provider_selected ((FtScreenOverlayManager*) self, (FtScreenOverlayProvider*) provider);
}

static void
_ft_screen_overlay_manager_on_provider_unselected_ft_provider_set_provider_unselected (FtProviderSet* _sender,
                                                                                       gconstpointer provider,
                                                                                       gpointer self)
{
	ft_screen_overlay_manager_on_provider_unselected ((FtScreenOverlayManager*) self, (FtScreenOverlayProvider*) provider);
}

static GObject *
ft_screen_overlay_manager_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	static GWeakRef FtScreenOverlayManager_singleton__ref;
	static GMutex FtScreenOverlayManager_singleton__lock;
	FtScreenOverlayManager * self;
	FtNotificationManager* _tmp0_;
	FtNotificationManager* _tmp1_;
	FtNotificationManager* _tmp2_;
	FtProviderSet* _tmp3_;
	FtProviderSet* _tmp4_;
	FtProviderSet* _tmp5_;
	FtProviderSet* _tmp6_;
	FtProviderSet* _tmp7_;
	g_mutex_lock (&FtScreenOverlayManager_singleton__lock);
	obj = g_weak_ref_get (&FtScreenOverlayManager_singleton__ref);
	if (obj != NULL) {
		g_mutex_unlock (&FtScreenOverlayManager_singleton__lock);
		return obj;
	}
	parent_class = G_OBJECT_CLASS (ft_screen_overlay_manager_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SCREEN_OVERLAY_MANAGER, FtScreenOverlayManager);
	_tmp0_ = ft_notification_manager_new ();
	_g_object_unref0 (self->priv->notification_manager);
	self->priv->notification_manager = _tmp0_;
	_tmp1_ = self->priv->notification_manager;
	g_signal_connect_object (_tmp1_, "request-screen-overlay-open", (GCallback) _ft_screen_overlay_manager_on_request_screen_overlay_open_ft_notification_manager_request_screen_overlay_open, self, 0);
	_tmp2_ = self->priv->notification_manager;
	g_signal_connect_object (_tmp2_, "request-screen-overlay-close", (GCallback) _ft_screen_overlay_manager_on_request_screen_overlay_close_ft_notification_manager_request_screen_overlay_close, self, 0);
	_tmp3_ = ft_provider_set_new (FT_TYPE_SCREEN_OVERLAY_PROVIDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, FT_SELECTION_MODE_SINGLE);
	_g_object_unref0 (self->priv->providers);
	self->priv->providers = _tmp3_;
	_tmp4_ = self->priv->providers;
	g_signal_connect_object (_tmp4_, "provider-selected", (GCallback) _ft_screen_overlay_manager_on_provider_selected_ft_provider_set_provider_selected, self, 0);
	_tmp5_ = self->priv->providers;
	g_signal_connect_object (_tmp5_, "provider-unselected", (GCallback) _ft_screen_overlay_manager_on_provider_unselected_ft_provider_set_provider_unselected, self, 0);
	_tmp6_ = self->priv->providers;
	ft_provider_set_discover (_tmp6_);
	_tmp7_ = self->priv->providers;
	ft_provider_set_enable (_tmp7_);
	g_weak_ref_set (&FtScreenOverlayManager_singleton__ref, obj);
	g_mutex_unlock (&FtScreenOverlayManager_singleton__lock);
	return obj;
}

static void
ft_screen_overlay_manager_class_init (FtScreenOverlayManagerClass * klass,
                                      gpointer klass_data)
{
	ft_screen_overlay_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtScreenOverlayManager_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_screen_overlay_manager_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_screen_overlay_manager_get_property;
	G_OBJECT_CLASS (klass)->constructor = ft_screen_overlay_manager_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_screen_overlay_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SCREEN_OVERLAY_MANAGER_PROVIDER_PROPERTY, ft_screen_overlay_manager_properties[FT_SCREEN_OVERLAY_MANAGER_PROVIDER_PROPERTY] = g_param_spec_object ("provider", "provider", "provider", FT_TYPE_SCREEN_OVERLAY_PROVIDER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
ft_screen_overlay_manager_instance_init (FtScreenOverlayManager * self,
                                         gpointer klass)
{
	self->priv = ft_screen_overlay_manager_get_instance_private (self);
	self->priv->providers = NULL;
	self->priv->_provider = NULL;
	self->priv->notification_manager = NULL;
}

static void
ft_screen_overlay_manager_finalize (GObject * obj)
{
	FtScreenOverlayManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SCREEN_OVERLAY_MANAGER, FtScreenOverlayManager);
	_g_object_unref0 (self->priv->providers);
	_g_object_unref0 (self->priv->notification_manager);
	G_OBJECT_CLASS (ft_screen_overlay_manager_parent_class)->finalize (obj);
}

/**
     * A helper primitive for representing the screen overlay.
     * The actual logic for showing/hiding the overlay is in `Ft.NotificationManager`.
     */
static GType
ft_screen_overlay_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtScreenOverlayManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_screen_overlay_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtScreenOverlayManager), 0, (GInstanceInitFunc) ft_screen_overlay_manager_instance_init, NULL };
	GType ft_screen_overlay_manager_type_id;
	ft_screen_overlay_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "FtScreenOverlayManager", &g_define_type_info, 0);
	FtScreenOverlayManager_private_offset = g_type_add_instance_private (ft_screen_overlay_manager_type_id, sizeof (FtScreenOverlayManagerPrivate));
	return ft_screen_overlay_manager_type_id;
}

GType
ft_screen_overlay_manager_get_type (void)
{
	static volatile gsize ft_screen_overlay_manager_type_id__once = 0;
	if (g_once_init_enter (&ft_screen_overlay_manager_type_id__once)) {
		GType ft_screen_overlay_manager_type_id;
		ft_screen_overlay_manager_type_id = ft_screen_overlay_manager_get_type_once ();
		g_once_init_leave (&ft_screen_overlay_manager_type_id__once, ft_screen_overlay_manager_type_id);
	}
	return ft_screen_overlay_manager_type_id__once;
}

static void
_vala_ft_screen_overlay_manager_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	FtScreenOverlayManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SCREEN_OVERLAY_MANAGER, FtScreenOverlayManager);
	switch (property_id) {
		case FT_SCREEN_OVERLAY_MANAGER_PROVIDER_PROPERTY:
		g_value_set_object (value, ft_screen_overlay_manager_get_provider (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

