/* InputMethod.c generated by valac 0.56.19, the Vala compiler
 * generated from InputMethod.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 <clutter/clutter.h>
#include <glib-object.h>
#include <meta/display.h>
#include <graphene-gobject.h>
#include <glib.h>
#include <ibus.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.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_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;
typedef struct _GalaInputMethodPrivate GalaInputMethodPrivate;

#define GALA_TYPE_OSK_MANAGER (gala_osk_manager_get_type ())
#define GALA_OSK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_OSK_MANAGER, GalaOSKManager))
#define GALA_OSK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_OSK_MANAGER, GalaOSKManagerClass))
#define GALA_IS_OSK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_OSK_MANAGER))
#define GALA_IS_OSK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_OSK_MANAGER))
#define GALA_OSK_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_OSK_MANAGER, GalaOSKManagerClass))

typedef struct _GalaOSKManager GalaOSKManager;
typedef struct _GalaOSKManagerClass GalaOSKManagerClass;
enum  {
	GALA_INPUT_METHOD_0_PROPERTY,
	GALA_INPUT_METHOD_DISPLAY_PROPERTY,
	GALA_INPUT_METHOD_CURSOR_LOCATION_PROPERTY,
	GALA_INPUT_METHOD_INPUT_PANEL_ACTIVE_PROPERTY,
	GALA_INPUT_METHOD_NUM_PROPERTIES
};
static GParamSpec* gala_input_method_properties[GALA_INPUT_METHOD_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __vala_ClutterEvent_free0(var) ((var == NULL) ? NULL : (var = (_vala_ClutterEvent_free (var), NULL)))
typedef struct _Block30Data Block30Data;

struct _GalaInputMethod {
	ClutterInputMethod parent_instance;
	GalaInputMethodPrivate * priv;
};

struct _GalaInputMethodClass {
	ClutterInputMethodClass parent_class;
};

struct _GalaInputMethodPrivate {
	MetaDisplay* _display;
	graphene_rect_t _cursor_location;
	gboolean _input_panel_active;
	GalaOSKManager* osk_manager;
	IBusBus* bus;
	IBusInputContext* context;
	gboolean preedit_visible;
	gchar* preedit_text;
	guint preedit_cursor;
	guint preedit_anchor;
	ClutterPreeditResetMode preedit_mode;
	gchar* surrounding_text;
	guint surrounding_cursor;
	guint surrounding_anchor;
	IBusInputPurpose input_purpose;
	IBusInputHints input_hints;
};

struct _Block30Data {
	int _ref_count_;
	GalaInputMethod* self;
	ClutterEvent* event;
};

static gint GalaInputMethod_private_offset;
static gpointer gala_input_method_parent_class = NULL;

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_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaOSKManager, g_object_unref)
VALA_EXTERN GalaInputMethod* gala_input_method_new (MetaDisplay* display);
VALA_EXTERN GalaInputMethod* gala_input_method_construct (GType object_type,
                                              MetaDisplay* display);
static void gala_input_method_on_input_panel_state_changed (GalaInputMethod* self,
                                                     ClutterInputPanelState state);
static void gala_input_method_set_input_panel_active (GalaInputMethod* self,
                                               gboolean value);
VALA_EXTERN gboolean gala_input_method_get_input_panel_active (GalaInputMethod* self);
VALA_EXTERN void gala_osk_manager_reset (GalaOSKManager* self);
static void gala_input_method_on_connected (GalaInputMethod* self);
static void gala_input_method_on_input_context_created (GalaInputMethod* self,
                                                 GObject* obj,
                                                 GAsyncResult* res);
static void _gala_input_method_on_input_context_created_gasync_ready_callback (GObject* source_object,
                                                                        GAsyncResult* res,
                                                                        gpointer self);
static void gala_input_method_on_commit_text (GalaInputMethod* self,
                                       IBusText* text);
static void _gala_input_method_on_commit_text_ibus_input_context_commit_text (IBusInputContext* _sender,
                                                                       IBusText* text,
                                                                       gpointer self);
static void gala_input_method_on_require_surrounding_text (GalaInputMethod* self);
static void _gala_input_method_on_require_surrounding_text_ibus_input_context_require_surrounding_text (IBusInputContext* _sender,
                                                                                                 gpointer self);
static void gala_input_method_on_delete_surrounding_text (GalaInputMethod* self,
                                                   gint offset,
                                                   guint length);
static void _gala_input_method_on_delete_surrounding_text_ibus_input_context_delete_surrounding_text (IBusInputContext* _sender,
                                                                                               gint offset,
                                                                                               guint n_chars,
                                                                                               gpointer self);
static void gala_input_method_on_update_preedit_text (GalaInputMethod* self,
                                               IBusText* text,
                                               guint cursor_pos,
                                               gboolean visible);
static void _gala_input_method_on_update_preedit_text_ibus_input_context_update_preedit_text (IBusInputContext* _sender,
                                                                                       IBusText* text,
                                                                                       guint cursor_pos,
                                                                                       gboolean visible,
                                                                                       gpointer self);
static void gala_input_method_on_update_preedit_text_with_mode (GalaInputMethod* self,
                                                         IBusText* text,
                                                         guint cursor_pos,
                                                         gboolean visible,
                                                         guint mode);
static void _gala_input_method_on_update_preedit_text_with_mode_ibus_input_context_update_preedit_text_with_mode (IBusInputContext* _sender,
                                                                                                           IBusText* text,
                                                                                                           guint cursor_pos,
                                                                                                           gboolean visible,
                                                                                                           guint mode,
                                                                                                           gpointer self);
static void gala_input_method_on_show_preedit_text (GalaInputMethod* self);
static void _gala_input_method_on_show_preedit_text_ibus_input_context_show_preedit_text (IBusInputContext* _sender,
                                                                                   gpointer self);
static void gala_input_method_on_hide_preedit_text (GalaInputMethod* self);
static void _gala_input_method_on_hide_preedit_text_ibus_input_context_hide_preedit_text (IBusInputContext* _sender,
                                                                                   gpointer self);
static void gala_input_method_on_forward_key_event (GalaInputMethod* self,
                                             guint keyval,
                                             guint keycode,
                                             guint _modifiers);
static void _gala_input_method_on_forward_key_event_ibus_input_context_forward_key_event (IBusInputContext* _sender,
                                                                                   guint keyval,
                                                                                   guint keycode,
                                                                                   guint modifiers,
                                                                                   gpointer self);
static void gala_input_method_on_destroy (GalaInputMethod* self);
static void _gala_input_method_on_destroy_ibus_proxy_destroy (IBusProxy* _sender,
                                                       gpointer self);
static void gala_input_method_update_capabilities (GalaInputMethod* self);
static MetaDisplay* gala_input_method_get_display (GalaInputMethod* self);
static void gala_input_method_maybe_request_surrounding (GalaInputMethod* self);
static void gala_input_method_real_focus_in (ClutterInputMethod* base,
                                      ClutterInputFocus* actor);
static void gala_input_method_real_focus_out (ClutterInputMethod* base);
static void gala_input_method_real_reset (ClutterInputMethod* base);
static void gala_input_method_real_set_cursor_location (ClutterInputMethod* base,
                                                 graphene_rect_t* rect);
static void gala_input_method_set_cursor_location (GalaInputMethod* self,
                                            graphene_rect_t * value);
static void gala_input_method_real_set_surrounding (ClutterInputMethod* base,
                                             const gchar* text,
                                             guint cursor_index,
                                             guint anchor_index);
static gboolean gala_input_method_real_filter_key_event (ClutterInputMethod* base,
                                                  ClutterEvent* event);
static ClutterEvent* _vala_ClutterEvent_copy (ClutterEvent* self);
static void _vala_ClutterEvent_free (ClutterEvent* self);
static Block30Data* block30_data_ref (Block30Data* _data30_);
static void block30_data_unref (void * _userdata_);
static void __lambda10_ (Block30Data* _data30_,
                  GObject* obj,
                  GAsyncResult* res);
static void ___lambda10__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void gala_input_method_real_update_content_hints (ClutterInputMethod* base,
                                                  ClutterInputContentHintFlags hints);
static void gala_input_method_real_update_content_purpose (ClutterInputMethod* base,
                                                    ClutterInputContentPurpose purpose);
VALA_EXTERN void gala_osk_manager_set_input_purpose (GalaOSKManager* self,
                                         IBusInputPurpose purpose);
static void gala_input_method_set_display (GalaInputMethod* self,
                                    MetaDisplay* value);
VALA_EXTERN void gala_input_method_get_cursor_location (GalaInputMethod* self,
                                            graphene_rect_t * result);
static gboolean _graphene_point_equal (const graphene_point_t * s1,
                                const graphene_point_t * s2);
static gboolean _graphene_size_equal (const graphene_size_t * s1,
                               const graphene_size_t * s2);
static gboolean _graphene_rect_equal (const graphene_rect_t * s1,
                               const graphene_rect_t * s2);
static GObject * gala_input_method_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
VALA_EXTERN GalaOSKManager* gala_osk_manager_new (MetaDisplay* display);
VALA_EXTERN GalaOSKManager* gala_osk_manager_construct (GType object_type,
                                            MetaDisplay* display);
static void _gala_input_method___lambda11_ (GalaInputMethod* self);
static void __gala_input_method___lambda11__gala_osk_manager_input_panel_deactivation_requested (GalaOSKManager* _sender,
                                                                                          gpointer self);
static void _gala_input_method_on_input_panel_state_changed_clutter_input_method_input_panel_state (ClutterInputMethod* _sender,
                                                                                             ClutterInputPanelState object,
                                                                                             gpointer self);
static void _gala_input_method_on_connected_ibus_bus_connected (IBusBus* _sender,
                                                         gpointer self);
static void gala_input_method_finalize (GObject * obj);
static GType gala_input_method_get_type_once (void);
static void _vala_gala_input_method_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_gala_input_method_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
gala_input_method_get_instance_private (GalaInputMethod* self)
{
	return G_STRUCT_MEMBER_P (self, GalaInputMethod_private_offset);
}

GalaInputMethod*
gala_input_method_construct (GType object_type,
                             MetaDisplay* display)
{
	GalaInputMethod * self = NULL;
	g_return_val_if_fail (display != NULL, NULL);
	self = (GalaInputMethod*) g_object_new (object_type, "display", display, NULL);
	return self;
}

GalaInputMethod*
gala_input_method_new (MetaDisplay* display)
{
	return gala_input_method_construct (GALA_TYPE_INPUT_METHOD, display);
}

static void
gala_input_method_on_input_panel_state_changed (GalaInputMethod* self,
                                                ClutterInputPanelState state)
{
	gboolean _tmp1_;
	g_return_if_fail (self != NULL);
	switch (state) {
		case CLUTTER_INPUT_PANEL_STATE_ON:
		{
			gala_input_method_set_input_panel_active (self, TRUE);
			break;
		}
		case CLUTTER_INPUT_PANEL_STATE_OFF:
		{
			gala_input_method_set_input_panel_active (self, FALSE);
			break;
		}
		case CLUTTER_INPUT_PANEL_STATE_TOGGLE:
		{
			gboolean _tmp0_;
			_tmp0_ = self->priv->_input_panel_active;
			gala_input_method_set_input_panel_active (self, !_tmp0_);
			break;
		}
		default:
		break;
	}
	_tmp1_ = self->priv->_input_panel_active;
	if (!_tmp1_) {
		GalaOSKManager* _tmp2_;
		_tmp2_ = self->priv->osk_manager;
		gala_osk_manager_reset (_tmp2_);
	}
}

static void
_gala_input_method_on_input_context_created_gasync_ready_callback (GObject* source_object,
                                                                   GAsyncResult* res,
                                                                   gpointer self)
{
	gala_input_method_on_input_context_created ((GalaInputMethod*) self, source_object, res);
	g_object_unref (self);
}

static void
gala_input_method_on_connected (GalaInputMethod* self)
{
	IBusBus* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->bus;
	ibus_bus_create_input_context_async (_tmp0_, "gala", -1, NULL, _gala_input_method_on_input_context_created_gasync_ready_callback, g_object_ref (self));
}

static void
_gala_input_method_on_commit_text_ibus_input_context_commit_text (IBusInputContext* _sender,
                                                                  IBusText* text,
                                                                  gpointer self)
{
	gala_input_method_on_commit_text ((GalaInputMethod*) self, text);
}

static void
_gala_input_method_on_require_surrounding_text_ibus_input_context_require_surrounding_text (IBusInputContext* _sender,
                                                                                            gpointer self)
{
	gala_input_method_on_require_surrounding_text ((GalaInputMethod*) self);
}

static void
_gala_input_method_on_delete_surrounding_text_ibus_input_context_delete_surrounding_text (IBusInputContext* _sender,
                                                                                          gint offset,
                                                                                          guint n_chars,
                                                                                          gpointer self)
{
	gala_input_method_on_delete_surrounding_text ((GalaInputMethod*) self, offset, n_chars);
}

static void
_gala_input_method_on_update_preedit_text_ibus_input_context_update_preedit_text (IBusInputContext* _sender,
                                                                                  IBusText* text,
                                                                                  guint cursor_pos,
                                                                                  gboolean visible,
                                                                                  gpointer self)
{
	gala_input_method_on_update_preedit_text ((GalaInputMethod*) self, text, cursor_pos, visible);
}

static void
_gala_input_method_on_update_preedit_text_with_mode_ibus_input_context_update_preedit_text_with_mode (IBusInputContext* _sender,
                                                                                                      IBusText* text,
                                                                                                      guint cursor_pos,
                                                                                                      gboolean visible,
                                                                                                      guint mode,
                                                                                                      gpointer self)
{
	gala_input_method_on_update_preedit_text_with_mode ((GalaInputMethod*) self, text, cursor_pos, visible, mode);
}

static void
_gala_input_method_on_show_preedit_text_ibus_input_context_show_preedit_text (IBusInputContext* _sender,
                                                                              gpointer self)
{
	gala_input_method_on_show_preedit_text ((GalaInputMethod*) self);
}

static void
_gala_input_method_on_hide_preedit_text_ibus_input_context_hide_preedit_text (IBusInputContext* _sender,
                                                                              gpointer self)
{
	gala_input_method_on_hide_preedit_text ((GalaInputMethod*) self);
}

static void
_gala_input_method_on_forward_key_event_ibus_input_context_forward_key_event (IBusInputContext* _sender,
                                                                              guint keyval,
                                                                              guint keycode,
                                                                              guint modifiers,
                                                                              gpointer self)
{
	gala_input_method_on_forward_key_event ((GalaInputMethod*) self, keyval, keycode, modifiers);
}

static void
_gala_input_method_on_destroy_ibus_proxy_destroy (IBusProxy* _sender,
                                                  gpointer self)
{
	gala_input_method_on_destroy ((GalaInputMethod*) self);
}

static void
gala_input_method_on_input_context_created (GalaInputMethod* self,
                                            GObject* obj,
                                            GAsyncResult* res)
{
	IBusInputContext* _tmp6_;
	IBusInputContext* _tmp7_;
	IBusInputContext* _tmp8_;
	IBusInputContext* _tmp9_;
	IBusInputContext* _tmp10_;
	IBusInputContext* _tmp11_;
	IBusInputContext* _tmp12_;
	IBusInputContext* _tmp13_;
	IBusInputContext* _tmp14_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (res != NULL);
	{
		IBusInputContext* _tmp0_ = NULL;
		IBusBus* _tmp1_;
		IBusInputContext* _tmp2_;
		IBusInputContext* _tmp3_;
		_tmp1_ = self->priv->bus;
		_tmp2_ = ibus_bus_create_input_context_async_finish (_tmp1_, res, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (self->priv->context);
		self->priv->context = _tmp3_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_warning ("InputMethod.vala:80: Failed to create IBus input context: %s", _tmp5_);
		_g_error_free0 (e);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp6_ = self->priv->context;
	g_signal_connect_object (_tmp6_, "commit-text", (GCallback) _gala_input_method_on_commit_text_ibus_input_context_commit_text, self, 0);
	_tmp7_ = self->priv->context;
	g_signal_connect_object (_tmp7_, "require-surrounding-text", (GCallback) _gala_input_method_on_require_surrounding_text_ibus_input_context_require_surrounding_text, self, 0);
	_tmp8_ = self->priv->context;
	g_signal_connect_object (_tmp8_, "delete-surrounding-text", (GCallback) _gala_input_method_on_delete_surrounding_text_ibus_input_context_delete_surrounding_text, self, 0);
	_tmp9_ = self->priv->context;
	g_signal_connect_object (_tmp9_, "update-preedit-text", (GCallback) _gala_input_method_on_update_preedit_text_ibus_input_context_update_preedit_text, self, 0);
	_tmp10_ = self->priv->context;
	g_signal_connect_object (_tmp10_, "update-preedit-text-with-mode", (GCallback) _gala_input_method_on_update_preedit_text_with_mode_ibus_input_context_update_preedit_text_with_mode, self, 0);
	_tmp11_ = self->priv->context;
	g_signal_connect_object (_tmp11_, "show-preedit-text", (GCallback) _gala_input_method_on_show_preedit_text_ibus_input_context_show_preedit_text, self, 0);
	_tmp12_ = self->priv->context;
	g_signal_connect_object (_tmp12_, "hide-preedit-text", (GCallback) _gala_input_method_on_hide_preedit_text_ibus_input_context_hide_preedit_text, self, 0);
	_tmp13_ = self->priv->context;
	g_signal_connect_object (_tmp13_, "forward-key-event", (GCallback) _gala_input_method_on_forward_key_event_ibus_input_context_forward_key_event, self, 0);
	_tmp14_ = self->priv->context;
	g_signal_connect_object ((IBusProxy*) _tmp14_, "destroy", (GCallback) _gala_input_method_on_destroy_ibus_proxy_destroy, self, 0);
	gala_input_method_update_capabilities (self);
}

static void
gala_input_method_update_capabilities (GalaInputMethod* self)
{
	IBusCapabilite caps = 0U;
	const gchar* _tmp0_;
	IBusInputContext* _tmp1_ = NULL;
	IBusInputContext* _tmp2_;
	g_return_if_fail (self != NULL);
	caps = IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_FOCUS;
	_tmp0_ = self->priv->surrounding_text;
	if (_tmp0_ != NULL) {
		caps |= IBUS_CAP_SURROUNDING_TEXT;
	}
	_tmp2_ = self->priv->context;
	_tmp1_ = _tmp2_;
	if (_tmp1_ != NULL) {
		ibus_input_context_set_capabilities (_tmp1_, (guint32) caps);
	}
}

static void
gala_input_method_on_commit_text (GalaInputMethod* self,
                                  IBusText* text)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = text->text;
	clutter_input_method_commit ((ClutterInputMethod*) self, _tmp0_);
}

static void
gala_input_method_on_require_surrounding_text (GalaInputMethod* self)
{
	g_return_if_fail (self != NULL);
	clutter_input_method_request_surrounding ((ClutterInputMethod*) self);
}

static void
gala_input_method_on_delete_surrounding_text (GalaInputMethod* self,
                                              gint offset,
                                              guint length)
{
	g_return_if_fail (self != NULL);
	clutter_input_method_delete_surrounding ((ClutterInputMethod*) self, offset, length);
}

static void
gala_input_method_on_update_preedit_text (GalaInputMethod* self,
                                          IBusText* text,
                                          guint cursor_pos,
                                          gboolean visible)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	gala_input_method_on_update_preedit_text_with_mode (self, text, cursor_pos, visible, (guint) self->priv->preedit_mode);
}

static void
gala_input_method_on_update_preedit_text_with_mode (GalaInputMethod* self,
                                                    IBusText* text,
                                                    guint cursor_pos,
                                                    gboolean visible,
                                                    guint mode)
{
	gchar* preedit = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	guint anchor = 0U;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = text->text;
	_tmp1_ = g_strdup (_tmp0_);
	preedit = _tmp1_;
	_tmp2_ = preedit;
	if (g_strcmp0 (_tmp2_, "") == 0) {
		_g_free0 (preedit);
		preedit = NULL;
	}
	anchor = cursor_pos;
	if (visible) {
		const gchar* _tmp3_;
		_tmp3_ = preedit;
		clutter_input_method_set_preedit_text ((ClutterInputMethod*) self, _tmp3_, cursor_pos, anchor, mode);
	} else {
		if (self->priv->preedit_visible) {
			clutter_input_method_set_preedit_text ((ClutterInputMethod*) self, NULL, cursor_pos, anchor, mode);
		}
	}
	self->priv->preedit_visible = visible;
	_tmp4_ = preedit;
	_tmp5_ = g_strdup (_tmp4_);
	_g_free0 (self->priv->preedit_text);
	self->priv->preedit_text = _tmp5_;
	self->priv->preedit_cursor = cursor_pos;
	self->priv->preedit_anchor = anchor;
	self->priv->preedit_mode = (ClutterPreeditResetMode) mode;
	_g_free0 (preedit);
}

static void
gala_input_method_on_show_preedit_text (GalaInputMethod* self)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	self->priv->preedit_visible = TRUE;
	_tmp0_ = self->priv->preedit_text;
	clutter_input_method_set_preedit_text ((ClutterInputMethod*) self, _tmp0_, self->priv->preedit_cursor, self->priv->preedit_anchor, self->priv->preedit_mode);
}

static void
gala_input_method_on_hide_preedit_text (GalaInputMethod* self)
{
	g_return_if_fail (self != NULL);
	clutter_input_method_set_preedit_text ((ClutterInputMethod*) self, NULL, self->priv->preedit_cursor, self->priv->preedit_anchor, self->priv->preedit_mode);
	self->priv->preedit_visible = FALSE;
}

static void
gala_input_method_on_forward_key_event (GalaInputMethod* self,
                                        guint keyval,
                                        guint keycode,
                                        guint _modifiers)
{
	IBusModifierType modifiers = 0U;
	gboolean press = FALSE;
	guint32 time = 0U;
	MetaDisplay* _tmp0_;
	g_return_if_fail (self != NULL);
	modifiers = (IBusModifierType) _modifiers;
	press = !((modifiers & IBUS_RELEASE_MASK) == IBUS_RELEASE_MASK);
	modifiers &= ~IBUS_RELEASE_MASK;
	_tmp0_ = self->priv->_display;
	time = meta_display_get_current_time (_tmp0_);
	clutter_input_method_forward_key ((ClutterInputMethod*) self, (guint32) keyval, (guint32) (keycode + 8), (guint32) (modifiers & CLUTTER_MODIFIER_MASK), (guint64) time, press);
}

static void
gala_input_method_on_destroy (GalaInputMethod* self)
{
	g_return_if_fail (self != NULL);
	g_debug ("InputMethod.vala:166: IBus input context was destroyed");
	_g_object_unref0 (self->priv->context);
	self->priv->context = NULL;
}

static void
gala_input_method_maybe_request_surrounding (GalaInputMethod* self)
{
	gboolean _tmp0_ = FALSE;
	IBusInputContext* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->context;
	if (_tmp1_ != NULL) {
		IBusInputContext* _tmp2_;
		_tmp2_ = self->priv->context;
		_tmp0_ = ibus_input_context_needs_surrounding_text (_tmp2_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		clutter_input_method_request_surrounding ((ClutterInputMethod*) self);
	}
}

static void
gala_input_method_real_focus_in (ClutterInputMethod* base,
                                 ClutterInputFocus* actor)
{
	GalaInputMethod * self;
	IBusInputContext* _tmp0_ = NULL;
	IBusInputContext* _tmp1_;
	IBusInputContext* _tmp2_ = NULL;
	IBusInputContext* _tmp3_;
	self = (GalaInputMethod*) base;
	g_return_if_fail (actor != NULL);
	gala_input_method_update_capabilities (self);
	_tmp1_ = self->priv->context;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ibus_input_context_set_content_type (_tmp0_, (guint) self->priv->input_purpose, (guint) self->priv->input_hints);
	}
	gala_input_method_maybe_request_surrounding (self);
	_tmp3_ = self->priv->context;
	_tmp2_ = _tmp3_;
	if (_tmp2_ != NULL) {
		ibus_input_context_focus_in (_tmp2_);
	}
}

static void
gala_input_method_real_focus_out (ClutterInputMethod* base)
{
	GalaInputMethod * self;
	IBusInputContext* _tmp0_ = NULL;
	IBusInputContext* _tmp1_;
	IBusInputContext* _tmp2_ = NULL;
	IBusInputContext* _tmp3_;
	IBusInputContext* _tmp4_ = NULL;
	IBusInputContext* _tmp5_;
	self = (GalaInputMethod*) base;
	_tmp1_ = self->priv->context;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ibus_input_context_set_content_type (_tmp0_, (guint) 0, (guint) 0);
	}
	_tmp3_ = self->priv->context;
	_tmp2_ = _tmp3_;
	if (_tmp2_ != NULL) {
		ibus_input_context_reset (_tmp2_);
	}
	_tmp5_ = self->priv->context;
	_tmp4_ = _tmp5_;
	if (_tmp4_ != NULL) {
		ibus_input_context_focus_out (_tmp4_);
	}
	if (self->priv->preedit_visible) {
		clutter_input_method_set_preedit_text ((ClutterInputMethod*) self, NULL, self->priv->preedit_cursor, self->priv->preedit_anchor, self->priv->preedit_mode);
		_g_free0 (self->priv->preedit_text);
		self->priv->preedit_text = NULL;
	}
	clutter_input_method_set_input_panel_state ((ClutterInputMethod*) self, CLUTTER_INPUT_PANEL_STATE_OFF);
}

static void
gala_input_method_real_reset (ClutterInputMethod* base)
{
	GalaInputMethod * self;
	IBusInputContext* _tmp0_ = NULL;
	IBusInputContext* _tmp1_;
	self = (GalaInputMethod*) base;
	_tmp1_ = self->priv->context;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ibus_input_context_reset (_tmp0_);
	}
	gala_input_method_maybe_request_surrounding (self);
	_g_free0 (self->priv->surrounding_text);
	self->priv->surrounding_text = NULL;
	self->priv->surrounding_cursor = (guint) 0;
	self->priv->surrounding_anchor = (guint) 0;
	_g_free0 (self->priv->preedit_text);
	self->priv->preedit_text = NULL;
}

static void
gala_input_method_real_set_cursor_location (ClutterInputMethod* base,
                                            graphene_rect_t* rect)
{
	GalaInputMethod * self;
	IBusInputContext* _tmp0_ = NULL;
	IBusInputContext* _tmp1_;
	graphene_rect_t _tmp10_;
	self = (GalaInputMethod*) base;
	g_return_if_fail (rect != NULL);
	_tmp1_ = self->priv->context;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		graphene_rect_t _tmp2_;
		graphene_point_t _tmp3_;
		graphene_rect_t _tmp4_;
		graphene_point_t _tmp5_;
		graphene_rect_t _tmp6_;
		graphene_size_t _tmp7_;
		graphene_rect_t _tmp8_;
		graphene_size_t _tmp9_;
		_tmp2_ = *rect;
		_tmp3_ = _tmp2_.origin;
		_tmp4_ = *rect;
		_tmp5_ = _tmp4_.origin;
		_tmp6_ = *rect;
		_tmp7_ = _tmp6_.size;
		_tmp8_ = *rect;
		_tmp9_ = _tmp8_.size;
		ibus_input_context_set_cursor_location (_tmp0_, (gint32) ((gint) _tmp3_.x), (gint32) ((gint) _tmp5_.y), (gint32) ((gint) _tmp7_.width), (gint32) ((gint) _tmp9_.height));
	}
	_tmp10_ = *rect;
	gala_input_method_set_cursor_location (self, &_tmp10_);
}

static void
gala_input_method_real_set_surrounding (ClutterInputMethod* base,
                                        const gchar* text,
                                        guint cursor_index,
                                        guint anchor_index)
{
	GalaInputMethod * self;
	gboolean update_caps = FALSE;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	IBusText* ibus_text = NULL;
	IBusText* _tmp2_;
	IBusInputContext* _tmp3_ = NULL;
	IBusInputContext* _tmp4_;
	self = (GalaInputMethod*) base;
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->surrounding_text;
	update_caps = (_tmp0_ == NULL) != (text == NULL);
	_tmp1_ = g_strdup (text);
	_g_free0 (self->priv->surrounding_text);
	self->priv->surrounding_text = _tmp1_;
	self->priv->surrounding_cursor = cursor_index;
	self->priv->surrounding_anchor = anchor_index;
	if (update_caps) {
		gala_input_method_update_capabilities (self);
	}
	if (text == NULL) {
		return;
	}
	_tmp2_ = ibus_text_new_from_string (text);
	g_object_ref_sink (_tmp2_);
	ibus_text = _tmp2_;
	_tmp4_ = self->priv->context;
	_tmp3_ = _tmp4_;
	if (_tmp3_ != NULL) {
		IBusText* _tmp5_;
		_tmp5_ = ibus_text;
		ibus_input_context_set_surrounding_text (_tmp3_, _tmp5_, (guint32) cursor_index, (guint32) anchor_index);
	}
	_g_object_unref0 (ibus_text);
}

static ClutterEvent*
_vala_ClutterEvent_copy (ClutterEvent* self)
{
	return g_boxed_copy (clutter_event_get_type (), self);
}

static gpointer
__vala_ClutterEvent_copy0 (gpointer self)
{
	return self ? _vala_ClutterEvent_copy (self) : NULL;
}

static void
_vala_ClutterEvent_free (ClutterEvent* self)
{
	g_boxed_free (clutter_event_get_type (), self);
}

static Block30Data*
block30_data_ref (Block30Data* _data30_)
{
	g_atomic_int_inc (&_data30_->_ref_count_);
	return _data30_;
}

static void
block30_data_unref (void * _userdata_)
{
	Block30Data* _data30_;
	_data30_ = (Block30Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data30_->_ref_count_)) {
		GalaInputMethod* self;
		self = _data30_->self;
		__vala_ClutterEvent_free0 (_data30_->event);
		_g_object_unref0 (self);
		g_slice_free (Block30Data, _data30_);
	}
}

static void
__lambda10_ (Block30Data* _data30_,
             GObject* obj,
             GAsyncResult* res)
{
	GalaInputMethod* self;
	GError* _inner_error0_ = NULL;
	self = _data30_->self;
	g_return_if_fail (res != NULL);
	{
		gboolean handled = FALSE;
		IBusInputContext* _tmp0_;
		_tmp0_ = self->priv->context;
		handled = ibus_input_context_process_key_event_async_finish (_tmp0_, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		clutter_input_method_notify_key_event ((ClutterInputMethod*) self, _data30_->event, handled);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_warning ("InputMethod.vala:254: Failed to process key event on IM: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda10__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda10_ (self, source_object, res);
	block30_data_unref (self);
}

static gboolean
gala_input_method_real_filter_key_event (ClutterInputMethod* base,
                                         ClutterEvent* event)
{
	GalaInputMethod * self;
	Block30Data* _data30_;
	ClutterEvent* _tmp0_;
	IBusInputContext* _tmp1_;
	IBusModifierType state = 0U;
	IBusInputContext* _tmp2_;
	gboolean result;
	self = (GalaInputMethod*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_data30_ = g_slice_new0 (Block30Data);
	_data30_->_ref_count_ = 1;
	_data30_->self = g_object_ref (self);
	_tmp0_ = __vala_ClutterEvent_copy0 (event);
	__vala_ClutterEvent_free0 (_data30_->event);
	_data30_->event = _tmp0_;
	_tmp1_ = self->priv->context;
	if (_tmp1_ == NULL) {
		result = FALSE;
		block30_data_unref (_data30_);
		_data30_ = NULL;
		return result;
	}
	state = (IBusModifierType) clutter_event_get_state (_data30_->event);
	if ((state & IBUS_IGNORED_MASK) == IBUS_IGNORED_MASK) {
		result = FALSE;
		block30_data_unref (_data30_);
		_data30_ = NULL;
		return result;
	}
	if (clutter_event_type (_data30_->event) == CLUTTER_KEY_RELEASE) {
		state |= IBUS_RELEASE_MASK;
	}
	_tmp2_ = self->priv->context;
	ibus_input_context_process_key_event_async (_tmp2_, (guint32) clutter_event_get_key_symbol (_data30_->event), (guint32) (clutter_event_get_key_code (_data30_->event) - 8), (guint32) state, -1, NULL, ___lambda10__gasync_ready_callback, block30_data_ref (_data30_));
	result = TRUE;
	block30_data_unref (_data30_);
	_data30_ = NULL;
	return result;
}

static void
gala_input_method_real_update_content_hints (ClutterInputMethod* base,
                                             ClutterInputContentHintFlags hints)
{
	GalaInputMethod * self;
	IBusInputHints ibus_hints = 0U;
	IBusInputContext* _tmp0_ = NULL;
	IBusInputContext* _tmp1_;
	self = (GalaInputMethod*) base;
	ibus_hints = 0;
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_COMPLETION) == CLUTTER_INPUT_CONTENT_HINT_COMPLETION) {
		ibus_hints |= IBUS_INPUT_HINT_WORD_COMPLETION;
	}
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_SPELLCHECK) == CLUTTER_INPUT_CONTENT_HINT_SPELLCHECK) {
		ibus_hints |= IBUS_INPUT_HINT_SPELLCHECK;
	}
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_AUTO_CAPITALIZATION) == CLUTTER_INPUT_CONTENT_HINT_AUTO_CAPITALIZATION) {
		ibus_hints |= IBUS_INPUT_HINT_UPPERCASE_SENTENCES;
	}
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_LOWERCASE) == CLUTTER_INPUT_CONTENT_HINT_LOWERCASE) {
		ibus_hints |= IBUS_INPUT_HINT_LOWERCASE;
	}
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_UPPERCASE) == CLUTTER_INPUT_CONTENT_HINT_UPPERCASE) {
		ibus_hints |= IBUS_INPUT_HINT_UPPERCASE_CHARS;
	}
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_TITLECASE) == CLUTTER_INPUT_CONTENT_HINT_TITLECASE) {
		ibus_hints |= IBUS_INPUT_HINT_UPPERCASE_WORDS;
	}
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_SENSITIVE_DATA) == CLUTTER_INPUT_CONTENT_HINT_SENSITIVE_DATA) {
		ibus_hints |= IBUS_INPUT_HINT_PRIVATE;
	}
	if ((hints & CLUTTER_INPUT_CONTENT_HINT_HIDDEN_TEXT) == CLUTTER_INPUT_CONTENT_HINT_HIDDEN_TEXT) {
	}
	self->priv->input_hints = ibus_hints;
	_tmp1_ = self->priv->context;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ibus_input_context_set_content_type (_tmp0_, (guint) self->priv->input_purpose, (guint) self->priv->input_hints);
	}
}

static void
gala_input_method_real_update_content_purpose (ClutterInputMethod* base,
                                               ClutterInputContentPurpose purpose)
{
	GalaInputMethod * self;
	IBusInputPurpose ibus_purpose = 0;
	IBusInputContext* _tmp0_ = NULL;
	IBusInputContext* _tmp1_;
	GalaOSKManager* _tmp2_;
	self = (GalaInputMethod*) base;
	switch (purpose) {
		case CLUTTER_INPUT_CONTENT_PURPOSE_NORMAL:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_ALPHA:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_ALPHA;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_DIGITS:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_DIGITS;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_NUMBER:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_NUMBER;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_PHONE:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_PHONE;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_URL:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_URL;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_EMAIL:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_EMAIL;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_NAME:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_NAME;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_PASSWORD:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_PASSWORD;
			break;
		}
		case CLUTTER_INPUT_CONTENT_PURPOSE_TERMINAL:
		{
			ibus_purpose = IBUS_INPUT_PURPOSE_TERMINAL;
			break;
		}
		default:
		{
			g_warning ("InputMethod.vala:338: Unknown input purpose: %d", (gint) purpose);
			ibus_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
			break;
		}
	}
	self->priv->input_purpose = ibus_purpose;
	_tmp1_ = self->priv->context;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ibus_input_context_set_content_type (_tmp0_, (guint) self->priv->input_purpose, (guint) self->priv->input_hints);
	}
	_tmp2_ = self->priv->osk_manager;
	gala_osk_manager_set_input_purpose (_tmp2_, self->priv->input_purpose);
}

static MetaDisplay*
gala_input_method_get_display (GalaInputMethod* self)
{
	MetaDisplay* result;
	MetaDisplay* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_display;
	result = _tmp0_;
	return result;
}

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

static void
gala_input_method_set_display (GalaInputMethod* self,
                               MetaDisplay* value)
{
	MetaDisplay* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_input_method_get_display (self);
	if (old_value != value) {
		MetaDisplay* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_display);
		self->priv->_display = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_input_method_properties[GALA_INPUT_METHOD_DISPLAY_PROPERTY]);
	}
}

void
gala_input_method_get_cursor_location (GalaInputMethod* self,
                                       graphene_rect_t * result)
{
	graphene_rect_t _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_cursor_location;
	*result = _tmp0_;
	return;
}

static gboolean
_graphene_point_equal (const graphene_point_t * s1,
                       const graphene_point_t * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (s1->x != s2->x) {
		return FALSE;
	}
	if (s1->y != s2->y) {
		return FALSE;
	}
	return TRUE;
}

static gboolean
_graphene_size_equal (const graphene_size_t * s1,
                      const graphene_size_t * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (s1->width != s2->width) {
		return FALSE;
	}
	if (s1->height != s2->height) {
		return FALSE;
	}
	return TRUE;
}

static gboolean
_graphene_rect_equal (const graphene_rect_t * s1,
                      const graphene_rect_t * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (!_graphene_point_equal (&s1->origin, &s2->origin)) {
		return FALSE;
	}
	if (!_graphene_size_equal (&s1->size, &s2->size)) {
		return FALSE;
	}
	return TRUE;
}

static void
gala_input_method_set_cursor_location (GalaInputMethod* self,
                                       graphene_rect_t * value)
{
	graphene_rect_t old_value;
	g_return_if_fail (self != NULL);
	gala_input_method_get_cursor_location (self, &old_value);
	if (_graphene_rect_equal (value, &old_value) != TRUE) {
		graphene_rect_t _tmp0_;
		_tmp0_ = *value;
		self->priv->_cursor_location = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_input_method_properties[GALA_INPUT_METHOD_CURSOR_LOCATION_PROPERTY]);
	}
}

gboolean
gala_input_method_get_input_panel_active (GalaInputMethod* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_input_panel_active;
	return result;
}

static void
gala_input_method_set_input_panel_active (GalaInputMethod* self,
                                          gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_input_method_get_input_panel_active (self);
	if (old_value != value) {
		self->priv->_input_panel_active = value;
		g_object_notify_by_pspec ((GObject *) self, gala_input_method_properties[GALA_INPUT_METHOD_INPUT_PANEL_ACTIVE_PROPERTY]);
	}
}

static void
_gala_input_method___lambda11_ (GalaInputMethod* self)
{
	gala_input_method_set_input_panel_active (self, FALSE);
}

static void
__gala_input_method___lambda11__gala_osk_manager_input_panel_deactivation_requested (GalaOSKManager* _sender,
                                                                                     gpointer self)
{
	_gala_input_method___lambda11_ ((GalaInputMethod*) self);
}

static void
_gala_input_method_on_input_panel_state_changed_clutter_input_method_input_panel_state (ClutterInputMethod* _sender,
                                                                                        ClutterInputPanelState object,
                                                                                        gpointer self)
{
	gala_input_method_on_input_panel_state_changed ((GalaInputMethod*) self, object);
}

static void
_gala_input_method_on_connected_ibus_bus_connected (IBusBus* _sender,
                                                    gpointer self)
{
	gala_input_method_on_connected ((GalaInputMethod*) self);
}

static GObject *
gala_input_method_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaInputMethod * self;
	MetaDisplay* _tmp0_;
	GalaOSKManager* _tmp1_;
	GalaOSKManager* _tmp2_;
	IBusBus* _tmp3_;
	IBusBus* _tmp4_;
	IBusBus* _tmp5_;
	parent_class = G_OBJECT_CLASS (gala_input_method_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_INPUT_METHOD, GalaInputMethod);
	_tmp0_ = self->priv->_display;
	_tmp1_ = gala_osk_manager_new (_tmp0_);
	_g_object_unref0 (self->priv->osk_manager);
	self->priv->osk_manager = _tmp1_;
	_tmp2_ = self->priv->osk_manager;
	g_signal_connect_object (_tmp2_, "input-panel-deactivation-requested", (GCallback) __gala_input_method___lambda11__gala_osk_manager_input_panel_deactivation_requested, self, 0);
	g_signal_connect_object ((ClutterInputMethod*) self, "input-panel-state", (GCallback) _gala_input_method_on_input_panel_state_changed_clutter_input_method_input_panel_state, self, 0);
	ibus_init ();
	_tmp3_ = ibus_bus_new_async ();
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->bus);
	self->priv->bus = _tmp3_;
	_tmp4_ = self->priv->bus;
	g_signal_connect_object (_tmp4_, "connected", (GCallback) _gala_input_method_on_connected_ibus_bus_connected, self, 0);
	_tmp5_ = self->priv->bus;
	if (ibus_bus_is_connected (_tmp5_)) {
		gala_input_method_on_connected (self);
	}
	return obj;
}

static void
gala_input_method_class_init (GalaInputMethodClass * klass,
                              gpointer klass_data)
{
	gala_input_method_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaInputMethod_private_offset);
	((ClutterInputMethodClass *) klass)->focus_in = (void (*) (ClutterInputMethod*, ClutterInputFocus*)) gala_input_method_real_focus_in;
	((ClutterInputMethodClass *) klass)->focus_out = (void (*) (ClutterInputMethod*)) gala_input_method_real_focus_out;
	((ClutterInputMethodClass *) klass)->reset = (void (*) (ClutterInputMethod*)) gala_input_method_real_reset;
	((ClutterInputMethodClass *) klass)->set_cursor_location = (void (*) (ClutterInputMethod*, graphene_rect_t*)) gala_input_method_real_set_cursor_location;
	((ClutterInputMethodClass *) klass)->set_surrounding = (void (*) (ClutterInputMethod*, const gchar*, guint, guint)) gala_input_method_real_set_surrounding;
	((ClutterInputMethodClass *) klass)->filter_key_event = (gboolean (*) (ClutterInputMethod*, ClutterEvent*)) gala_input_method_real_filter_key_event;
	((ClutterInputMethodClass *) klass)->update_content_hints = (void (*) (ClutterInputMethod*, ClutterInputContentHintFlags)) gala_input_method_real_update_content_hints;
	((ClutterInputMethodClass *) klass)->update_content_purpose = (void (*) (ClutterInputMethod*, ClutterInputContentPurpose)) gala_input_method_real_update_content_purpose;
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_input_method_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_input_method_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_input_method_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_input_method_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_INPUT_METHOD_DISPLAY_PROPERTY, gala_input_method_properties[GALA_INPUT_METHOD_DISPLAY_PROPERTY] = g_param_spec_object ("display", "display", "display", meta_display_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_INPUT_METHOD_CURSOR_LOCATION_PROPERTY, gala_input_method_properties[GALA_INPUT_METHOD_CURSOR_LOCATION_PROPERTY] = g_param_spec_boxed ("cursor-location", "cursor-location", "cursor-location", graphene_rect_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_INPUT_METHOD_INPUT_PANEL_ACTIVE_PROPERTY, gala_input_method_properties[GALA_INPUT_METHOD_INPUT_PANEL_ACTIVE_PROPERTY] = g_param_spec_boolean ("input-panel-active", "input-panel-active", "input-panel-active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gala_input_method_instance_init (GalaInputMethod * self,
                                 gpointer klass)
{
	self->priv = gala_input_method_get_instance_private (self);
}

static void
gala_input_method_finalize (GObject * obj)
{
	GalaInputMethod * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_INPUT_METHOD, GalaInputMethod);
	_g_object_unref0 (self->priv->_display);
	_g_object_unref0 (self->priv->osk_manager);
	_g_object_unref0 (self->priv->bus);
	_g_object_unref0 (self->priv->context);
	_g_free0 (self->priv->preedit_text);
	_g_free0 (self->priv->surrounding_text);
	G_OBJECT_CLASS (gala_input_method_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_input_method_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaInputMethodClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_input_method_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaInputMethod), 0, (GInstanceInitFunc) gala_input_method_instance_init, NULL };
	GType gala_input_method_type_id;
	gala_input_method_type_id = g_type_register_static (clutter_input_method_get_type (), "GalaInputMethod", &g_define_type_info, G_TYPE_FLAG_NONE);
	GalaInputMethod_private_offset = g_type_add_instance_private (gala_input_method_type_id, sizeof (GalaInputMethodPrivate));
	return gala_input_method_type_id;
}

GType
gala_input_method_get_type (void)
{
	static gsize gala_input_method_type_id__once = 0;
	if (g_once_init_enter (&gala_input_method_type_id__once)) {
		GType gala_input_method_type_id;
		gala_input_method_type_id = gala_input_method_get_type_once ();
		g_once_init_leave (&gala_input_method_type_id__once, gala_input_method_type_id);
	}
	return gala_input_method_type_id__once;
}

static void
_vala_gala_input_method_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	GalaInputMethod * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_INPUT_METHOD, GalaInputMethod);
	switch (property_id) {
		case GALA_INPUT_METHOD_DISPLAY_PROPERTY:
		g_value_set_object (value, gala_input_method_get_display (self));
		break;
		case GALA_INPUT_METHOD_CURSOR_LOCATION_PROPERTY:
		{
			graphene_rect_t boxed;
			gala_input_method_get_cursor_location (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		case GALA_INPUT_METHOD_INPUT_PANEL_ACTIVE_PROPERTY:
		g_value_set_boolean (value, gala_input_method_get_input_panel_active (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_input_method_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	GalaInputMethod * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_INPUT_METHOD, GalaInputMethod);
	switch (property_id) {
		case GALA_INPUT_METHOD_DISPLAY_PROPERTY:
		gala_input_method_set_display (self, g_value_get_object (value));
		break;
		case GALA_INPUT_METHOD_CURSOR_LOCATION_PROPERTY:
		gala_input_method_set_cursor_location (self, g_value_get_boxed (value));
		break;
		case GALA_INPUT_METHOD_INPUT_PANEL_ACTIVE_PROPERTY:
		gala_input_method_set_input_panel_active (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

