/* IBusCandidateWindow.c generated by valac 0.56.19, the Vala compiler
 * generated from IBusCandidateWindow.vala, do not modify */

/*
 * Copyright 2026 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 <clutter/clutter.h>
#include <meta/window.h>
#include <graphene-gobject.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_IBUS_CANDIDATE_WINDOW (gala_ibus_candidate_window_get_type ())
#define GALA_IBUS_CANDIDATE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_IBUS_CANDIDATE_WINDOW, GalaIBusCandidateWindow))
#define GALA_IBUS_CANDIDATE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_IBUS_CANDIDATE_WINDOW, GalaIBusCandidateWindowClass))
#define GALA_IS_IBUS_CANDIDATE_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_IBUS_CANDIDATE_WINDOW))
#define GALA_IS_IBUS_CANDIDATE_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_IBUS_CANDIDATE_WINDOW))
#define GALA_IBUS_CANDIDATE_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_IBUS_CANDIDATE_WINDOW, GalaIBusCandidateWindowClass))

typedef struct _GalaIBusCandidateWindow GalaIBusCandidateWindow;
typedef struct _GalaIBusCandidateWindowClass GalaIBusCandidateWindowClass;
typedef struct _GalaIBusCandidateWindowPrivate GalaIBusCandidateWindowPrivate;

#define GALA_TYPE_INPUT_METHOD (gala_input_method_get_type ())
#define GALA_INPUT_METHOD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_INPUT_METHOD, GalaInputMethod))
#define GALA_INPUT_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_INPUT_METHOD, GalaInputMethodClass))
#define GALA_IS_INPUT_METHOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_INPUT_METHOD))
#define GALA_IS_INPUT_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_INPUT_METHOD))
#define GALA_INPUT_METHOD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_INPUT_METHOD, GalaInputMethodClass))

typedef struct _GalaInputMethod GalaInputMethod;
typedef struct _GalaInputMethodClass GalaInputMethodClass;
enum  {
	GALA_IBUS_CANDIDATE_WINDOW_0_PROPERTY,
	GALA_IBUS_CANDIDATE_WINDOW_IM_PROPERTY,
	GALA_IBUS_CANDIDATE_WINDOW_NUM_PROPERTIES
};
static GParamSpec* gala_ibus_candidate_window_properties[GALA_IBUS_CANDIDATE_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 _GalaIBusCandidateWindow {
	GalaPositionedWindow parent_instance;
	GalaIBusCandidateWindowPrivate * priv;
};

struct _GalaIBusCandidateWindowClass {
	GalaPositionedWindowClass parent_class;
};

struct _GalaIBusCandidateWindowPrivate {
	GalaInputMethod* _im;
};

static gint GalaIBusCandidateWindow_private_offset;
static gpointer gala_ibus_candidate_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_ibus_candidate_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaIBusCandidateWindow, g_object_unref)
VALA_EXTERN GType gala_input_method_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaInputMethod, g_object_unref)
VALA_EXTERN void gala_positioned_window_get_window_position (GalaPositionedWindow* self,
                                                 MtkRectangle* window_rect,
                                                 gint* x,
                                                 gint* y);
VALA_EXTERN GalaIBusCandidateWindow* gala_ibus_candidate_window_new (GalaInputMethod* im,
                                                         MetaWindow* window);
VALA_EXTERN GalaIBusCandidateWindow* gala_ibus_candidate_window_construct (GType object_type,
                                                               GalaInputMethod* im,
                                                               MetaWindow* window);
static void gala_ibus_candidate_window_real_get_window_position (GalaPositionedWindow* base,
                                                          MtkRectangle* window_rect,
                                                          gint* x,
                                                          gint* y);
VALA_EXTERN GalaInputMethod* gala_ibus_candidate_window_get_im (GalaIBusCandidateWindow* self);
VALA_EXTERN void gala_input_method_get_cursor_location (GalaInputMethod* self,
                                            graphene_rect_t * result);
static void gala_ibus_candidate_window_set_im (GalaIBusCandidateWindow* self,
                                        GalaInputMethod* value);
static GObject * gala_ibus_candidate_window_constructor (GType type,
                                                  guint n_construct_properties,
                                                  GObjectConstructParam * construct_properties);
VALA_EXTERN void gala_positioned_window_position_window (GalaPositionedWindow* self);
static void _gala_positioned_window_position_window_g_object_notify (GObject* _sender,
                                                              GParamSpec* pspec,
                                                              gpointer self);
static void gala_ibus_candidate_window_finalize (GObject * obj);
static GType gala_ibus_candidate_window_get_type_once (void);
static void _vala_gala_ibus_candidate_window_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static void _vala_gala_ibus_candidate_window_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec);

static inline gpointer
gala_ibus_candidate_window_get_instance_private (GalaIBusCandidateWindow* self)
{
	return G_STRUCT_MEMBER_P (self, GalaIBusCandidateWindow_private_offset);
}

GalaIBusCandidateWindow*
gala_ibus_candidate_window_construct (GType object_type,
                                      GalaInputMethod* im,
                                      MetaWindow* window)
{
	GalaIBusCandidateWindow * self = NULL;
	g_return_val_if_fail (im != NULL, NULL);
	g_return_val_if_fail (window != NULL, NULL);
	self = (GalaIBusCandidateWindow*) g_object_new (object_type, "im", im, "window", window, NULL);
	return self;
}

GalaIBusCandidateWindow*
gala_ibus_candidate_window_new (GalaInputMethod* im,
                                MetaWindow* window)
{
	return gala_ibus_candidate_window_construct (GALA_TYPE_IBUS_CANDIDATE_WINDOW, im, window);
}

static void
gala_ibus_candidate_window_real_get_window_position (GalaPositionedWindow* base,
                                                     MtkRectangle* window_rect,
                                                     gint* x,
                                                     gint* y)
{
	GalaIBusCandidateWindow * self;
	gint _vala_x = 0;
	gint _vala_y = 0;
	GalaInputMethod* _tmp0_;
	graphene_rect_t _tmp1_ = {0};
	graphene_rect_t _tmp2_;
	graphene_point_t _tmp3_;
	GalaInputMethod* _tmp4_;
	graphene_rect_t _tmp5_ = {0};
	graphene_rect_t _tmp6_;
	graphene_size_t _tmp7_;
	GalaInputMethod* _tmp8_;
	graphene_rect_t _tmp9_ = {0};
	graphene_rect_t _tmp10_;
	graphene_point_t _tmp11_;
	GalaInputMethod* _tmp12_;
	graphene_rect_t _tmp13_ = {0};
	graphene_rect_t _tmp14_;
	graphene_size_t _tmp15_;
	self = (GalaIBusCandidateWindow*) base;
	g_return_if_fail (window_rect != NULL);
	_tmp0_ = self->priv->_im;
	gala_input_method_get_cursor_location (_tmp0_, &_tmp1_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_.origin;
	_tmp4_ = self->priv->_im;
	gala_input_method_get_cursor_location (_tmp4_, &_tmp5_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_.size;
	_vala_x = (gint) (_tmp3_.x + _tmp7_.width);
	_tmp8_ = self->priv->_im;
	gala_input_method_get_cursor_location (_tmp8_, &_tmp9_);
	_tmp10_ = _tmp9_;
	_tmp11_ = _tmp10_.origin;
	_tmp12_ = self->priv->_im;
	gala_input_method_get_cursor_location (_tmp12_, &_tmp13_);
	_tmp14_ = _tmp13_;
	_tmp15_ = _tmp14_.size;
	_vala_y = (gint) (_tmp11_.y + _tmp15_.height);
	if (x) {
		*x = _vala_x;
	}
	if (y) {
		*y = _vala_y;
	}
}

GalaInputMethod*
gala_ibus_candidate_window_get_im (GalaIBusCandidateWindow* self)
{
	GalaInputMethod* result;
	GalaInputMethod* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_im;
	result = _tmp0_;
	return result;
}

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

static void
gala_ibus_candidate_window_set_im (GalaIBusCandidateWindow* self,
                                   GalaInputMethod* value)
{
	GalaInputMethod* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_ibus_candidate_window_get_im (self);
	if (old_value != value) {
		GalaInputMethod* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_im);
		self->priv->_im = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_ibus_candidate_window_properties[GALA_IBUS_CANDIDATE_WINDOW_IM_PROPERTY]);
	}
}

static void
_gala_positioned_window_position_window_g_object_notify (GObject* _sender,
                                                         GParamSpec* pspec,
                                                         gpointer self)
{
	gala_positioned_window_position_window ((GalaPositionedWindow*) self);
}

static GObject *
gala_ibus_candidate_window_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaIBusCandidateWindow * self;
	GalaInputMethod* _tmp0_;
	parent_class = G_OBJECT_CLASS (gala_ibus_candidate_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_IBUS_CANDIDATE_WINDOW, GalaIBusCandidateWindow);
	_tmp0_ = self->priv->_im;
	g_signal_connect_object ((GObject*) _tmp0_, "notify::cursor-location", (GCallback) _gala_positioned_window_position_window_g_object_notify, (GalaPositionedWindow*) self, 0);
	return obj;
}

static void
gala_ibus_candidate_window_class_init (GalaIBusCandidateWindowClass * klass,
                                       gpointer klass_data)
{
	gala_ibus_candidate_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaIBusCandidateWindow_private_offset);
	((GalaPositionedWindowClass *) klass)->get_window_position = (void (*) (GalaPositionedWindow*, MtkRectangle*, gint*, gint*)) gala_ibus_candidate_window_real_get_window_position;
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_ibus_candidate_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_ibus_candidate_window_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_ibus_candidate_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_ibus_candidate_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_IBUS_CANDIDATE_WINDOW_IM_PROPERTY, gala_ibus_candidate_window_properties[GALA_IBUS_CANDIDATE_WINDOW_IM_PROPERTY] = g_param_spec_object ("im", "im", "im", GALA_TYPE_INPUT_METHOD, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_ibus_candidate_window_instance_init (GalaIBusCandidateWindow * self,
                                          gpointer klass)
{
	self->priv = gala_ibus_candidate_window_get_instance_private (self);
}

static void
gala_ibus_candidate_window_finalize (GObject * obj)
{
	GalaIBusCandidateWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_IBUS_CANDIDATE_WINDOW, GalaIBusCandidateWindow);
	_g_object_unref0 (self->priv->_im);
	G_OBJECT_CLASS (gala_ibus_candidate_window_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_ibus_candidate_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaIBusCandidateWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_ibus_candidate_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaIBusCandidateWindow), 0, (GInstanceInitFunc) gala_ibus_candidate_window_instance_init, NULL };
	GType gala_ibus_candidate_window_type_id;
	gala_ibus_candidate_window_type_id = g_type_register_static (GALA_TYPE_POSITIONED_WINDOW, "GalaIBusCandidateWindow", &g_define_type_info, G_TYPE_FLAG_NONE);
	GalaIBusCandidateWindow_private_offset = g_type_add_instance_private (gala_ibus_candidate_window_type_id, sizeof (GalaIBusCandidateWindowPrivate));
	return gala_ibus_candidate_window_type_id;
}

GType
gala_ibus_candidate_window_get_type (void)
{
	static gsize gala_ibus_candidate_window_type_id__once = 0;
	if (g_once_init_enter (&gala_ibus_candidate_window_type_id__once)) {
		GType gala_ibus_candidate_window_type_id;
		gala_ibus_candidate_window_type_id = gala_ibus_candidate_window_get_type_once ();
		g_once_init_leave (&gala_ibus_candidate_window_type_id__once, gala_ibus_candidate_window_type_id);
	}
	return gala_ibus_candidate_window_type_id__once;
}

static void
_vala_gala_ibus_candidate_window_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	GalaIBusCandidateWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_IBUS_CANDIDATE_WINDOW, GalaIBusCandidateWindow);
	switch (property_id) {
		case GALA_IBUS_CANDIDATE_WINDOW_IM_PROPERTY:
		g_value_set_object (value, gala_ibus_candidate_window_get_im (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_ibus_candidate_window_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec)
{
	GalaIBusCandidateWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_IBUS_CANDIDATE_WINDOW, GalaIBusCandidateWindow);
	switch (property_id) {
		case GALA_IBUS_CANDIDATE_WINDOW_IM_PROPERTY:
		gala_ibus_candidate_window_set_im (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

