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

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

#include <clutter/clutter.h>
#include <glib-object.h>
#include "gala.h"
#include <gee.h>
#include <glib.h>
#include <meta/meta-window-actor.h>
#include <meta/window.h>
#include <float.h>
#include <math.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
#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 GALA_TYPE_MODAL_GROUP (gala_modal_group_get_type ())
#define GALA_MODAL_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_MODAL_GROUP, GalaModalGroup))
#define GALA_MODAL_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_MODAL_GROUP, GalaModalGroupClass))
#define GALA_IS_MODAL_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_MODAL_GROUP))
#define GALA_IS_MODAL_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_MODAL_GROUP))
#define GALA_MODAL_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_MODAL_GROUP, GalaModalGroupClass))

typedef struct _GalaModalGroup GalaModalGroup;
typedef struct _GalaModalGroupClass GalaModalGroupClass;
typedef struct _GalaModalGroupPrivate GalaModalGroupPrivate;

#define GALA_TYPE_SHELL_CLIENTS_MANAGER (gala_shell_clients_manager_get_type ())
#define GALA_SHELL_CLIENTS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SHELL_CLIENTS_MANAGER, GalaShellClientsManager))
#define GALA_SHELL_CLIENTS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SHELL_CLIENTS_MANAGER, GalaShellClientsManagerClass))
#define GALA_IS_SHELL_CLIENTS_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SHELL_CLIENTS_MANAGER))
#define GALA_IS_SHELL_CLIENTS_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SHELL_CLIENTS_MANAGER))
#define GALA_SHELL_CLIENTS_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SHELL_CLIENTS_MANAGER, GalaShellClientsManagerClass))

typedef struct _GalaShellClientsManager GalaShellClientsManager;
typedef struct _GalaShellClientsManagerClass GalaShellClientsManagerClass;
enum  {
	GALA_MODAL_GROUP_0_PROPERTY,
	GALA_MODAL_GROUP_WM_PROPERTY,
	GALA_MODAL_GROUP_SHELL_CLIENTS_PROPERTY,
	GALA_MODAL_GROUP_WINDOW_GROUP_PROPERTY,
	GALA_MODAL_GROUP_NUM_PROPERTIES
};
static GParamSpec* gala_modal_group_properties[GALA_MODAL_GROUP_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GALA_TYPE_BACKGROUND_BLUR_EFFECT (gala_background_blur_effect_get_type ())
#define GALA_BACKGROUND_BLUR_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_BACKGROUND_BLUR_EFFECT, GalaBackgroundBlurEffect))
#define GALA_BACKGROUND_BLUR_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_BACKGROUND_BLUR_EFFECT, GalaBackgroundBlurEffectClass))
#define GALA_IS_BACKGROUND_BLUR_EFFECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_BACKGROUND_BLUR_EFFECT))
#define GALA_IS_BACKGROUND_BLUR_EFFECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_BACKGROUND_BLUR_EFFECT))
#define GALA_BACKGROUND_BLUR_EFFECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_BACKGROUND_BLUR_EFFECT, GalaBackgroundBlurEffectClass))

typedef struct _GalaBackgroundBlurEffect GalaBackgroundBlurEffect;
typedef struct _GalaBackgroundBlurEffectClass GalaBackgroundBlurEffectClass;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _GalaModalGroup {
	ClutterActor parent_instance;
	GalaModalGroupPrivate * priv;
};

struct _GalaModalGroupClass {
	ClutterActorClass parent_class;
};

struct _GalaModalGroupPrivate {
	GalaWindowManager* _wm;
	GalaShellClientsManager* _shell_clients;
	ClutterActor* _window_group;
	ClutterActor* background;
	GeeSet* dimmed;
	GalaModalProxy* modal_proxy;
};

static gint GalaModalGroup_private_offset;
static gpointer gala_modal_group_parent_class = NULL;

VALA_EXTERN GType gala_modal_group_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaModalGroup, g_object_unref)
VALA_EXTERN GType gala_shell_clients_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaShellClientsManager, g_object_unref)
VALA_EXTERN GalaModalGroup* gala_modal_group_new (GalaWindowManager* wm,
                                      GalaShellClientsManager* shell_clients);
VALA_EXTERN GalaModalGroup* gala_modal_group_construct (GType object_type,
                                            GalaWindowManager* wm,
                                            GalaShellClientsManager* shell_clients);
static void gala_modal_group_on_child_added (GalaModalGroup* self,
                                      ClutterActor* child);
static GalaShellClientsManager* gala_modal_group_get_shell_clients (GalaModalGroup* self);
VALA_EXTERN gboolean gala_shell_clients_manager_is_system_modal_dimmed (GalaShellClientsManager* self,
                                                            MetaWindow* window);
VALA_EXTERN ClutterActor* gala_modal_group_get_window_group (GalaModalGroup* self);
static GalaWindowManager* gala_modal_group_get_wm (GalaModalGroup* self);
static void gala_modal_group_on_child_removed (GalaModalGroup* self,
                                        ClutterActor* child);
static void ____lambda32_ (GalaModalGroup* self);
static void _____lambda32__clutter_timeline_completed (ClutterTimeline* _sender,
                                                gpointer self);
static void gala_modal_group_set_wm (GalaModalGroup* self,
                              GalaWindowManager* value);
static void gala_modal_group_set_shell_clients (GalaModalGroup* self,
                                         GalaShellClientsManager* value);
static void gala_modal_group_set_window_group (GalaModalGroup* self,
                                        ClutterActor* value);
static GObject * gala_modal_group_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
VALA_EXTERN GalaBackgroundBlurEffect* gala_background_blur_effect_new (gfloat blur_radius,
                                                           gfloat clip_radius,
                                                           gfloat monitor_scale);
VALA_EXTERN GalaBackgroundBlurEffect* gala_background_blur_effect_construct (GType object_type,
                                                                 gfloat blur_radius,
                                                                 gfloat clip_radius,
                                                                 gfloat monitor_scale);
VALA_EXTERN GType gala_background_blur_effect_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaBackgroundBlurEffect, g_object_unref)
static void _gala_modal_group_on_child_added_clutter_actor_child_added (ClutterActor* _sender,
                                                                 ClutterActor* child,
                                                                 gpointer self);
static void _gala_modal_group_on_child_removed_clutter_actor_child_removed (ClutterActor* _sender,
                                                                     ClutterActor* child,
                                                                     gpointer self);
static void gala_modal_group_finalize (GObject * obj);
static GType gala_modal_group_get_type_once (void);
static void _vala_gala_modal_group_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_gala_modal_group_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
gala_modal_group_get_instance_private (GalaModalGroup* self)
{
	return G_STRUCT_MEMBER_P (self, GalaModalGroup_private_offset);
}

GalaModalGroup*
gala_modal_group_construct (GType object_type,
                            GalaWindowManager* wm,
                            GalaShellClientsManager* shell_clients)
{
	GalaModalGroup * self = NULL;
	g_return_val_if_fail (wm != NULL, NULL);
	g_return_val_if_fail (shell_clients != NULL, NULL);
	self = (GalaModalGroup*) g_object_new (object_type, "wm", wm, "shell-clients", shell_clients, NULL);
	return self;
}

GalaModalGroup*
gala_modal_group_new (GalaWindowManager* wm,
                      GalaShellClientsManager* shell_clients)
{
	return gala_modal_group_construct (GALA_TYPE_MODAL_GROUP, wm, shell_clients);
}

static void
gala_modal_group_on_child_added (GalaModalGroup* self,
                                 ClutterActor* child)
{
	gboolean _tmp0_ = FALSE;
	ClutterActor* _tmp5_;
	GeeSet* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (child != NULL);
	if (G_TYPE_CHECK_INSTANCE_TYPE (child, meta_window_actor_get_type ())) {
		GalaShellClientsManager* _tmp1_;
		MetaWindow* _tmp2_;
		MetaWindow* _tmp3_;
		_tmp1_ = self->priv->_shell_clients;
		_tmp2_ = meta_window_actor_get_meta_window ((MetaWindowActor*) child);
		_tmp3_ = _tmp2_;
		_tmp0_ = gala_shell_clients_manager_is_system_modal_dimmed (_tmp1_, _tmp3_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GeeSet* _tmp4_;
		_tmp4_ = self->priv->dimmed;
		gee_collection_add ((GeeCollection*) _tmp4_, child);
	}
	_tmp5_ = self->priv->_window_group;
	if (clutter_actor_get_n_children (_tmp5_) == 1) {
		GalaModalProxy* _tmp6_;
		GalaWindowManager* _tmp7_;
		GalaModalProxy* _tmp8_;
		GalaModalProxy* _tmp9_;
		_tmp6_ = self->priv->modal_proxy;
		_vala_assert (_tmp6_ == NULL, "modal_proxy == null");
		g_object_set ((ClutterActor*) self, "visible", TRUE, NULL);
		_tmp7_ = self->priv->_wm;
		_tmp8_ = gala_window_manager_push_modal (_tmp7_, (ClutterActor*) self, FALSE);
		_g_object_unref0 (self->priv->modal_proxy);
		self->priv->modal_proxy = _tmp8_;
		_tmp9_ = self->priv->modal_proxy;
		gala_modal_proxy_allow_actions (_tmp9_, (((GALA_MODAL_ACTIONS_ZOOM | GALA_MODAL_ACTIONS_LOCATE_POINTER) | GALA_MODAL_ACTIONS_SCREENSHOT) | GALA_MODAL_ACTIONS_SCREENSHOT_AREA) | GALA_MODAL_ACTIONS_SCREENSHOT_WINDOW);
	}
	_tmp10_ = self->priv->dimmed;
	_tmp11_ = gee_collection_get_size ((GeeCollection*) _tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ == 1) {
		ClutterActor* _tmp13_;
		ClutterActor* _tmp14_;
		ClutterActor* _tmp15_;
		ClutterActor* _tmp16_;
		_tmp13_ = self->priv->background;
		clutter_actor_save_easing_state (_tmp13_);
		_tmp14_ = self->priv->background;
		clutter_actor_set_easing_duration (_tmp14_, gala_utils_get_animation_duration ((guint) GALA_ANIMATION_DURATION_OPEN));
		_tmp15_ = self->priv->background;
		clutter_actor_set_opacity (_tmp15_, 255U);
		_tmp16_ = self->priv->background;
		clutter_actor_restore_easing_state (_tmp16_);
	}
}

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

static void
____lambda32_ (GalaModalGroup* self)
{
	g_object_set ((ClutterActor*) self, "visible", FALSE, NULL);
}

static void
_____lambda32__clutter_timeline_completed (ClutterTimeline* _sender,
                                           gpointer self)
{
	____lambda32_ ((GalaModalGroup*) self);
}

static void
gala_modal_group_on_child_removed (GalaModalGroup* self,
                                   ClutterActor* child)
{
	GeeSet* _tmp0_;
	GeeSet* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	ClutterActor* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (child != NULL);
	_tmp0_ = self->priv->dimmed;
	gee_collection_remove ((GeeCollection*) _tmp0_, child);
	_tmp1_ = self->priv->dimmed;
	_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == 0) {
		ClutterActor* _tmp4_;
		ClutterActor* _tmp5_;
		ClutterActor* _tmp6_;
		ClutterActor* _tmp7_;
		_tmp4_ = self->priv->background;
		clutter_actor_save_easing_state (_tmp4_);
		_tmp5_ = self->priv->background;
		clutter_actor_set_easing_duration (_tmp5_, gala_utils_get_animation_duration ((guint) GALA_ANIMATION_DURATION_CLOSE));
		_tmp6_ = self->priv->background;
		clutter_actor_set_opacity (_tmp6_, 0U);
		_tmp7_ = self->priv->background;
		clutter_actor_restore_easing_state (_tmp7_);
	}
	_tmp8_ = self->priv->_window_group;
	if (clutter_actor_get_n_children (_tmp8_) == 0) {
		GalaWindowManager* _tmp9_;
		GalaModalProxy* _tmp10_;
		ClutterTransition* transition = NULL;
		ClutterActor* _tmp11_;
		ClutterTransition* _tmp12_;
		ClutterTransition* _tmp13_;
		ClutterTransition* _tmp14_;
		_tmp9_ = self->priv->_wm;
		_tmp10_ = self->priv->modal_proxy;
		gala_window_manager_pop_modal (_tmp9_, _tmp10_);
		_g_object_unref0 (self->priv->modal_proxy);
		self->priv->modal_proxy = NULL;
		_tmp11_ = self->priv->background;
		_tmp12_ = clutter_actor_get_transition (_tmp11_, "opacity");
		_tmp13_ = _g_object_ref0 (_tmp12_);
		transition = _tmp13_;
		_tmp14_ = transition;
		if (_tmp14_ != NULL) {
			ClutterTransition* _tmp15_;
			_tmp15_ = transition;
			g_signal_connect_object ((ClutterTimeline*) _tmp15_, "completed", (GCallback) _____lambda32__clutter_timeline_completed, self, 0);
		} else {
			g_object_set ((ClutterActor*) self, "visible", FALSE, NULL);
		}
		_g_object_unref0 (transition);
	}
}

static GalaWindowManager*
gala_modal_group_get_wm (GalaModalGroup* self)
{
	GalaWindowManager* result;
	GalaWindowManager* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_wm;
	result = _tmp0_;
	return result;
}

static void
gala_modal_group_set_wm (GalaModalGroup* self,
                         GalaWindowManager* value)
{
	GalaWindowManager* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_modal_group_get_wm (self);
	if (old_value != value) {
		GalaWindowManager* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_wm);
		self->priv->_wm = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_modal_group_properties[GALA_MODAL_GROUP_WM_PROPERTY]);
	}
}

static GalaShellClientsManager*
gala_modal_group_get_shell_clients (GalaModalGroup* self)
{
	GalaShellClientsManager* result;
	GalaShellClientsManager* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_shell_clients;
	result = _tmp0_;
	return result;
}

static void
gala_modal_group_set_shell_clients (GalaModalGroup* self,
                                    GalaShellClientsManager* value)
{
	GalaShellClientsManager* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_modal_group_get_shell_clients (self);
	if (old_value != value) {
		GalaShellClientsManager* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_shell_clients);
		self->priv->_shell_clients = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_modal_group_properties[GALA_MODAL_GROUP_SHELL_CLIENTS_PROPERTY]);
	}
}

ClutterActor*
gala_modal_group_get_window_group (GalaModalGroup* self)
{
	ClutterActor* result;
	ClutterActor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window_group;
	result = _tmp0_;
	return result;
}

static void
gala_modal_group_set_window_group (GalaModalGroup* self,
                                   ClutterActor* value)
{
	ClutterActor* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_modal_group_get_window_group (self);
	if (old_value != value) {
		ClutterActor* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window_group);
		self->priv->_window_group = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_modal_group_properties[GALA_MODAL_GROUP_WINDOW_GROUP_PROPERTY]);
	}
}

static void
_gala_modal_group_on_child_added_clutter_actor_child_added (ClutterActor* _sender,
                                                            ClutterActor* child,
                                                            gpointer self)
{
	gala_modal_group_on_child_added ((GalaModalGroup*) self, child);
}

static void
_gala_modal_group_on_child_removed_clutter_actor_child_removed (ClutterActor* _sender,
                                                                ClutterActor* child,
                                                                gpointer self)
{
	gala_modal_group_on_child_removed ((GalaModalGroup*) self, child);
}

static GObject *
gala_modal_group_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaModalGroup * self;
	ClutterColor _tmp0_ = {0};
	ClutterActor* _tmp1_ = NULL;
	ClutterActor* _tmp2_;
	GalaBackgroundBlurEffect* _tmp3_;
	GalaBackgroundBlurEffect* _tmp4_;
	ClutterActor* _tmp5_ = NULL;
	ClutterActor* _tmp6_;
	ClutterActor* _tmp7_;
	ClutterActor* _tmp8_;
	GeeHashSet* _tmp9_;
	ClutterActor* _tmp10_;
	ClutterActor* _tmp11_;
	parent_class = G_OBJECT_CLASS (gala_modal_group_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_MODAL_GROUP, GalaModalGroup);
	_tmp0_.red = (guint8) 0;
	_tmp0_.green = (guint8) 0;
	_tmp0_.blue = (guint8) 0;
	_tmp0_.alpha = (guint8) 125;
	_tmp1_ = clutter_actor_new ();
	clutter_actor_set_background_color (_tmp1_, &_tmp0_);
	clutter_actor_set_x_expand (_tmp1_, TRUE);
	clutter_actor_set_y_expand (_tmp1_, TRUE);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->background);
	self->priv->background = _tmp1_;
	_tmp2_ = self->priv->background;
	_tmp3_ = gala_background_blur_effect_new ((gfloat) 10, (gfloat) 0, (gfloat) 1);
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	clutter_actor_add_effect (_tmp2_, (ClutterEffect*) _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = clutter_actor_new ();
	clutter_actor_set_x_expand (_tmp5_, TRUE);
	clutter_actor_set_y_expand (_tmp5_, TRUE);
	g_object_ref_sink (_tmp5_);
	_tmp6_ = _tmp5_;
	gala_modal_group_set_window_group (self, _tmp6_);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = self->priv->background;
	clutter_actor_add_child ((ClutterActor*) self, _tmp7_);
	_tmp8_ = self->priv->_window_group;
	clutter_actor_add_child ((ClutterActor*) self, _tmp8_);
	_tmp9_ = gee_hash_set_new (clutter_actor_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->dimmed);
	self->priv->dimmed = (GeeSet*) _tmp9_;
	g_object_set ((ClutterActor*) self, "visible", FALSE, NULL);
	clutter_actor_set_reactive ((ClutterActor*) self, TRUE);
	_tmp10_ = self->priv->_window_group;
	g_signal_connect_object (_tmp10_, "child-added", (GCallback) _gala_modal_group_on_child_added_clutter_actor_child_added, self, 0);
	_tmp11_ = self->priv->_window_group;
	g_signal_connect_object (_tmp11_, "child-removed", (GCallback) _gala_modal_group_on_child_removed_clutter_actor_child_removed, self, 0);
	return obj;
}

static void
gala_modal_group_base_init (GalaModalGroupClass * klass)
{
	clutter_actor_class_set_layout_manager_type (CLUTTER_ACTOR_CLASS (klass), clutter_bin_layout_get_type ());
}

static void
gala_modal_group_class_init (GalaModalGroupClass * klass,
                             gpointer klass_data)
{
	gala_modal_group_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaModalGroup_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_modal_group_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_modal_group_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_modal_group_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_modal_group_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_MODAL_GROUP_WM_PROPERTY, gala_modal_group_properties[GALA_MODAL_GROUP_WM_PROPERTY] = g_param_spec_object ("wm", "wm", "wm", GALA_TYPE_WINDOW_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_MODAL_GROUP_SHELL_CLIENTS_PROPERTY, gala_modal_group_properties[GALA_MODAL_GROUP_SHELL_CLIENTS_PROPERTY] = g_param_spec_object ("shell-clients", "shell-clients", "shell-clients", GALA_TYPE_SHELL_CLIENTS_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_MODAL_GROUP_WINDOW_GROUP_PROPERTY, gala_modal_group_properties[GALA_MODAL_GROUP_WINDOW_GROUP_PROPERTY] = g_param_spec_object ("window-group", "window-group", "window-group", clutter_actor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_modal_group_instance_init (GalaModalGroup * self,
                                gpointer klass)
{
	self->priv = gala_modal_group_get_instance_private (self);
	self->priv->modal_proxy = NULL;
}

static void
gala_modal_group_finalize (GObject * obj)
{
	GalaModalGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_MODAL_GROUP, GalaModalGroup);
	_g_object_unref0 (self->priv->_wm);
	_g_object_unref0 (self->priv->_shell_clients);
	_g_object_unref0 (self->priv->_window_group);
	_g_object_unref0 (self->priv->background);
	_g_object_unref0 (self->priv->dimmed);
	_g_object_unref0 (self->priv->modal_proxy);
	G_OBJECT_CLASS (gala_modal_group_parent_class)->finalize (obj);
}

/**
 * This class allows to make windows system modal i.e. dim
 * the desktop behind them and only allow interaction with them.
 * Not to be confused with WindowManager.push_modal which only
 * works for our own Clutter.Actors.
 * Note that windows shouldn't be added to this actor directly but
 * instead to {@link window_group}.
 */
 G_GNUC_NO_INLINE static GType
gala_modal_group_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaModalGroupClass), (GBaseInitFunc) gala_modal_group_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_modal_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaModalGroup), 0, (GInstanceInitFunc) gala_modal_group_instance_init, NULL };
	GType gala_modal_group_type_id;
	gala_modal_group_type_id = g_type_register_static (clutter_actor_get_type (), "GalaModalGroup", &g_define_type_info, 0);
	GalaModalGroup_private_offset = g_type_add_instance_private (gala_modal_group_type_id, sizeof (GalaModalGroupPrivate));
	return gala_modal_group_type_id;
}

GType
gala_modal_group_get_type (void)
{
	static gsize gala_modal_group_type_id__once = 0;
	if (g_once_init_enter (&gala_modal_group_type_id__once)) {
		GType gala_modal_group_type_id;
		gala_modal_group_type_id = gala_modal_group_get_type_once ();
		g_once_init_leave (&gala_modal_group_type_id__once, gala_modal_group_type_id);
	}
	return gala_modal_group_type_id__once;
}

static void
_vala_gala_modal_group_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	GalaModalGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_MODAL_GROUP, GalaModalGroup);
	switch (property_id) {
		case GALA_MODAL_GROUP_WM_PROPERTY:
		g_value_set_object (value, gala_modal_group_get_wm (self));
		break;
		case GALA_MODAL_GROUP_SHELL_CLIENTS_PROPERTY:
		g_value_set_object (value, gala_modal_group_get_shell_clients (self));
		break;
		case GALA_MODAL_GROUP_WINDOW_GROUP_PROPERTY:
		g_value_set_object (value, gala_modal_group_get_window_group (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_modal_group_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	GalaModalGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_MODAL_GROUP, GalaModalGroup);
	switch (property_id) {
		case GALA_MODAL_GROUP_WM_PROPERTY:
		gala_modal_group_set_wm (self, g_value_get_object (value));
		break;
		case GALA_MODAL_GROUP_SHELL_CLIENTS_PROPERTY:
		gala_modal_group_set_shell_clients (self, g_value_get_object (value));
		break;
		case GALA_MODAL_GROUP_WINDOW_GROUP_PROPERTY:
		gala_modal_group_set_window_group (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

