/* OSKWindow.c generated by valac 0.56.19, the Vala compiler
 * generated from OSKWindow.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 "gala.h"
#include <float.h>
#include <math.h>
#include <clutter/clutter.h>
#include <meta/window.h>
#include <meta/display.h>
#include <graphene-gobject.h>
#include <meta/meta-window-actor.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_OSK_WINDOW (gala_osk_window_get_type ())
#define GALA_OSK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_OSK_WINDOW, GalaOSKWindow))
#define GALA_OSK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_OSK_WINDOW, GalaOSKWindowClass))
#define GALA_IS_OSK_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_OSK_WINDOW))
#define GALA_IS_OSK_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_OSK_WINDOW))
#define GALA_OSK_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_OSK_WINDOW, GalaOSKWindowClass))

typedef struct _GalaOSKWindow GalaOSKWindow;
typedef struct _GalaOSKWindowClass GalaOSKWindowClass;
typedef struct _GalaOSKWindowPrivate GalaOSKWindowPrivate;

#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;

#define GALA_TYPE_OSK_FOCUS_TRACKER (gala_osk_focus_tracker_get_type ())
#define GALA_OSK_FOCUS_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_OSK_FOCUS_TRACKER, GalaOSKFocusTracker))
#define GALA_OSK_FOCUS_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_OSK_FOCUS_TRACKER, GalaOSKFocusTrackerClass))
#define GALA_IS_OSK_FOCUS_TRACKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_OSK_FOCUS_TRACKER))
#define GALA_IS_OSK_FOCUS_TRACKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_OSK_FOCUS_TRACKER))
#define GALA_OSK_FOCUS_TRACKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_OSK_FOCUS_TRACKER, GalaOSKFocusTrackerClass))

typedef struct _GalaOSKFocusTracker GalaOSKFocusTracker;
typedef struct _GalaOSKFocusTrackerClass GalaOSKFocusTrackerClass;
enum  {
	GALA_OSK_WINDOW_0_PROPERTY,
	GALA_OSK_WINDOW_IM_PROPERTY,
	GALA_OSK_WINDOW_ACTOR_PROPERTY,
	GALA_OSK_WINDOW_NUM_PROPERTIES
};
static GParamSpec* gala_osk_window_properties[GALA_OSK_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 _GalaOSKWindow {
	GalaShellWindow parent_instance;
	GalaOSKWindowPrivate * priv;
};

struct _GalaOSKWindowClass {
	GalaShellWindowClass parent_class;
};

struct _GalaOSKWindowPrivate {
	GalaInputMethod* _im;
	GalaGestureController* gesture_controller;
	GalaOSKFocusTracker* focus_tracker;
	MetaWindow* focus_window;
};

static gint GalaOSKWindow_private_offset;
static gpointer gala_osk_window_parent_class = NULL;
static GalaRootTargetIface * gala_osk_window_gala_root_target_parent_iface = 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_osk_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaOSKWindow, 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 GType gala_osk_focus_tracker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaOSKFocusTracker, g_object_unref)
VALA_EXTERN gdouble gala_shell_window_get_hidden_progress (GalaShellWindow* self);
VALA_EXTERN void gala_positioned_window_get_window_position (GalaPositionedWindow* self,
                                                 MtkRectangle* window_rect,
                                                 gint* x,
                                                 gint* y);
VALA_EXTERN GalaOSKWindow* gala_osk_window_new (GalaInputMethod* im,
                                    MetaWindow* window);
VALA_EXTERN GalaOSKWindow* gala_osk_window_construct (GType object_type,
                                          GalaInputMethod* im,
                                          MetaWindow* window);
static void gala_osk_window_update_target (GalaOSKWindow* self);
VALA_EXTERN MetaWindow* gala_positioned_window_get_window (GalaPositionedWindow* self);
VALA_EXTERN void gala_shell_window_set_hide_target (GalaShellWindow* self,
                                        GalaGestureTarget* value);
static void gala_osk_window_sync_visible (GalaOSKWindow* self);
static GalaInputMethod* gala_osk_window_get_im (GalaOSKWindow* self);
VALA_EXTERN gboolean gala_input_method_get_input_panel_active (GalaInputMethod* self);
static void gala_osk_window_update_focus_window (GalaOSKWindow* self);
VALA_EXTERN MetaWindow* gala_osk_focus_tracker_get_current_focus_window (GalaOSKFocusTracker* self);
static void gala_osk_window_update_window_offset (GalaOSKWindow* self,
                                           MetaWindow* window,
                                           gfloat translation,
                                           gboolean animate);
static void gala_osk_window_update_focus_window_offset (GalaOSKWindow* self);
static gfloat gala_osk_window_calculate_window_offset (GalaOSKWindow* self,
                                                graphene_rect_t* cursor_rect);
VALA_EXTERN void gala_input_method_get_cursor_location (GalaInputMethod* self,
                                            graphene_rect_t * result);
static gdouble gala_osk_window_real_get_hidden_progress (GalaShellWindow* base);
static void gala_osk_window_real_get_window_position (GalaPositionedWindow* base,
                                               MtkRectangle* window_rect,
                                               gint* x,
                                               gint* y);
VALA_EXTERN gint gala_osk_focus_tracker_get_current_monitor (GalaOSKFocusTracker* self);
static void gala_osk_window_set_im (GalaOSKWindow* self,
                             GalaInputMethod* value);
static GObject * gala_osk_window_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties);
static void _gala_osk_window_update_target_meta_window_size_changed (MetaWindow* _sender,
                                                              gpointer self);
static void _gala_osk_window_update_target_meta_window_shown (MetaWindow* _sender,
                                                       gpointer self);
static void _gala_osk_window_sync_visible_g_object_notify (GObject* _sender,
                                                    GParamSpec* pspec,
                                                    gpointer self);
static void _gala_osk_window_sync_visible_meta_window_shown (MetaWindow* _sender,
                                                      gpointer self);
VALA_EXTERN GalaOSKFocusTracker* gala_osk_focus_tracker_new (MetaDisplay* display,
                                                 GalaInputMethod* im);
VALA_EXTERN GalaOSKFocusTracker* gala_osk_focus_tracker_construct (GType object_type,
                                                       MetaDisplay* display,
                                                       GalaInputMethod* im);
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_osk_window_update_focus_window_g_object_notify (GObject* _sender,
                                                           GParamSpec* pspec,
                                                           gpointer self);
static void _gala_osk_window_update_focus_window_offset_g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self);
static void gala_osk_window_finalize (GObject * obj);
static GType gala_osk_window_get_type_once (void);
static void _vala_gala_osk_window_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_gala_osk_window_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);

static inline gpointer
gala_osk_window_get_instance_private (GalaOSKWindow* self)
{
	return G_STRUCT_MEMBER_P (self, GalaOSKWindow_private_offset);
}

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

GalaOSKWindow*
gala_osk_window_new (GalaInputMethod* im,
                     MetaWindow* window)
{
	return gala_osk_window_construct (GALA_TYPE_OSK_WINDOW, im, window);
}

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

static void
gala_osk_window_update_target (GalaOSKWindow* self)
{
	ClutterActor* actor = NULL;
	MetaWindow* _tmp0_;
	MetaWindow* _tmp1_;
	GObject* _tmp2_;
	ClutterActor* _tmp3_;
	GValue _tmp4_ = {0};
	gfloat _tmp5_;
	gfloat _tmp6_;
	GValue _tmp7_ = {0};
	GalaPropertyTarget* _tmp8_;
	GalaPropertyTarget* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = meta_window_get_compositor_private (_tmp1_);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, clutter_actor_get_type (), ClutterActor));
	actor = _tmp3_;
	g_value_init (&_tmp4_, G_TYPE_FLOAT);
	g_value_set_float (&_tmp4_, 0.f);
	_tmp5_ = clutter_actor_get_height (actor);
	_tmp6_ = _tmp5_;
	g_value_init (&_tmp7_, G_TYPE_FLOAT);
	g_value_set_float (&_tmp7_, _tmp6_);
	_tmp8_ = gala_property_target_new (GALA_GESTURE_ACTION_CUSTOM, (GObject*) actor, "translation-y", G_TYPE_FLOAT, &_tmp4_, &_tmp7_);
	_tmp9_ = _tmp8_;
	gala_shell_window_set_hide_target ((GalaShellWindow*) self, (GalaGestureTarget*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	G_IS_VALUE (&_tmp7_) ? (g_value_unset (&_tmp7_), NULL) : NULL;
	G_IS_VALUE (&_tmp4_) ? (g_value_unset (&_tmp4_), NULL) : NULL;
	_g_object_unref0 (actor);
}

static void
gala_osk_window_sync_visible (GalaOSKWindow* self)
{
	GalaInputMethod* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_im;
	_tmp1_ = gala_input_method_get_input_panel_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GalaGestureController* _tmp3_;
		_tmp3_ = self->priv->gesture_controller;
		gala_gesture_controller_goto (_tmp3_, (gdouble) 0);
	} else {
		GalaGestureController* _tmp4_;
		_tmp4_ = self->priv->gesture_controller;
		gala_gesture_controller_goto (_tmp4_, (gdouble) 1);
	}
}

static void
gala_osk_window_update_focus_window (GalaOSKWindow* self)
{
	MetaWindow* _tmp0_;
	GalaOSKFocusTracker* _tmp1_;
	MetaWindow* _tmp2_;
	MetaWindow* _tmp3_;
	MetaWindow* _tmp4_;
	GalaOSKFocusTracker* _tmp9_;
	MetaWindow* _tmp10_;
	MetaWindow* _tmp11_;
	MetaWindow* _tmp12_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->focus_window;
	_tmp1_ = self->priv->focus_tracker;
	_tmp2_ = gala_osk_focus_tracker_get_current_focus_window (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp0_ == _tmp3_) {
		return;
	}
	_tmp4_ = self->priv->focus_window;
	if (_tmp4_ != NULL) {
		MetaWindow* _tmp5_;
		MetaWindow* _tmp6_;
		MetaWindow* _tmp7_;
		MetaDisplay* _tmp8_;
		_tmp5_ = self->priv->focus_window;
		_tmp6_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = meta_window_get_display (_tmp7_);
		gala_osk_window_update_window_offset (self, _tmp5_, (gfloat) 0, !meta_display_is_grabbed (_tmp8_));
	}
	_tmp9_ = self->priv->focus_tracker;
	_tmp10_ = gala_osk_focus_tracker_get_current_focus_window (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = _g_object_ref0 (_tmp11_);
	_g_object_unref0 (self->priv->focus_window);
	self->priv->focus_window = _tmp12_;
	gala_osk_window_update_focus_window_offset (self);
}

static void
gala_osk_window_update_focus_window_offset (GalaOSKWindow* self)
{
	MetaWindow* _tmp0_;
	gfloat offset = 0.0F;
	GalaInputMethod* _tmp1_;
	graphene_rect_t _tmp2_ = {0};
	graphene_rect_t _tmp3_;
	MetaWindow* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->focus_window;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->_im;
	gala_input_method_get_cursor_location (_tmp1_, &_tmp2_);
	_tmp3_ = _tmp2_;
	offset = gala_osk_window_calculate_window_offset (self, &_tmp3_);
	_tmp4_ = self->priv->focus_window;
	gala_osk_window_update_window_offset (self, _tmp4_, offset, TRUE);
}

static gfloat
gala_osk_window_calculate_window_offset (GalaOSKWindow* self,
                                         graphene_rect_t* cursor_rect)
{
	MtkRectangle keyboard_rect = {0};
	MetaWindow* _tmp0_;
	MetaWindow* _tmp1_;
	MtkRectangle _tmp2_ = {0};
	MtkRectangle _tmp3_;
	gfloat result;
	g_return_val_if_fail (self != NULL, -1.0F);
	g_return_val_if_fail (cursor_rect != NULL, -1.0F);
	_tmp0_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp1_ = _tmp0_;
	meta_window_get_frame_rect (_tmp1_, &_tmp2_);
	keyboard_rect = _tmp2_;
	_tmp3_ = keyboard_rect;
	if ((graphene_rect_get_y (cursor_rect) + graphene_rect_get_height (cursor_rect)) > ((gfloat) _tmp3_.y)) {
		MtkRectangle _tmp4_;
		_tmp4_ = keyboard_rect;
		result = (gfloat) (_tmp4_.y - (graphene_rect_get_y (cursor_rect) + graphene_rect_get_height (cursor_rect)));
		return result;
	}
	result = 0.f;
	return result;
}

static void
gala_osk_window_update_window_offset (GalaOSKWindow* self,
                                      MetaWindow* window,
                                      gfloat translation,
                                      gboolean animate)
{
	MetaWindowActor* window_actor = NULL;
	GObject* _tmp0_;
	MetaWindowActor* _tmp1_;
	MetaWindowActor* _tmp4_;
	MetaWindowActor* _tmp5_;
	MetaWindowActor* _tmp6_;
	MetaWindowActor* _tmp7_;
	MetaWindowActor* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	_tmp0_ = meta_window_get_compositor_private (window);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, meta_window_actor_get_type (), MetaWindowActor));
	window_actor = _tmp1_;
	if (!animate) {
		MetaWindowActor* _tmp2_;
		MetaWindowActor* _tmp3_;
		_tmp2_ = window_actor;
		clutter_actor_remove_all_transitions ((ClutterActor*) _tmp2_);
		_tmp3_ = window_actor;
		g_object_set ((ClutterActor*) _tmp3_, "translation-y", translation, NULL);
		_g_object_unref0 (window_actor);
		return;
	}
	_tmp4_ = window_actor;
	clutter_actor_save_easing_state ((ClutterActor*) _tmp4_);
	_tmp5_ = window_actor;
	clutter_actor_set_easing_duration ((ClutterActor*) _tmp5_, (guint) 200);
	_tmp6_ = window_actor;
	clutter_actor_set_easing_mode ((ClutterActor*) _tmp6_, CLUTTER_EASE);
	_tmp7_ = window_actor;
	g_object_set ((ClutterActor*) _tmp7_, "translation-y", translation, NULL);
	_tmp8_ = window_actor;
	clutter_actor_restore_easing_state ((ClutterActor*) _tmp8_);
	_g_object_unref0 (window_actor);
}

static gdouble
gala_osk_window_real_get_hidden_progress (GalaShellWindow* base)
{
	GalaOSKWindow * self;
	GalaGestureController* _tmp0_;
	gdouble _tmp1_;
	gdouble _tmp2_;
	gdouble result;
	self = (GalaOSKWindow*) base;
	_tmp0_ = self->priv->gesture_controller;
	_tmp1_ = gala_gesture_controller_get_progress (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
gala_osk_window_real_get_window_position (GalaPositionedWindow* base,
                                          MtkRectangle* window_rect,
                                          gint* x,
                                          gint* y)
{
	GalaOSKWindow * self;
	gint _vala_x = 0;
	gint _vala_y = 0;
	MtkRectangle monitor_geom = {0};
	MetaWindow* _tmp0_;
	MetaWindow* _tmp1_;
	MetaDisplay* _tmp2_;
	MetaDisplay* _tmp3_;
	GalaOSKFocusTracker* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	MtkRectangle _tmp7_ = {0};
	MtkRectangle _tmp8_;
	MtkRectangle _tmp9_;
	MtkRectangle _tmp10_;
	MtkRectangle _tmp11_;
	MtkRectangle _tmp12_;
	MtkRectangle _tmp13_;
	self = (GalaOSKWindow*) 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_ = self->priv->focus_tracker;
	_tmp5_ = gala_osk_focus_tracker_get_current_monitor (_tmp4_);
	_tmp6_ = _tmp5_;
	meta_display_get_monitor_geometry (_tmp3_, _tmp6_, &_tmp7_);
	monitor_geom = _tmp7_;
	_tmp8_ = monitor_geom;
	_tmp9_ = monitor_geom;
	_tmp10_ = *window_rect;
	_vala_x = _tmp8_.x + ((_tmp9_.width - _tmp10_.width) / 2);
	_tmp11_ = monitor_geom;
	_tmp12_ = monitor_geom;
	_tmp13_ = *window_rect;
	_vala_y = (_tmp11_.y + _tmp12_.height) - _tmp13_.height;
	if (x) {
		*x = _vala_x;
	}
	if (y) {
		*y = _vala_y;
	}
}

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

static void
gala_osk_window_set_im (GalaOSKWindow* self,
                        GalaInputMethod* value)
{
	GalaInputMethod* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_osk_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_osk_window_properties[GALA_OSK_WINDOW_IM_PROPERTY]);
	}
}

static ClutterActor*
gala_osk_window_real_get_actor (GalaRootTarget* base)
{
	ClutterActor* result;
	GalaOSKWindow* self;
	MetaWindow* _tmp0_;
	MetaWindow* _tmp1_;
	GObject* _tmp2_;
	self = (GalaOSKWindow*) base;
	_tmp0_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = meta_window_get_compositor_private (_tmp1_);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, clutter_actor_get_type (), ClutterActor);
	return result;
}

static void
_gala_osk_window_update_target_meta_window_size_changed (MetaWindow* _sender,
                                                         gpointer self)
{
	gala_osk_window_update_target ((GalaOSKWindow*) self);
}

static void
_gala_osk_window_update_target_meta_window_shown (MetaWindow* _sender,
                                                  gpointer self)
{
	gala_osk_window_update_target ((GalaOSKWindow*) self);
}

static void
_gala_osk_window_sync_visible_g_object_notify (GObject* _sender,
                                               GParamSpec* pspec,
                                               gpointer self)
{
	gala_osk_window_sync_visible ((GalaOSKWindow*) self);
}

static void
_gala_osk_window_sync_visible_meta_window_shown (MetaWindow* _sender,
                                                 gpointer self)
{
	gala_osk_window_sync_visible ((GalaOSKWindow*) self);
}

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

static void
_gala_osk_window_update_focus_window_g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self)
{
	gala_osk_window_update_focus_window ((GalaOSKWindow*) self);
}

static void
_gala_osk_window_update_focus_window_offset_g_object_notify (GObject* _sender,
                                                             GParamSpec* pspec,
                                                             gpointer self)
{
	gala_osk_window_update_focus_window_offset ((GalaOSKWindow*) self);
}

static GObject *
gala_osk_window_constructor (GType type,
                             guint n_construct_properties,
                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaOSKWindow * self;
	GalaGestureController* _tmp0_ = NULL;
	GalaGestureController* _tmp1_;
	MetaWindow* _tmp2_;
	MetaWindow* _tmp3_;
	MetaWindow* _tmp4_;
	MetaWindow* _tmp5_;
	GalaInputMethod* _tmp6_;
	MetaWindow* _tmp7_;
	MetaWindow* _tmp8_;
	MetaWindow* _tmp9_;
	MetaWindow* _tmp10_;
	MetaDisplay* _tmp11_;
	GalaInputMethod* _tmp12_;
	GalaOSKFocusTracker* _tmp13_;
	GalaOSKFocusTracker* _tmp14_;
	GalaOSKFocusTracker* _tmp15_;
	GalaInputMethod* _tmp16_;
	parent_class = G_OBJECT_CLASS (gala_osk_window_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_OSK_WINDOW, GalaOSKWindow);
	_tmp0_ = gala_gesture_controller_new (GALA_GESTURE_ACTION_CUSTOM);
	gala_gesture_controller_set_progress (_tmp0_, (gdouble) 1);
	_g_object_unref0 (self->priv->gesture_controller);
	self->priv->gesture_controller = _tmp0_;
	_tmp1_ = self->priv->gesture_controller;
	gala_root_target_add_gesture_controller ((GalaRootTarget*) self, _tmp1_);
	_tmp2_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp3_ = _tmp2_;
	g_signal_connect_object (_tmp3_, "size-changed", (GCallback) _gala_osk_window_update_target_meta_window_size_changed, self, 0);
	_tmp4_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp5_ = _tmp4_;
	g_signal_connect_object (_tmp5_, "shown", (GCallback) _gala_osk_window_update_target_meta_window_shown, self, 0);
	_tmp6_ = self->priv->_im;
	g_signal_connect_object ((GObject*) _tmp6_, "notify::input-panel-active", (GCallback) _gala_osk_window_sync_visible_g_object_notify, self, 0);
	_tmp7_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp8_ = _tmp7_;
	g_signal_connect_object (_tmp8_, "shown", (GCallback) _gala_osk_window_sync_visible_meta_window_shown, self, 0);
	_tmp9_ = gala_positioned_window_get_window ((GalaPositionedWindow*) self);
	_tmp10_ = _tmp9_;
	_tmp11_ = meta_window_get_display (_tmp10_);
	_tmp12_ = self->priv->_im;
	_tmp13_ = gala_osk_focus_tracker_new (_tmp11_, _tmp12_);
	_g_object_unref0 (self->priv->focus_tracker);
	self->priv->focus_tracker = _tmp13_;
	_tmp14_ = self->priv->focus_tracker;
	g_signal_connect_object ((GObject*) _tmp14_, "notify::current-monitor", (GCallback) _gala_positioned_window_position_window_g_object_notify, (GalaPositionedWindow*) self, 0);
	_tmp15_ = self->priv->focus_tracker;
	g_signal_connect_object ((GObject*) _tmp15_, "notify::current-focus-window", (GCallback) _gala_osk_window_update_focus_window_g_object_notify, self, 0);
	gala_osk_window_update_focus_window (self);
	_tmp16_ = self->priv->_im;
	g_signal_connect_object ((GObject*) _tmp16_, "notify::cursor-location", (GCallback) _gala_osk_window_update_focus_window_offset_g_object_notify, self, 0);
	return obj;
}

static void
gala_osk_window_class_init (GalaOSKWindowClass * klass,
                            gpointer klass_data)
{
	gala_osk_window_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaOSKWindow_private_offset);
	((GalaShellWindowClass *) klass)->get_hidden_progress = (gdouble (*) (GalaShellWindow*)) gala_osk_window_real_get_hidden_progress;
	((GalaPositionedWindowClass *) klass)->get_window_position = (void (*) (GalaPositionedWindow*, MtkRectangle*, gint*, gint*)) gala_osk_window_real_get_window_position;
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_osk_window_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_osk_window_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_osk_window_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_osk_window_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_OSK_WINDOW_IM_PROPERTY, gala_osk_window_properties[GALA_OSK_WINDOW_IM_PROPERTY] = g_param_spec_object ("im", "im", "im", GALA_TYPE_INPUT_METHOD, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_OSK_WINDOW_ACTOR_PROPERTY, gala_osk_window_properties[GALA_OSK_WINDOW_ACTOR_PROPERTY] = g_param_spec_object ("actor", "actor", "actor", clutter_actor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gala_osk_window_gala_root_target_interface_init (GalaRootTargetIface * iface,
                                                 gpointer iface_data)
{
	gala_osk_window_gala_root_target_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_actor = gala_osk_window_real_get_actor;
}

static void
gala_osk_window_instance_init (GalaOSKWindow * self,
                               gpointer klass)
{
	self->priv = gala_osk_window_get_instance_private (self);
}

static void
gala_osk_window_finalize (GObject * obj)
{
	GalaOSKWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_OSK_WINDOW, GalaOSKWindow);
	_g_object_unref0 (self->priv->_im);
	_g_object_unref0 (self->priv->gesture_controller);
	_g_object_unref0 (self->priv->focus_tracker);
	_g_object_unref0 (self->priv->focus_window);
	G_OBJECT_CLASS (gala_osk_window_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_osk_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaOSKWindowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_osk_window_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaOSKWindow), 0, (GInstanceInitFunc) gala_osk_window_instance_init, NULL };
	static const GInterfaceInfo gala_root_target_info = { (GInterfaceInitFunc) gala_osk_window_gala_root_target_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gala_osk_window_type_id;
	gala_osk_window_type_id = g_type_register_static (GALA_TYPE_SHELL_WINDOW, "GalaOSKWindow", &g_define_type_info, G_TYPE_FLAG_NONE);
	g_type_add_interface_static (gala_osk_window_type_id, GALA_TYPE_ROOT_TARGET, &gala_root_target_info);
	GalaOSKWindow_private_offset = g_type_add_instance_private (gala_osk_window_type_id, sizeof (GalaOSKWindowPrivate));
	return gala_osk_window_type_id;
}

GType
gala_osk_window_get_type (void)
{
	static gsize gala_osk_window_type_id__once = 0;
	if (g_once_init_enter (&gala_osk_window_type_id__once)) {
		GType gala_osk_window_type_id;
		gala_osk_window_type_id = gala_osk_window_get_type_once ();
		g_once_init_leave (&gala_osk_window_type_id__once, gala_osk_window_type_id);
	}
	return gala_osk_window_type_id__once;
}

static void
_vala_gala_osk_window_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	GalaOSKWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_OSK_WINDOW, GalaOSKWindow);
	switch (property_id) {
		case GALA_OSK_WINDOW_IM_PROPERTY:
		g_value_set_object (value, gala_osk_window_get_im (self));
		break;
		case GALA_OSK_WINDOW_ACTOR_PROPERTY:
		g_value_set_object (value, gala_root_target_get_actor ((GalaRootTarget*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_osk_window_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	GalaOSKWindow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_OSK_WINDOW, GalaOSKWindow);
	switch (property_id) {
		case GALA_OSK_WINDOW_IM_PROPERTY:
		gala_osk_window_set_im (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

