/* StaticWindowClone.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from StaticWindowClone.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 "gala.h"
#include <glib-object.h>
#include <meta/window.h>
#include <glib.h>
#include <meta/meta-window-actor.h>
#include <clutter/clutter.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_STATIC_WINDOW_CLONE (gala_static_window_clone_get_type ())
#define GALA_STATIC_WINDOW_CLONE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_STATIC_WINDOW_CLONE, GalaStaticWindowClone))
#define GALA_STATIC_WINDOW_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_STATIC_WINDOW_CLONE, GalaStaticWindowCloneClass))
#define GALA_IS_STATIC_WINDOW_CLONE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_STATIC_WINDOW_CLONE))
#define GALA_IS_STATIC_WINDOW_CLONE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_STATIC_WINDOW_CLONE))
#define GALA_STATIC_WINDOW_CLONE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_STATIC_WINDOW_CLONE, GalaStaticWindowCloneClass))

typedef struct _GalaStaticWindowClone GalaStaticWindowClone;
typedef struct _GalaStaticWindowCloneClass GalaStaticWindowCloneClass;
typedef struct _GalaStaticWindowClonePrivate GalaStaticWindowClonePrivate;
enum  {
	GALA_STATIC_WINDOW_CLONE_0_PROPERTY,
	GALA_STATIC_WINDOW_CLONE_WINDOW_PROPERTY,
	GALA_STATIC_WINDOW_CLONE_NUM_PROPERTIES
};
static GParamSpec* gala_static_window_clone_properties[GALA_STATIC_WINDOW_CLONE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaStaticWindowClone {
	GalaActorTarget parent_instance;
	GalaStaticWindowClonePrivate * priv;
};

struct _GalaStaticWindowCloneClass {
	GalaActorTargetClass parent_class;
};

struct _GalaStaticWindowClonePrivate {
	MetaWindow* _window;
};

static gint GalaStaticWindowClone_private_offset;
static gpointer gala_static_window_clone_parent_class = NULL;

VALA_EXTERN GType gala_static_window_clone_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaStaticWindowClone, g_object_unref)
VALA_EXTERN GalaStaticWindowClone* gala_static_window_clone_new (MetaWindow* window);
VALA_EXTERN GalaStaticWindowClone* gala_static_window_clone_construct (GType object_type,
                                                           MetaWindow* window);
VALA_EXTERN MetaWindow* gala_static_window_clone_get_window (GalaStaticWindowClone* self);
static void gala_static_window_clone_set_window (GalaStaticWindowClone* self,
                                          MetaWindow* value);
static GObject * gala_static_window_clone_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties);
static void gala_static_window_clone_finalize (GObject * obj);
static GType gala_static_window_clone_get_type_once (void);
static void _vala_gala_static_window_clone_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_gala_static_window_clone_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);

static inline gpointer
gala_static_window_clone_get_instance_private (GalaStaticWindowClone* self)
{
	return G_STRUCT_MEMBER_P (self, GalaStaticWindowClone_private_offset);
}

GalaStaticWindowClone*
gala_static_window_clone_construct (GType object_type,
                                    MetaWindow* window)
{
	GalaStaticWindowClone * self = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	self = (GalaStaticWindowClone*) g_object_new (object_type, "window", window, NULL);
	return self;
}

GalaStaticWindowClone*
gala_static_window_clone_new (MetaWindow* window)
{
	return gala_static_window_clone_construct (GALA_TYPE_STATIC_WINDOW_CLONE, window);
}

MetaWindow*
gala_static_window_clone_get_window (GalaStaticWindowClone* self)
{
	MetaWindow* result;
	MetaWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

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

static void
gala_static_window_clone_set_window (GalaStaticWindowClone* self,
                                     MetaWindow* value)
{
	MetaWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_static_window_clone_get_window (self);
	if (old_value != value) {
		MetaWindow* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_window);
		self->priv->_window = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_static_window_clone_properties[GALA_STATIC_WINDOW_CLONE_WINDOW_PROPERTY]);
	}
}

static GObject *
gala_static_window_clone_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaStaticWindowClone * self;
	MetaWindowActor* window_actor = NULL;
	MetaWindow* _tmp0_;
	GObject* _tmp1_;
	MetaWindowActor* _tmp2_;
	ClutterClone* clone = NULL;
	MetaWindowActor* _tmp3_;
	ClutterClone* _tmp4_;
	ClutterClone* _tmp5_;
	GValue _tmp6_ = {0};
	GValue _tmp7_ = {0};
	GalaPropertyTarget* _tmp8_;
	GalaPropertyTarget* _tmp9_;
	MetaWindowActor* _tmp10_;
	MetaWindowActor* _tmp11_;
	parent_class = G_OBJECT_CLASS (gala_static_window_clone_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_STATIC_WINDOW_CLONE, GalaStaticWindowClone);
	_tmp0_ = self->priv->_window;
	_tmp1_ = meta_window_get_compositor_private (_tmp0_);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, meta_window_actor_get_type (), MetaWindowActor));
	window_actor = _tmp2_;
	_tmp3_ = window_actor;
	_tmp4_ = (ClutterClone*) clutter_clone_new ((ClutterActor*) _tmp3_);
	g_object_ref_sink (_tmp4_);
	clone = _tmp4_;
	_tmp5_ = clone;
	clutter_actor_add_child ((ClutterActor*) self, (ClutterActor*) _tmp5_);
	g_value_init (&_tmp6_, G_TYPE_UINT);
	g_value_set_uint (&_tmp6_, 255U);
	g_value_init (&_tmp7_, G_TYPE_UINT);
	g_value_set_uint (&_tmp7_, 0U);
	_tmp8_ = gala_property_target_new (GALA_GESTURE_ACTION_MULTITASKING_VIEW, (GObject*) self, "opacity", G_TYPE_UINT, &_tmp6_, &_tmp7_);
	_tmp9_ = _tmp8_;
	gala_actor_target_add_target ((GalaActorTarget*) self, (GalaGestureTarget*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	G_IS_VALUE (&_tmp7_) ? (g_value_unset (&_tmp7_), NULL) : NULL;
	G_IS_VALUE (&_tmp6_) ? (g_value_unset (&_tmp6_), NULL) : NULL;
	_tmp10_ = window_actor;
	g_object_bind_property_with_closures ((GObject*) _tmp10_, "x", (GObject*) self, "x", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp11_ = window_actor;
	g_object_bind_property_with_closures ((GObject*) _tmp11_, "y", (GObject*) self, "y", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (clone);
	_g_object_unref0 (window_actor);
	return obj;
}

static void
gala_static_window_clone_class_init (GalaStaticWindowCloneClass * klass,
                                     gpointer klass_data)
{
	gala_static_window_clone_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaStaticWindowClone_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_static_window_clone_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_static_window_clone_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_static_window_clone_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_static_window_clone_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_STATIC_WINDOW_CLONE_WINDOW_PROPERTY, gala_static_window_clone_properties[GALA_STATIC_WINDOW_CLONE_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", meta_window_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_static_window_clone_instance_init (GalaStaticWindowClone * self,
                                        gpointer klass)
{
	self->priv = gala_static_window_clone_get_instance_private (self);
}

static void
gala_static_window_clone_finalize (GObject * obj)
{
	GalaStaticWindowClone * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_STATIC_WINDOW_CLONE, GalaStaticWindowClone);
	_g_object_unref0 (self->priv->_window);
	G_OBJECT_CLASS (gala_static_window_clone_parent_class)->finalize (obj);
}

/**
 * A exact clone of a window (same position and size). This is used for static
 * windows (e.g. on all workspaces or moving) and fades out while the multitasking view
 * is being opened.
 */
 G_GNUC_NO_INLINE static GType
gala_static_window_clone_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaStaticWindowCloneClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_static_window_clone_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaStaticWindowClone), 0, (GInstanceInitFunc) gala_static_window_clone_instance_init, NULL };
	GType gala_static_window_clone_type_id;
	gala_static_window_clone_type_id = g_type_register_static (GALA_TYPE_ACTOR_TARGET, "GalaStaticWindowClone", &g_define_type_info, 0);
	GalaStaticWindowClone_private_offset = g_type_add_instance_private (gala_static_window_clone_type_id, sizeof (GalaStaticWindowClonePrivate));
	return gala_static_window_clone_type_id;
}

GType
gala_static_window_clone_get_type (void)
{
	static gsize gala_static_window_clone_type_id__once = 0;
	if (g_once_init_enter (&gala_static_window_clone_type_id__once)) {
		GType gala_static_window_clone_type_id;
		gala_static_window_clone_type_id = gala_static_window_clone_get_type_once ();
		g_once_init_leave (&gala_static_window_clone_type_id__once, gala_static_window_clone_type_id);
	}
	return gala_static_window_clone_type_id__once;
}

static void
_vala_gala_static_window_clone_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GalaStaticWindowClone * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_STATIC_WINDOW_CLONE, GalaStaticWindowClone);
	switch (property_id) {
		case GALA_STATIC_WINDOW_CLONE_WINDOW_PROPERTY:
		g_value_set_object (value, gala_static_window_clone_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_static_window_clone_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GalaStaticWindowClone * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_STATIC_WINDOW_CLONE, GalaStaticWindowClone);
	switch (property_id) {
		case GALA_STATIC_WINDOW_CLONE_WINDOW_PROPERTY:
		gala_static_window_clone_set_window (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

