/* ExtendedBehaviorWindow.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from ExtendedBehaviorWindow.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 <glib-object.h>
#include <mtk/mtk.h>
#include <glib.h>
#include "gala.h"
#include <float.h>
#include <math.h>
#include <meta/window.h>
#include <meta/display.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_POSITIONED_WINDOW (gala_positioned_window_get_type ())
#define GALA_POSITIONED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_POSITIONED_WINDOW, GalaPositionedWindow))
#define GALA_POSITIONED_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_POSITIONED_WINDOW, GalaPositionedWindowClass))
#define GALA_IS_POSITIONED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_POSITIONED_WINDOW))
#define GALA_IS_POSITIONED_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_POSITIONED_WINDOW))
#define GALA_POSITIONED_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_POSITIONED_WINDOW, GalaPositionedWindowClass))

typedef struct _GalaPositionedWindow GalaPositionedWindow;
typedef struct _GalaPositionedWindowClass GalaPositionedWindowClass;
typedef struct _GalaPositionedWindowPrivate GalaPositionedWindowPrivate;

#define GALA_TYPE_SHELL_WINDOW (gala_shell_window_get_type ())
#define GALA_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SHELL_WINDOW, GalaShellWindow))
#define GALA_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SHELL_WINDOW, GalaShellWindowClass))
#define GALA_IS_SHELL_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SHELL_WINDOW))
#define GALA_IS_SHELL_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SHELL_WINDOW))
#define GALA_SHELL_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SHELL_WINDOW, GalaShellWindowClass))

typedef struct _GalaShellWindow GalaShellWindow;
typedef struct _GalaShellWindowClass GalaShellWindowClass;
typedef struct _GalaShellWindowPrivate GalaShellWindowPrivate;

#define GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW (gala_extended_behavior_window_get_type ())
#define GALA_EXTENDED_BEHAVIOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW, GalaExtendedBehaviorWindow))
#define GALA_EXTENDED_BEHAVIOR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW, GalaExtendedBehaviorWindowClass))
#define GALA_IS_EXTENDED_BEHAVIOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW))
#define GALA_IS_EXTENDED_BEHAVIOR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW))
#define GALA_EXTENDED_BEHAVIOR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW, GalaExtendedBehaviorWindowClass))

typedef struct _GalaExtendedBehaviorWindow GalaExtendedBehaviorWindow;
typedef struct _GalaExtendedBehaviorWindowClass GalaExtendedBehaviorWindowClass;
typedef struct _GalaExtendedBehaviorWindowPrivate GalaExtendedBehaviorWindowPrivate;
enum  {
	GALA_EXTENDED_BEHAVIOR_WINDOW_0_PROPERTY,
	GALA_EXTENDED_BEHAVIOR_WINDOW_MODAL_PROPERTY,
	GALA_EXTENDED_BEHAVIOR_WINDOW_DIM_PROPERTY,
	GALA_EXTENDED_BEHAVIOR_WINDOW_NUM_PROPERTIES
};
static GParamSpec* gala_extended_behavior_window_properties[GALA_EXTENDED_BEHAVIOR_WINDOW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaPositionedWindow {
	GObject parent_instance;
	GalaPositionedWindowPrivate * priv;
};

struct _GalaPositionedWindowClass {
	GObjectClass parent_class;
	void (*get_window_position) (GalaPositionedWindow* self, MtkRectangle* window_rect, gint* x, gint* y);
};

struct _GalaShellWindow {
	GalaPositionedWindow parent_instance;
	GalaShellWindowPrivate * priv;
};

struct _GalaShellWindowClass {
	GalaPositionedWindowClass parent_class;
	void (*propagate) (GalaShellWindow* self, GalaGestureTargetUpdateType update_type, GalaGestureAction action, gdouble progress);
	gdouble (*get_hidden_progress) (GalaShellWindow* self);
};

struct _GalaExtendedBehaviorWindow {
	GalaShellWindow parent_instance;
	GalaExtendedBehaviorWindowPrivate * priv;
};

struct _GalaExtendedBehaviorWindowClass {
	GalaShellWindowClass parent_class;
};

struct _GalaExtendedBehaviorWindowPrivate {
	gboolean _modal;
	gboolean _dim;
};

static gint GalaExtendedBehaviorWindow_private_offset;
static gpointer gala_extended_behavior_window_parent_class = NULL;

VALA_EXTERN GType gala_positioned_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaPositionedWindow, g_object_unref)
VALA_EXTERN GType gala_shell_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaShellWindow, g_object_unref)
VALA_EXTERN GType gala_extended_behavior_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaExtendedBehaviorWindow, g_object_unref)
VALA_EXTERN void gala_positioned_window_get_window_position (GalaPositionedWindow* self,
                                                 MtkRectangle* window_rect,
                                                 gint* x,
                                                 gint* y);
VALA_EXTERN GalaExtendedBehaviorWindow* gala_extended_behavior_window_new (MetaWindow* window);
VALA_EXTERN GalaExtendedBehaviorWindow* gala_extended_behavior_window_construct (GType object_type,
                                                                     MetaWindow* window);
VALA_EXTERN void gala_extended_behavior_window_make_modal (GalaExtendedBehaviorWindow* self,
                                               gboolean dim);
static void gala_extended_behavior_window_set_modal (GalaExtendedBehaviorWindow* self,
                                              gboolean value);
static void gala_extended_behavior_window_set_dim (GalaExtendedBehaviorWindow* self,
                                            gboolean value);
static void gala_extended_behavior_window_real_get_window_position (GalaPositionedWindow* base,
                                                             MtkRectangle* window_rect,
                                                             gint* x,
                                                             gint* y);
VALA_EXTERN MetaWindow* gala_positioned_window_get_window (GalaPositionedWindow* self);
VALA_EXTERN gboolean gala_extended_behavior_window_get_modal (GalaExtendedBehaviorWindow* self);
VALA_EXTERN gboolean gala_extended_behavior_window_get_dim (GalaExtendedBehaviorWindow* self);
static void gala_extended_behavior_window_finalize (GObject * obj);
static GType gala_extended_behavior_window_get_type_once (void);
static void _vala_gala_extended_behavior_window_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec);
static void _vala_gala_extended_behavior_window_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec);

static inline gpointer
gala_extended_behavior_window_get_instance_private (GalaExtendedBehaviorWindow* self)
{
	return G_STRUCT_MEMBER_P (self, GalaExtendedBehaviorWindow_private_offset);
}

GalaExtendedBehaviorWindow*
gala_extended_behavior_window_construct (GType object_type,
                                         MetaWindow* window)
{
	GalaExtendedBehaviorWindow * self = NULL;
	GalaPropertyTarget* target = NULL;
	GObject* _tmp0_;
	GValue _tmp1_ = {0};
	GValue _tmp2_ = {0};
	GalaPropertyTarget* _tmp3_;
	GalaPropertyTarget* _tmp4_;
	g_return_val_if_fail (window != NULL, NULL);
	_tmp0_ = meta_window_get_compositor_private (window);
	g_value_init (&_tmp1_, G_TYPE_UINT);
	g_value_set_uint (&_tmp1_, 255U);
	g_value_init (&_tmp2_, G_TYPE_UINT);
	g_value_set_uint (&_tmp2_, 0U);
	_tmp3_ = gala_property_target_new (GALA_GESTURE_ACTION_CUSTOM, _tmp0_, "opacity", G_TYPE_UINT, &_tmp1_, &_tmp2_);
	_tmp4_ = _tmp3_;
	G_IS_VALUE (&_tmp2_) ? (g_value_unset (&_tmp2_), NULL) : NULL;
	G_IS_VALUE (&_tmp1_) ? (g_value_unset (&_tmp1_), NULL) : NULL;
	target = _tmp4_;
	self = (GalaExtendedBehaviorWindow*) g_object_new (object_type, "window", window, "hide-target", target, NULL);
	_g_object_unref0 (target);
	return self;
}

GalaExtendedBehaviorWindow*
gala_extended_behavior_window_new (MetaWindow* window)
{
	return gala_extended_behavior_window_construct (GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW, window);
}

void
gala_extended_behavior_window_make_modal (GalaExtendedBehaviorWindow* self,
                                          gboolean dim)
{
	g_return_if_fail (self != NULL);
	gala_extended_behavior_window_set_modal (self, TRUE);
	gala_extended_behavior_window_set_dim (self, dim);
}

static void
gala_extended_behavior_window_real_get_window_position (GalaPositionedWindow* base,
                                                        MtkRectangle* window_rect,
                                                        gint* x,
                                                        gint* y)
{
	GalaExtendedBehaviorWindow * self;
	gint _vala_x = 0;
	gint _vala_y = 0;
	MtkRectangle monitor_rect = {0};
	MetaWindow* _tmp0_;
	MetaWindow* _tmp1_;
	MetaDisplay* _tmp2_;
	MetaDisplay* _tmp3_;
	MetaWindow* _tmp4_;
	MetaWindow* _tmp5_;
	MtkRectangle _tmp6_ = {0};
	MtkRectangle _tmp7_;
	MtkRectangle _tmp8_;
	MtkRectangle _tmp9_;
	MtkRectangle _tmp10_;
	MtkRectangle _tmp11_;
	MtkRectangle _tmp12_;
	self = (GalaExtendedBehaviorWindow*) base;
	g_return_if_fail (window_rect != NULL);
	_tmp0_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = meta_window_get_display (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp5_ = _tmp4_;
	meta_display_get_monitor_geometry (_tmp3_, meta_window_get_monitor (_tmp5_), &_tmp6_);
	monitor_rect = _tmp6_;
	_tmp7_ = monitor_rect;
	_tmp8_ = monitor_rect;
	_tmp9_ = *window_rect;
	_vala_x = _tmp7_.x + ((_tmp8_.width - _tmp9_.width) / 2);
	_tmp10_ = monitor_rect;
	_tmp11_ = monitor_rect;
	_tmp12_ = *window_rect;
	_vala_y = _tmp10_.y + ((_tmp11_.height - _tmp12_.height) / 2);
	if (x) {
		*x = _vala_x;
	}
	if (y) {
		*y = _vala_y;
	}
}

gboolean
gala_extended_behavior_window_get_modal (GalaExtendedBehaviorWindow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_modal;
	return result;
}

static void
gala_extended_behavior_window_set_modal (GalaExtendedBehaviorWindow* self,
                                         gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_extended_behavior_window_get_modal (self);
	if (old_value != value) {
		self->priv->_modal = value;
		g_object_notify_by_pspec ((GObject *) self, gala_extended_behavior_window_properties[GALA_EXTENDED_BEHAVIOR_WINDOW_MODAL_PROPERTY]);
	}
}

gboolean
gala_extended_behavior_window_get_dim (GalaExtendedBehaviorWindow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_dim;
	return result;
}

static void
gala_extended_behavior_window_set_dim (GalaExtendedBehaviorWindow* self,
                                       gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_extended_behavior_window_get_dim (self);
	if (old_value != value) {
		self->priv->_dim = value;
		g_object_notify_by_pspec ((GObject *) self, gala_extended_behavior_window_properties[GALA_EXTENDED_BEHAVIOR_WINDOW_DIM_PROPERTY]);
	}
}

static void
gala_extended_behavior_window_class_init (GalaExtendedBehaviorWindowClass * klass,
                                          gpointer klass_data)
{
	gala_extended_behavior_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaExtendedBehaviorWindow_private_offset);
	((GalaPositionedWindowClass *) klass)->get_window_position = (void (*) (GalaPositionedWindow*, MtkRectangle*, gint*, gint*)) gala_extended_behavior_window_real_get_window_position;
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_extended_behavior_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_extended_behavior_window_set_property;
	G_OBJECT_CLASS (klass)->finalize = gala_extended_behavior_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_EXTENDED_BEHAVIOR_WINDOW_MODAL_PROPERTY, gala_extended_behavior_window_properties[GALA_EXTENDED_BEHAVIOR_WINDOW_MODAL_PROPERTY] = g_param_spec_boolean ("modal", "modal", "modal", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_EXTENDED_BEHAVIOR_WINDOW_DIM_PROPERTY, gala_extended_behavior_window_properties[GALA_EXTENDED_BEHAVIOR_WINDOW_DIM_PROPERTY] = g_param_spec_boolean ("dim", "dim", "dim", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gala_extended_behavior_window_instance_init (GalaExtendedBehaviorWindow * self,
                                             gpointer klass)
{
	self->priv = gala_extended_behavior_window_get_instance_private (self);
	self->priv->_modal = FALSE;
	self->priv->_dim = FALSE;
}

static void
gala_extended_behavior_window_finalize (GObject * obj)
{
	GalaExtendedBehaviorWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW, GalaExtendedBehaviorWindow);
	G_OBJECT_CLASS (gala_extended_behavior_window_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_extended_behavior_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaExtendedBehaviorWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_extended_behavior_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaExtendedBehaviorWindow), 0, (GInstanceInitFunc) gala_extended_behavior_window_instance_init, NULL };
	GType gala_extended_behavior_window_type_id;
	gala_extended_behavior_window_type_id = g_type_register_static (GALA_TYPE_SHELL_WINDOW, "GalaExtendedBehaviorWindow", &g_define_type_info, 0);
	GalaExtendedBehaviorWindow_private_offset = g_type_add_instance_private (gala_extended_behavior_window_type_id, sizeof (GalaExtendedBehaviorWindowPrivate));
	return gala_extended_behavior_window_type_id;
}

GType
gala_extended_behavior_window_get_type (void)
{
	static gsize gala_extended_behavior_window_type_id__once = 0;
	if (g_once_init_enter (&gala_extended_behavior_window_type_id__once)) {
		GType gala_extended_behavior_window_type_id;
		gala_extended_behavior_window_type_id = gala_extended_behavior_window_get_type_once ();
		g_once_init_leave (&gala_extended_behavior_window_type_id__once, gala_extended_behavior_window_type_id);
	}
	return gala_extended_behavior_window_type_id__once;
}

static void
_vala_gala_extended_behavior_window_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec)
{
	GalaExtendedBehaviorWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW, GalaExtendedBehaviorWindow);
	switch (property_id) {
		case GALA_EXTENDED_BEHAVIOR_WINDOW_MODAL_PROPERTY:
		g_value_set_boolean (value, gala_extended_behavior_window_get_modal (self));
		break;
		case GALA_EXTENDED_BEHAVIOR_WINDOW_DIM_PROPERTY:
		g_value_set_boolean (value, gala_extended_behavior_window_get_dim (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_extended_behavior_window_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec)
{
	GalaExtendedBehaviorWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_EXTENDED_BEHAVIOR_WINDOW, GalaExtendedBehaviorWindow);
	switch (property_id) {
		case GALA_EXTENDED_BEHAVIOR_WINDOW_MODAL_PROPERTY:
		gala_extended_behavior_window_set_modal (self, g_value_get_boolean (value));
		break;
		case GALA_EXTENDED_BEHAVIOR_WINDOW_DIM_PROPERTY:
		gala_extended_behavior_window_set_dim (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

