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

/* vim:set et sts=4 sw=4:
 *
 * ibus - The Input Bus
 *
 * Copyright(c) 2011-2015 Peng Huang <shawn.p.huang@gmail.com>
 * Copyright(c) 2015-2025 Takao Fujiwara <takao.fujiwara1@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gdk/gdk.h>
#include <pango/pango.h>
#include <ibus.h>
#include <string.h>
#include <cairo-gobject.h>
#include <stdlib.h>
#include <gdk/gdkwayland.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 TYPE_CANDIDATE_PANEL (candidate_panel_get_type ())
#define CANDIDATE_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CANDIDATE_PANEL, CandidatePanel))
#define CANDIDATE_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CANDIDATE_PANEL, CandidatePanelClass))
#define IS_CANDIDATE_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CANDIDATE_PANEL))
#define IS_CANDIDATE_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CANDIDATE_PANEL))
#define CANDIDATE_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CANDIDATE_PANEL, CandidatePanelClass))

typedef struct _CandidatePanel CandidatePanel;
typedef struct _CandidatePanelClass CandidatePanelClass;
typedef struct _CandidatePanelPrivate CandidatePanelPrivate;

#define TYPE_CANDIDATE_AREA (candidate_area_get_type ())
#define CANDIDATE_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CANDIDATE_AREA, CandidateArea))
#define CANDIDATE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CANDIDATE_AREA, CandidateAreaClass))
#define IS_CANDIDATE_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CANDIDATE_AREA))
#define IS_CANDIDATE_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CANDIDATE_AREA))
#define CANDIDATE_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CANDIDATE_AREA, CandidateAreaClass))

typedef struct _CandidateArea CandidateArea;
typedef struct _CandidateAreaClass CandidateAreaClass;

#define TYPE_HSEPARATOR (hseparator_get_type ())
#define HSEPARATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HSEPARATOR, HSeparator))
#define HSEPARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HSEPARATOR, HSeparatorClass))
#define IS_HSEPARATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HSEPARATOR))
#define IS_HSEPARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HSEPARATOR))
#define HSEPARATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HSEPARATOR, HSeparatorClass))

typedef struct _HSeparator HSeparator;
typedef struct _HSeparatorClass HSeparatorClass;
enum  {
	CANDIDATE_PANEL_0_PROPERTY,
	CANDIDATE_PANEL_NUM_PROPERTIES
};
static GParamSpec* candidate_panel_properties[CANDIDATE_PANEL_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _pango_attribute_destroy0(var) ((var == NULL) ? NULL : (var = (pango_attribute_destroy (var), NULL)))

#define TYPE_HANDLE (handle_get_type ())
#define HANDLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HANDLE, Handle))
#define HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HANDLE, HandleClass))
#define IS_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HANDLE))
#define IS_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HANDLE))
#define HANDLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HANDLE, HandleClass))

typedef struct _Handle Handle;
typedef struct _HandleClass HandleClass;
#define _pango_attr_list_unref0(var) ((var == NULL) ? NULL : (var = (pango_attr_list_unref (var), NULL)))
typedef struct _Block5Data Block5Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block6Data Block6Data;
typedef struct _Block7Data Block7Data;
enum  {
	CANDIDATE_PANEL_CURSOR_UP_SIGNAL,
	CANDIDATE_PANEL_CURSOR_DOWN_SIGNAL,
	CANDIDATE_PANEL_PAGE_UP_SIGNAL,
	CANDIDATE_PANEL_PAGE_DOWN_SIGNAL,
	CANDIDATE_PANEL_CANDIDATE_CLICKED_SIGNAL,
	CANDIDATE_PANEL_FORWARD_PROCESS_KEY_EVENT_SIGNAL,
	CANDIDATE_PANEL_REALIZE_SURFACE_SIGNAL,
	CANDIDATE_PANEL_NUM_SIGNALS
};
static guint candidate_panel_signals[CANDIDATE_PANEL_NUM_SIGNALS] = {0};

struct _CandidatePanel {
	GtkBox parent_instance;
	CandidatePanelPrivate * priv;
};

struct _CandidatePanelClass {
	GtkBoxClass parent_class;
};

struct _CandidatePanelPrivate {
	gboolean m_vertical_panel_system;
	gboolean m_vertical_writing;
	GtkWindow* m_toplevel;
	GtkBox* m_vbox;
	GtkLabel* m_preedit_label;
	GtkLabel* m_aux_label;
	CandidateArea* m_candidate_area;
	HSeparator* m_hseparator;
	GdkRectangle m_cursor_location;
	PangoAttribute* m_language_attribute;
	guint m_update_id;
	gboolean m_is_wayland;
	gboolean m_no_wayland_panel;
	gboolean m_hide_after_show;
	guint m_prev_page_size;
	guint m_prev_ncandidates;
	guint m_prev_cursor;
	guint m_prev_cursor_in_page;
	gboolean m_prev_show_cursor;
	guint m_set_preedit_text_id;
	guint m_set_auxiliary_text_id;
	guint m_set_lookup_table_id;
	gboolean m_first_set_lookup_table;
};

struct _Block5Data {
	int _ref_count_;
	CandidatePanel* self;
	IBusText* text;
	guint cursor;
};

struct _Block6Data {
	int _ref_count_;
	CandidatePanel* self;
	IBusText* text;
};

struct _Block7Data {
	int _ref_count_;
	CandidatePanel* self;
	IBusLookupTable* table;
};

static gint CandidatePanel_private_offset;
static gpointer candidate_panel_parent_class = NULL;

VALA_EXTERN GType candidate_panel_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CandidatePanel, g_object_unref)
VALA_EXTERN GType candidate_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CandidateArea, g_object_unref)
VALA_EXTERN GType hseparator_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (HSeparator, g_object_unref)
VALA_EXTERN CandidatePanel* candidate_panel_new (gboolean is_wayland,
                                     gboolean no_wayland_panel);
VALA_EXTERN CandidatePanel* candidate_panel_construct (GType object_type,
                                           gboolean is_wayland,
                                           gboolean no_wayland_panel);
static gboolean __lambda37_ (CandidatePanel* self,
                      GtkWidget* w,
                      GdkEventButton* e);
VALA_EXTERN void candidate_panel_set_vertical (CandidatePanel* self,
                                   gboolean vertical);
static gboolean ___lambda37__gtk_widget_button_press_event (GtkWidget* _sender,
                                                     GdkEventButton* event,
                                                     gpointer self);
static void __lambda38_ (CandidatePanel* self,
                  GtkWidget* w,
                  GtkAllocation* a);
static void candidate_panel_adjust_window_position (CandidatePanel* self,
                                             GtkWidget* window);
static void ___lambda38__gtk_widget_size_allocate (GtkWidget* _sender,
                                            GtkAllocation* allocation,
                                            gpointer self);
static void ___lambda39_ (CandidatePanel* self,
                   GtkWidget* w);
static void candidate_panel_realize_window (CandidatePanel* self,
                                     gboolean initial);
static void ____lambda39__gtk_widget_realize (GtkWidget* _sender,
                                       gpointer self);
static void ___lambda40_ (CandidatePanel* self,
                   GtkWidget* w);
static void ____lambda40__gtk_widget_show (GtkWidget* _sender,
                                    gpointer self);
static void ___lambda41_ (CandidatePanel* self,
                   GtkWidget* w);
static void ____lambda41__gtk_widget_hide (GtkWidget* _sender,
                                    gpointer self);
static gboolean __lambda42_ (CandidatePanel* self,
                      GtkWidget* widget,
                      GdkEventKey* event);
static gboolean ___lambda42__gtk_widget_key_press_event (GtkWidget* _sender,
                                                  GdkEventKey* event,
                                                  gpointer self);
static gboolean __lambda43_ (CandidatePanel* self,
                      GtkWidget* widget,
                      GdkEventKey* event);
static gboolean ___lambda43__gtk_widget_key_release_event (GtkWidget* _sender,
                                                    GdkEventKey* event,
                                                    gpointer self);
VALA_EXTERN GType handle_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Handle, g_object_unref)
VALA_EXTERN Handle* handle_new (void);
VALA_EXTERN Handle* handle_construct (GType object_type);
static void candidate_panel_create_ui (CandidatePanel* self);
VALA_EXTERN void candidate_area_set_vertical (CandidateArea* self,
                                  gboolean vertical,
                                  gboolean force);
static void candidate_panel_set_orientation (CandidatePanel* self,
                                      IBusOrientation orientation);
VALA_EXTERN GdkRectangle* candidate_panel_get_cursor_rect (CandidatePanel* self);
static GdkRectangle* _vala_GdkRectangle_copy (GdkRectangle* self);
VALA_EXTERN void candidate_panel_set_cursor_location (CandidatePanel* self,
                                          gint x,
                                          gint y,
                                          gint width,
                                          gint height);
static gboolean _cairo_rectangle_int_equal (const cairo_rectangle_int_t * s1,
                                     const cairo_rectangle_int_t * s2);
static void candidate_panel_set_labels (CandidatePanel* self,
                                 IBusText** labels,
                                 gint labels_length1);
VALA_EXTERN void candidate_area_set_labels (CandidateArea* self,
                                IBusText** labels,
                                gint labels_length1);
VALA_EXTERN void candidate_panel_set_language (CandidatePanel* self,
                                   PangoAttribute* language_attribute);
VALA_EXTERN void candidate_area_set_language (CandidateArea* self,
                                  PangoAttribute* language_attribute);
static void candidate_panel_set_attributes (CandidatePanel* self,
                                     GtkLabel* label,
                                     IBusText* text);
VALA_EXTERN PangoAttrList* get_pango_attr_list_from_ibus_text (IBusText* text);
VALA_EXTERN void candidate_panel_set_preedit_text (CandidatePanel* self,
                                       IBusText* text,
                                       guint cursor);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
VALA_EXTERN void candidate_panel_set_preedit_text_real (CandidatePanel* self,
                                            IBusText* text,
                                            guint cursor);
static gboolean __lambda50_ (Block5Data* _data5_);
static gboolean ___lambda50__gsource_func (gpointer self);
static void candidate_panel_update (CandidatePanel* self);
VALA_EXTERN void candidate_panel_set_auxiliary_text (CandidatePanel* self,
                                         IBusText* text);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
VALA_EXTERN void candidate_panel_set_auxiliary_text_real (CandidatePanel* self,
                                              IBusText* text);
static gboolean __lambda51_ (Block6Data* _data6_);
static gboolean ___lambda51__gsource_func (gpointer self);
VALA_EXTERN void candidate_panel_set_lookup_table (CandidatePanel* self,
                                       IBusLookupTable* table);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
VALA_EXTERN void candidate_panel_set_lookup_table_real (CandidatePanel* self,
                                            IBusLookupTable* table);
static gboolean __lambda52_ (Block7Data* _data7_);
static gboolean ___lambda52__gsource_func (gpointer self);
static void _vala_array_add9 (IBusText** * array,
                       gint* length,
                       gint* size,
                       IBusText* value);
static void _vala_array_add10 (IBusText** * array,
                        gint* length,
                        gint* size,
                        IBusText* value);
VALA_EXTERN void candidate_area_set_candidates (CandidateArea* self,
                                    IBusText** candidates,
                                    gint candidates_length1,
                                    guint focus_candidate,
                                    gboolean show_cursor);
VALA_EXTERN void candidate_panel_set_content_type (CandidatePanel* self,
                                       guint purpose,
                                       guint hints);
static void candidate_panel_update_real (CandidatePanel* self);
static gboolean __lambda49_ (CandidatePanel* self);
static gboolean ___lambda49__gsource_func (gpointer self);
VALA_EXTERN void candidate_panel_show (CandidatePanel* self);
VALA_EXTERN void candidate_panel_hide (CandidatePanel* self);
VALA_EXTERN CandidateArea* candidate_area_new (gboolean vertical);
VALA_EXTERN CandidateArea* candidate_area_construct (GType object_type,
                                         gboolean vertical);
static void __lambda44_ (CandidatePanel* self,
                  CandidateArea* w,
                  guint i,
                  guint b,
                  guint s);
static void ___lambda44__candidate_area_candidate_clicked (CandidateArea* _sender,
                                                    guint index,
                                                    guint button,
                                                    guint state,
                                                    gpointer self);
static void __lambda45_ (CandidatePanel* self,
                  CandidateArea* c);
static void ___lambda45__candidate_area_page_up (CandidateArea* _sender,
                                          gpointer self);
static void __lambda46_ (CandidatePanel* self,
                  CandidateArea* c);
static void ___lambda46__candidate_area_page_down (CandidateArea* _sender,
                                            gpointer self);
static void __lambda47_ (CandidatePanel* self,
                  CandidateArea* c);
static void ___lambda47__candidate_area_cursor_up (CandidateArea* _sender,
                                            gpointer self);
static void __lambda48_ (CandidatePanel* self,
                  CandidateArea* c);
static void ___lambda48__candidate_area_cursor_down (CandidateArea* _sender,
                                              gpointer self);
VALA_EXTERN HSeparator* hseparator_new (void);
VALA_EXTERN HSeparator* hseparator_construct (GType object_type);
static void candidate_panel_pack_all_widgets (CandidatePanel* self);
static void candidate_panel_move (CandidatePanel* self,
                           gint x,
                           gint y);
static void candidate_panel_adjust_window_position_horizontal (CandidatePanel* self,
                                                        GtkWidget* window);
static void candidate_panel_adjust_window_position_vertical (CandidatePanel* self,
                                                      GtkWidget* window);
static void candidate_panel_get_monitor_geometry (CandidatePanel* self,
                                           GtkWidget* window,
                                           GdkRectangle* result);
VALA_EXTERN gboolean candidate_area_get_vertical (CandidateArea* self);
static void g_cclosure_user_marshal_VOID__UINT_UINT_UINT (GClosure * closure,
                                                   GValue * return_value,
                                                   guint n_param_values,
                                                   const GValue * param_values,
                                                   gpointer invocation_hint,
                                                   gpointer marshal_data);
static void candidate_panel_finalize (GObject * obj);
static GType candidate_panel_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
candidate_panel_get_instance_private (CandidatePanel* self)
{
	return G_STRUCT_MEMBER_P (self, CandidatePanel_private_offset);
}

static gboolean
__lambda37_ (CandidatePanel* self,
             GtkWidget* w,
             GdkEventButton* e)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	if (e->button != ((guint) 1)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = (e->state & GDK_CONTROL_MASK) == 0;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	candidate_panel_set_vertical (self, !self->priv->m_vertical_panel_system);
	result = TRUE;
	return result;
}

static gboolean
___lambda37__gtk_widget_button_press_event (GtkWidget* _sender,
                                            GdkEventButton* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda37_ ((CandidatePanel*) self, _sender, event);
	return result;
}

static void
__lambda38_ (CandidatePanel* self,
             GtkWidget* w,
             GtkAllocation* a)
{
	g_return_if_fail (w != NULL);
	g_return_if_fail (a != NULL);
	candidate_panel_adjust_window_position (self, w);
}

static void
___lambda38__gtk_widget_size_allocate (GtkWidget* _sender,
                                       GtkAllocation* allocation,
                                       gpointer self)
{
	__lambda38_ ((CandidatePanel*) self, _sender, allocation);
}

static void
___lambda39_ (CandidatePanel* self,
              GtkWidget* w)
{
	g_return_if_fail (w != NULL);
	candidate_panel_realize_window (self, TRUE);
}

static void
____lambda39__gtk_widget_realize (GtkWidget* _sender,
                                  gpointer self)
{
	___lambda39_ ((CandidatePanel*) self, _sender);
}

static void
___lambda40_ (CandidatePanel* self,
              GtkWidget* w)
{
	g_return_if_fail (w != NULL);
	if (self->priv->m_hide_after_show) {
		candidate_panel_realize_window (self, FALSE);
	}
	self->priv->m_hide_after_show = FALSE;
}

static void
____lambda40__gtk_widget_show (GtkWidget* _sender,
                               gpointer self)
{
	___lambda40_ ((CandidatePanel*) self, _sender);
}

static void
___lambda41_ (CandidatePanel* self,
              GtkWidget* w)
{
	g_return_if_fail (w != NULL);
	self->priv->m_hide_after_show = TRUE;
}

static void
____lambda41__gtk_widget_hide (GtkWidget* _sender,
                               gpointer self)
{
	___lambda41_ ((CandidatePanel*) self, _sender);
}

static gboolean
__lambda42_ (CandidatePanel* self,
             GtkWidget* widget,
             GdkEventKey* event)
{
	guint32 keyval = 0U;
	guint32 keycode = 0U;
	guint32 state = 0U;
	gboolean result;
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	keyval = (guint32) event->keyval;
	keycode = (guint32) event->hardware_keycode;
	state = (guint32) event->state;
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_FORWARD_PROCESS_KEY_EVENT_SIGNAL], 0, (guint) keyval, (guint) keycode, (guint) state);
	result = FALSE;
	return result;
}

static gboolean
___lambda42__gtk_widget_key_press_event (GtkWidget* _sender,
                                         GdkEventKey* event,
                                         gpointer self)
{
	gboolean result;
	result = __lambda42_ ((CandidatePanel*) self, _sender, event);
	return result;
}

static gboolean
__lambda43_ (CandidatePanel* self,
             GtkWidget* widget,
             GdkEventKey* event)
{
	guint32 keyval = 0U;
	guint32 keycode = 0U;
	guint32 state = 0U;
	gboolean result;
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	keyval = (guint32) event->keyval;
	keycode = (guint32) event->hardware_keycode;
	state = (guint32) event->state;
	state |= (guint32) IBUS_RELEASE_MASK;
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_FORWARD_PROCESS_KEY_EVENT_SIGNAL], 0, (guint) keyval, (guint) keycode, (guint) state);
	result = FALSE;
	return result;
}

static gboolean
___lambda43__gtk_widget_key_release_event (GtkWidget* _sender,
                                           GdkEventKey* event,
                                           gpointer self)
{
	gboolean result;
	result = __lambda43_ ((CandidatePanel*) self, _sender, event);
	return result;
}

CandidatePanel*
candidate_panel_construct (GType object_type,
                           gboolean is_wayland,
                           gboolean no_wayland_panel)
{
	CandidatePanel * self = NULL;
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	GtkWindow* _tmp3_;
	GtkWindow* _tmp7_;
	GtkWindow* _tmp8_;
	Handle* handle = NULL;
	Handle* _tmp9_;
	GtkBox* _tmp10_;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	GtkWindow* _tmp13_;
	self = (CandidatePanel*) g_object_new (object_type, "name", "IBusCandidate", "orientation", GTK_ORIENTATION_HORIZONTAL, "visible", TRUE, NULL);
	self->priv->m_is_wayland = is_wayland;
	self->priv->m_no_wayland_panel = no_wayland_panel;
	_tmp0_ = (GtkWindow*) gtk_window_new (GTK_WINDOW_POPUP);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->m_toplevel);
	self->priv->m_toplevel = _tmp0_;
	_tmp1_ = self->priv->m_toplevel;
	gtk_widget_add_events ((GtkWidget*) _tmp1_, (gint) GDK_BUTTON_PRESS_MASK);
	_tmp2_ = self->priv->m_toplevel;
	g_signal_connect_object ((GtkWidget*) _tmp2_, "button-press-event", (GCallback) ___lambda37__gtk_widget_button_press_event, self, 0);
	_tmp3_ = self->priv->m_toplevel;
	g_signal_connect_object ((GtkWidget*) _tmp3_, "size-allocate", (GCallback) ___lambda38__gtk_widget_size_allocate, self, 0);
	if (self->priv->m_is_wayland) {
		GtkWindow* _tmp4_;
		GtkWindow* _tmp5_;
		GtkWindow* _tmp6_;
		_tmp4_ = self->priv->m_toplevel;
		g_signal_connect_object ((GtkWidget*) _tmp4_, "realize", (GCallback) ____lambda39__gtk_widget_realize, self, 0);
		_tmp5_ = self->priv->m_toplevel;
		g_signal_connect_object ((GtkWidget*) _tmp5_, "show", (GCallback) ____lambda40__gtk_widget_show, self, 0);
		_tmp6_ = self->priv->m_toplevel;
		g_signal_connect_object ((GtkWidget*) _tmp6_, "hide", (GCallback) ____lambda41__gtk_widget_hide, self, 0);
	}
	_tmp7_ = self->priv->m_toplevel;
	g_signal_connect_object ((GtkWidget*) _tmp7_, "key-press-event", (GCallback) ___lambda42__gtk_widget_key_press_event, self, 0);
	_tmp8_ = self->priv->m_toplevel;
	g_signal_connect_object ((GtkWidget*) _tmp8_, "key-release-event", (GCallback) ___lambda43__gtk_widget_key_release_event, self, 0);
	_tmp9_ = handle_new ();
	g_object_ref_sink (_tmp9_);
	handle = _tmp9_;
	gtk_widget_set_visible ((GtkWidget*) handle, TRUE);
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) handle, FALSE, FALSE, (guint) 0);
	_tmp10_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp10_);
	_g_object_unref0 (self->priv->m_vbox);
	self->priv->m_vbox = _tmp10_;
	_tmp11_ = self->priv->m_vbox;
	gtk_widget_set_visible ((GtkWidget*) _tmp11_, TRUE);
	_tmp12_ = self->priv->m_vbox;
	gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) _tmp12_, FALSE, FALSE, (guint) 0);
	_tmp13_ = self->priv->m_toplevel;
	gtk_container_add ((GtkContainer*) _tmp13_, (GtkWidget*) self);
	candidate_panel_create_ui (self);
	_g_object_unref0 (handle);
	return self;
}

CandidatePanel*
candidate_panel_new (gboolean is_wayland,
                     gboolean no_wayland_panel)
{
	return candidate_panel_construct (TYPE_CANDIDATE_PANEL, is_wayland, no_wayland_panel);
}

void
candidate_panel_set_vertical (CandidatePanel* self,
                              gboolean vertical)
{
	CandidateArea* _tmp0_;
	g_return_if_fail (self != NULL);
	if (self->priv->m_vertical_panel_system == vertical) {
		return;
	}
	self->priv->m_vertical_panel_system = vertical;
	_tmp0_ = self->priv->m_candidate_area;
	candidate_area_set_vertical (_tmp0_, vertical, FALSE);
}

static void
candidate_panel_set_orientation (CandidatePanel* self,
                                 IBusOrientation orientation)
{
	g_return_if_fail (self != NULL);
	switch (orientation) {
		case IBUS_ORIENTATION_VERTICAL:
		{
			CandidateArea* _tmp0_;
			_tmp0_ = self->priv->m_candidate_area;
			candidate_area_set_vertical (_tmp0_, TRUE, FALSE);
			break;
		}
		case IBUS_ORIENTATION_HORIZONTAL:
		{
			CandidateArea* _tmp1_;
			_tmp1_ = self->priv->m_candidate_area;
			candidate_area_set_vertical (_tmp1_, FALSE, FALSE);
			break;
		}
		case IBUS_ORIENTATION_SYSTEM:
		{
			CandidateArea* _tmp2_;
			_tmp2_ = self->priv->m_candidate_area;
			candidate_area_set_vertical (_tmp2_, self->priv->m_vertical_panel_system, FALSE);
			break;
		}
		default:
		break;
	}
}

static GdkRectangle*
_vala_GdkRectangle_copy (GdkRectangle* self)
{
	return g_boxed_copy (gdk_rectangle_get_type (), self);
}

static gpointer
__vala_GdkRectangle_copy0 (gpointer self)
{
	return self ? _vala_GdkRectangle_copy (self) : NULL;
}

GdkRectangle*
candidate_panel_get_cursor_rect (CandidatePanel* self)
{
	GdkRectangle _tmp0_;
	GdkRectangle* _tmp1_;
	GdkRectangle* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->m_cursor_location;
	_tmp1_ = __vala_GdkRectangle_copy0 (&_tmp0_);
	result = _tmp1_;
	return result;
}

static gboolean
_cairo_rectangle_int_equal (const cairo_rectangle_int_t * s1,
                            const cairo_rectangle_int_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;
	}
	if (s1->width != s2->width) {
		return FALSE;
	}
	if (s1->height != s2->height) {
		return FALSE;
	}
	return TRUE;
}

void
candidate_panel_set_cursor_location (CandidatePanel* self,
                                     gint x,
                                     gint y,
                                     gint width,
                                     gint height)
{
	GdkRectangle location = {0};
	GdkRectangle _tmp0_ = {0};
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	g_return_if_fail (self != NULL);
	memset (&_tmp0_, 0, sizeof (GdkRectangle));
	_tmp0_.x = x;
	_tmp0_.y = y;
	_tmp0_.width = width;
	_tmp0_.height = height;
	location = _tmp0_;
	_tmp1_ = self->priv->m_cursor_location;
	_tmp2_ = location;
	if (_cairo_rectangle_int_equal (&_tmp1_, &_tmp2_) == TRUE) {
		return;
	}
	_tmp3_ = location;
	self->priv->m_cursor_location = _tmp3_;
}

static void
candidate_panel_set_labels (CandidatePanel* self,
                            IBusText** labels,
                            gint labels_length1)
{
	CandidateArea* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->m_candidate_area;
	candidate_area_set_labels (_tmp0_, labels, (gint) labels_length1);
}

void
candidate_panel_set_language (CandidatePanel* self,
                              PangoAttribute* language_attribute)
{
	CandidateArea* _tmp0_;
	PangoAttribute* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (language_attribute != NULL);
	_tmp0_ = self->priv->m_candidate_area;
	candidate_area_set_language (_tmp0_, language_attribute);
	_tmp1_ = pango_attribute_copy (language_attribute);
	_pango_attribute_destroy0 (self->priv->m_language_attribute);
	self->priv->m_language_attribute = _tmp1_;
}

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

static void
candidate_panel_set_attributes (CandidatePanel* self,
                                GtkLabel* label,
                                IBusText* text)
{
	PangoAttrList* attrs = NULL;
	PangoAttrList* _tmp0_;
	PangoAttrList* _tmp1_;
	PangoAttribute* _tmp2_;
	PangoAttribute* _tmp3_;
	GtkStyleContext* context = NULL;
	GtkStyleContext* _tmp4_;
	GtkStyleContext* _tmp5_;
	GdkRGBA color = {0};
	GtkStyleContext* _tmp6_;
	GdkRGBA _tmp7_ = {0};
	gboolean _tmp8_;
	PangoAttrList* _tmp20_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (label != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = get_pango_attr_list_from_ibus_text (text);
	attrs = _tmp0_;
	_tmp1_ = attrs;
	_tmp2_ = self->priv->m_language_attribute;
	_tmp3_ = pango_attribute_copy (_tmp2_);
	pango_attr_list_change (_tmp1_, _tmp3_);
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) label);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	context = _tmp5_;
	_tmp6_ = context;
	_tmp8_ = gtk_style_context_lookup_color (_tmp6_, "placeholder_text_color", &_tmp7_);
	color = _tmp7_;
	if (_tmp8_) {
		PangoAttribute* pango_attr = NULL;
		GdkRGBA _tmp9_;
		GdkRGBA _tmp10_;
		GdkRGBA _tmp11_;
		PangoAttribute* _tmp12_;
		PangoAttribute* _tmp13_;
		PangoAttribute* _tmp14_;
		const gchar* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		PangoAttrList* _tmp18_;
		PangoAttribute* _tmp19_;
		_tmp9_ = color;
		_tmp10_ = color;
		_tmp11_ = color;
		_tmp12_ = pango_attr_foreground_new ((guint16) (_tmp9_.red * G_MAXUINT16), (guint16) (_tmp10_.green * G_MAXUINT16), (guint16) (_tmp11_.blue * G_MAXUINT16));
		pango_attr = _tmp12_;
		_tmp13_ = pango_attr;
		_tmp13_->start_index = (guint) 0;
		_tmp14_ = pango_attr;
		_tmp15_ = gtk_label_get_text (label);
		_tmp16_ = strlen (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp14_->end_index = (guint) _tmp17_;
		_tmp18_ = attrs;
		_tmp19_ = pango_attr;
		pango_attr = NULL;
		pango_attr_list_insert (_tmp18_, _tmp19_);
		_pango_attribute_destroy0 (pango_attr);
	}
	_tmp20_ = attrs;
	gtk_label_set_attributes (label, _tmp20_);
	_g_object_unref0 (context);
	_pango_attr_list_unref0 (attrs);
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		CandidatePanel* self;
		self = _data5_->self;
		_g_object_unref0 (_data5_->text);
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static gboolean
__lambda50_ (Block5Data* _data5_)
{
	CandidatePanel* self;
	gboolean result;
	self = _data5_->self;
	self->priv->m_set_preedit_text_id = (guint) 0;
	candidate_panel_set_preedit_text_real (self, _data5_->text, _data5_->cursor);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda50__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda50_ (self);
	return result;
}

void
candidate_panel_set_preedit_text (CandidatePanel* self,
                                  IBusText* text,
                                  guint cursor)
{
	Block5Data* _data5_;
	IBusText* _tmp0_;
	g_return_if_fail (self != NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_data5_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (text);
	_g_object_unref0 (_data5_->text);
	_data5_->text = _tmp0_;
	_data5_->cursor = cursor;
	if (!self->priv->m_is_wayland) {
		candidate_panel_set_preedit_text_real (self, _data5_->text, _data5_->cursor);
		block5_data_unref (_data5_);
		_data5_ = NULL;
		return;
	}
	if (self->priv->m_set_preedit_text_id > ((guint) 0)) {
		g_source_remove (self->priv->m_set_preedit_text_id);
	}
	self->priv->m_set_preedit_text_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 100, ___lambda50__gsource_func, block5_data_ref (_data5_), block5_data_unref);
	block5_data_unref (_data5_);
	_data5_ = NULL;
}

void
candidate_panel_set_preedit_text_real (CandidatePanel* self,
                                       IBusText* text,
                                       guint cursor)
{
	g_return_if_fail (self != NULL);
	if (text != NULL) {
		gchar* str = NULL;
		const gchar* _tmp0_;
		gchar* _tmp1_;
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp0_ = ibus_text_get_text (text);
		_tmp1_ = g_strdup (_tmp0_);
		str = _tmp1_;
		_tmp2_ = str;
		_tmp3_ = strlen (_tmp2_);
		_tmp4_ = _tmp3_;
		if (_tmp4_ > 0) {
			GtkLabel* _tmp5_;
			const gchar* _tmp6_;
			GtkLabel* _tmp7_;
			GtkLabel* _tmp8_;
			_tmp5_ = self->priv->m_preedit_label;
			_tmp6_ = str;
			gtk_label_set_text (_tmp5_, _tmp6_);
			_tmp7_ = self->priv->m_preedit_label;
			gtk_widget_show ((GtkWidget*) _tmp7_);
			_tmp8_ = self->priv->m_preedit_label;
			candidate_panel_set_attributes (self, _tmp8_, text);
		} else {
			GtkLabel* _tmp9_;
			GtkLabel* _tmp10_;
			_tmp9_ = self->priv->m_preedit_label;
			gtk_label_set_text (_tmp9_, "");
			_tmp10_ = self->priv->m_preedit_label;
			gtk_widget_hide ((GtkWidget*) _tmp10_);
		}
		_g_free0 (str);
	} else {
		GtkLabel* _tmp11_;
		GtkLabel* _tmp12_;
		_tmp11_ = self->priv->m_preedit_label;
		gtk_label_set_text (_tmp11_, "");
		_tmp12_ = self->priv->m_preedit_label;
		gtk_widget_hide ((GtkWidget*) _tmp12_);
	}
	candidate_panel_update (self);
}

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		CandidatePanel* self;
		self = _data6_->self;
		_g_object_unref0 (_data6_->text);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}

static gboolean
__lambda51_ (Block6Data* _data6_)
{
	CandidatePanel* self;
	gboolean result;
	self = _data6_->self;
	self->priv->m_set_auxiliary_text_id = (guint) 0;
	candidate_panel_set_auxiliary_text_real (self, _data6_->text);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda51__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda51_ (self);
	return result;
}

void
candidate_panel_set_auxiliary_text (CandidatePanel* self,
                                    IBusText* text)
{
	Block6Data* _data6_;
	IBusText* _tmp0_;
	g_return_if_fail (self != NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (text);
	_g_object_unref0 (_data6_->text);
	_data6_->text = _tmp0_;
	if (!self->priv->m_is_wayland) {
		candidate_panel_set_auxiliary_text_real (self, _data6_->text);
		block6_data_unref (_data6_);
		_data6_ = NULL;
		return;
	}
	if (self->priv->m_set_auxiliary_text_id > ((guint) 0)) {
		g_source_remove (self->priv->m_set_auxiliary_text_id);
	}
	self->priv->m_set_auxiliary_text_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 100, ___lambda51__gsource_func, block6_data_ref (_data6_), block6_data_unref);
	block6_data_unref (_data6_);
	_data6_ = NULL;
}

void
candidate_panel_set_auxiliary_text_real (CandidatePanel* self,
                                         IBusText* text)
{
	g_return_if_fail (self != NULL);
	if (text != NULL) {
		GtkLabel* _tmp0_;
		const gchar* _tmp1_;
		PangoAttrList* attrs = NULL;
		PangoAttrList* _tmp2_;
		PangoAttrList* _tmp3_;
		PangoAttribute* _tmp4_;
		PangoAttribute* _tmp5_;
		GtkLabel* _tmp6_;
		PangoAttrList* _tmp7_;
		GtkLabel* _tmp8_;
		_tmp0_ = self->priv->m_aux_label;
		_tmp1_ = ibus_text_get_text (text);
		gtk_label_set_text (_tmp0_, _tmp1_);
		_tmp2_ = get_pango_attr_list_from_ibus_text (text);
		attrs = _tmp2_;
		_tmp3_ = attrs;
		_tmp4_ = self->priv->m_language_attribute;
		_tmp5_ = pango_attribute_copy (_tmp4_);
		pango_attr_list_change (_tmp3_, _tmp5_);
		_tmp6_ = self->priv->m_aux_label;
		_tmp7_ = attrs;
		gtk_label_set_attributes (_tmp6_, _tmp7_);
		_tmp8_ = self->priv->m_aux_label;
		gtk_widget_show ((GtkWidget*) _tmp8_);
		_pango_attr_list_unref0 (attrs);
	} else {
		GtkLabel* _tmp9_;
		GtkLabel* _tmp10_;
		_tmp9_ = self->priv->m_aux_label;
		gtk_label_set_text (_tmp9_, "");
		_tmp10_ = self->priv->m_aux_label;
		gtk_widget_hide ((GtkWidget*) _tmp10_);
	}
	candidate_panel_update (self);
}

static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		CandidatePanel* self;
		self = _data7_->self;
		_g_object_unref0 (_data7_->table);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

static gboolean
__lambda52_ (Block7Data* _data7_)
{
	CandidatePanel* self;
	gboolean result;
	self = _data7_->self;
	self->priv->m_set_lookup_table_id = (guint) 0;
	candidate_panel_set_lookup_table_real (self, _data7_->table);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda52__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda52_ (self);
	return result;
}

void
candidate_panel_set_lookup_table (CandidatePanel* self,
                                  IBusLookupTable* table)
{
	Block7Data* _data7_;
	IBusLookupTable* _tmp0_;
	g_return_if_fail (self != NULL);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_data7_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (table);
	_g_object_unref0 (_data7_->table);
	_data7_->table = _tmp0_;
	if (!self->priv->m_is_wayland) {
		candidate_panel_set_lookup_table_real (self, _data7_->table);
		block7_data_unref (_data7_);
		_data7_ = NULL;
		return;
	}
	if (self->priv->m_set_lookup_table_id > ((guint) 0)) {
		gboolean _tmp1_ = FALSE;
		if (_data7_->table == NULL) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			gboolean _tmp3_ = FALSE;
			gboolean _tmp4_ = FALSE;
			gboolean _tmp5_ = FALSE;
			if (self->priv->m_prev_page_size == ibus_lookup_table_get_page_size (_data7_->table)) {
				_tmp5_ = self->priv->m_prev_ncandidates == ibus_lookup_table_get_number_of_candidates (_data7_->table);
			} else {
				_tmp5_ = FALSE;
			}
			if (_tmp5_) {
				_tmp4_ = self->priv->m_prev_cursor == ibus_lookup_table_get_cursor_pos (_data7_->table);
			} else {
				_tmp4_ = FALSE;
			}
			if (_tmp4_) {
				_tmp3_ = self->priv->m_prev_cursor_in_page == ibus_lookup_table_get_cursor_in_page (_data7_->table);
			} else {
				_tmp3_ = FALSE;
			}
			if (_tmp3_) {
				_tmp2_ = self->priv->m_prev_show_cursor == ibus_lookup_table_is_cursor_visible (_data7_->table);
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		if (_tmp1_) {
			g_source_remove (self->priv->m_set_lookup_table_id);
		}
	}
	if (_data7_->table != NULL) {
		if (self->priv->m_prev_ncandidates == ((guint) 0)) {
			self->priv->m_first_set_lookup_table = TRUE;
		}
		self->priv->m_prev_page_size = ibus_lookup_table_get_page_size (_data7_->table);
		self->priv->m_prev_ncandidates = ibus_lookup_table_get_number_of_candidates (_data7_->table);
		self->priv->m_prev_cursor = ibus_lookup_table_get_cursor_pos (_data7_->table);
		self->priv->m_prev_cursor_in_page = ibus_lookup_table_get_cursor_in_page (_data7_->table);
		self->priv->m_prev_show_cursor = ibus_lookup_table_is_cursor_visible (_data7_->table);
	} else {
		self->priv->m_prev_cursor_in_page = (guint) 0;
		self->priv->m_prev_cursor = self->priv->m_prev_cursor_in_page;
		self->priv->m_prev_ncandidates = self->priv->m_prev_cursor;
		self->priv->m_prev_page_size = self->priv->m_prev_ncandidates;
		self->priv->m_prev_show_cursor = FALSE;
	}
	self->priv->m_set_lookup_table_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 100, ___lambda52__gsource_func, block7_data_ref (_data7_), block7_data_unref);
	block7_data_unref (_data7_);
	_data7_ = NULL;
}

static void
_vala_array_add9 (IBusText** * array,
                  gint* length,
                  gint* size,
                  IBusText* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (IBusText*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add10 (IBusText** * array,
                   gint* length,
                   gint* size,
                   IBusText* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (IBusText*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

void
candidate_panel_set_lookup_table_real (CandidatePanel* self,
                                       IBusLookupTable* table)
{
	IBusText** candidates = NULL;
	IBusText** _tmp0_;
	gint candidates_length1;
	gint _candidates_size_;
	guint cursor_in_page = 0U;
	gboolean show_cursor = FALSE;
	IBusText** labels = NULL;
	IBusText** _tmp1_;
	gint labels_length1;
	gint _labels_size_;
	IBusOrientation orientation = 0;
	CandidateArea* _tmp13_;
	IBusText** _tmp14_;
	gint _tmp14__length1;
	IBusText** _tmp15_;
	gint _tmp15__length1;
	IBusText** _tmp16_;
	gint _tmp16__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_new0 (IBusText*, 0 + 1);
	candidates = _tmp0_;
	candidates_length1 = 0;
	_candidates_size_ = candidates_length1;
	cursor_in_page = (guint) 0;
	show_cursor = TRUE;
	_tmp1_ = g_new0 (IBusText*, 0 + 1);
	labels = _tmp1_;
	labels_length1 = 0;
	_labels_size_ = labels_length1;
	orientation = IBUS_ORIENTATION_SYSTEM;
	if (table != NULL) {
		guint page_size = 0U;
		guint ncandidates = 0U;
		guint cursor = 0U;
		guint page_start_pos = 0U;
		guint page_end_pos = 0U;
		page_size = ibus_lookup_table_get_page_size (table);
		ncandidates = ibus_lookup_table_get_number_of_candidates (table);
		cursor = ibus_lookup_table_get_cursor_pos (table);
		cursor_in_page = ibus_lookup_table_get_cursor_in_page (table);
		show_cursor = ibus_lookup_table_is_cursor_visible (table);
		page_start_pos = (cursor / page_size) * page_size;
		page_end_pos = MIN (page_start_pos + page_size, ncandidates);
		{
			guint i = 0U;
			i = page_start_pos;
			{
				gboolean _tmp2_ = FALSE;
				_tmp2_ = TRUE;
				while (TRUE) {
					IBusText* _tmp4_;
					IBusText* _tmp5_;
					if (!_tmp2_) {
						guint _tmp3_;
						_tmp3_ = i;
						i = _tmp3_ + 1;
					}
					_tmp2_ = FALSE;
					if (!(i < page_end_pos)) {
						break;
					}
					_tmp4_ = ibus_lookup_table_get_candidate (table, i);
					_tmp5_ = _g_object_ref0 (_tmp4_);
					_vala_array_add9 (&candidates, &candidates_length1, &_candidates_size_, _tmp5_);
				}
			}
		}
		{
			guint i = 0U;
			i = (guint) 0;
			{
				gboolean _tmp6_ = FALSE;
				_tmp6_ = TRUE;
				while (TRUE) {
					IBusText* label = NULL;
					IBusText* _tmp8_;
					IBusText* _tmp9_;
					IBusText* _tmp10_;
					if (!_tmp6_) {
						guint _tmp7_;
						_tmp7_ = i;
						i = _tmp7_ + 1;
					}
					_tmp6_ = FALSE;
					if (!(i < page_size)) {
						break;
					}
					_tmp8_ = ibus_lookup_table_get_label (table, i);
					_tmp9_ = _g_object_ref0 (_tmp8_);
					label = _tmp9_;
					_tmp10_ = label;
					if (_tmp10_ != NULL) {
						IBusText* _tmp11_;
						IBusText* _tmp12_;
						_tmp11_ = label;
						_tmp12_ = _g_object_ref0 (_tmp11_);
						_vala_array_add10 (&labels, &labels_length1, &_labels_size_, _tmp12_);
					}
					_g_object_unref0 (label);
				}
			}
		}
		orientation = (IBusOrientation) ibus_lookup_table_get_orientation (table);
	}
	_tmp13_ = self->priv->m_candidate_area;
	_tmp14_ = candidates;
	_tmp14__length1 = candidates_length1;
	candidate_area_set_candidates (_tmp13_, _tmp14_, (gint) _tmp14__length1, cursor_in_page, show_cursor);
	_tmp15_ = labels;
	_tmp15__length1 = labels_length1;
	candidate_panel_set_labels (self, _tmp15_, (gint) _tmp15__length1);
	if (table != NULL) {
		candidate_panel_set_orientation (self, orientation);
	}
	_tmp16_ = candidates;
	_tmp16__length1 = candidates_length1;
	if (_tmp16__length1 != 0) {
		CandidateArea* _tmp17_;
		_tmp17_ = self->priv->m_candidate_area;
		gtk_widget_show_all ((GtkWidget*) _tmp17_);
	} else {
		CandidateArea* _tmp18_;
		_tmp18_ = self->priv->m_candidate_area;
		gtk_widget_hide ((GtkWidget*) _tmp18_);
	}
	candidate_panel_update (self);
	labels = (_vala_array_free (labels, labels_length1, (GDestroyNotify) g_object_unref), NULL);
	candidates = (_vala_array_free (candidates, candidates_length1, (GDestroyNotify) g_object_unref), NULL);
}

void
candidate_panel_set_content_type (CandidatePanel* self,
                                  guint purpose,
                                  guint hints)
{
	g_return_if_fail (self != NULL);
	self->priv->m_vertical_writing = (hints & IBUS_INPUT_HINT_VERTICAL_WRITING) != ((guint) 0);
}

static gboolean
__lambda49_ (CandidatePanel* self)
{
	gboolean result;
	self->priv->m_update_id = (guint) 0;
	candidate_panel_update_real (self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda49__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda49_ ((CandidatePanel*) self);
	return result;
}

static void
candidate_panel_update (CandidatePanel* self)
{
	g_return_if_fail (self != NULL);
	if (!self->priv->m_is_wayland) {
		candidate_panel_update_real (self);
		return;
	}
	if (self->priv->m_first_set_lookup_table) {
		self->priv->m_first_set_lookup_table = FALSE;
		if (self->priv->m_update_id > ((guint) 0)) {
			g_source_remove (self->priv->m_update_id);
			self->priv->m_update_id = (guint) 0;
		}
		candidate_panel_update_real (self);
		return;
	}
	if (self->priv->m_update_id > ((guint) 0)) {
		g_source_remove (self->priv->m_update_id);
	}
	self->priv->m_update_id = g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 100, ___lambda49__gsource_func, g_object_ref (self), g_object_unref);
}

static void
candidate_panel_update_real (CandidatePanel* self)
{
	GtkWindow* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	CandidateArea* _tmp3_;
	gboolean _tmp6_ = FALSE;
	GtkLabel* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->m_toplevel;
	gtk_window_resize (_tmp0_, 1, 1);
	_tmp3_ = self->priv->m_candidate_area;
	if (gtk_widget_get_visible ((GtkWidget*) _tmp3_)) {
		_tmp2_ = TRUE;
	} else {
		GtkLabel* _tmp4_;
		_tmp4_ = self->priv->m_preedit_label;
		_tmp2_ = gtk_widget_get_visible ((GtkWidget*) _tmp4_);
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		GtkLabel* _tmp5_;
		_tmp5_ = self->priv->m_aux_label;
		_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp5_);
	}
	if (_tmp1_) {
		candidate_panel_show (self);
	} else {
		candidate_panel_hide (self);
	}
	_tmp7_ = self->priv->m_aux_label;
	if (gtk_widget_get_visible ((GtkWidget*) _tmp7_)) {
		gboolean _tmp8_ = FALSE;
		CandidateArea* _tmp9_;
		_tmp9_ = self->priv->m_candidate_area;
		if (gtk_widget_get_visible ((GtkWidget*) _tmp9_)) {
			_tmp8_ = TRUE;
		} else {
			GtkLabel* _tmp10_;
			_tmp10_ = self->priv->m_preedit_label;
			_tmp8_ = gtk_widget_get_visible ((GtkWidget*) _tmp10_);
		}
		_tmp6_ = _tmp8_;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		HSeparator* _tmp11_;
		_tmp11_ = self->priv->m_hseparator;
		gtk_widget_show ((GtkWidget*) _tmp11_);
	} else {
		HSeparator* _tmp12_;
		_tmp12_ = self->priv->m_hseparator;
		gtk_widget_hide ((GtkWidget*) _tmp12_);
	}
}

static void
__lambda44_ (CandidatePanel* self,
             CandidateArea* w,
             guint i,
             guint b,
             guint s)
{
	g_return_if_fail (w != NULL);
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_CANDIDATE_CLICKED_SIGNAL], 0, i, b, s);
}

static void
___lambda44__candidate_area_candidate_clicked (CandidateArea* _sender,
                                               guint index,
                                               guint button,
                                               guint state,
                                               gpointer self)
{
	__lambda44_ ((CandidatePanel*) self, _sender, index, button, state);
}

static void
__lambda45_ (CandidatePanel* self,
             CandidateArea* c)
{
	g_return_if_fail (c != NULL);
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_PAGE_UP_SIGNAL], 0);
}

static void
___lambda45__candidate_area_page_up (CandidateArea* _sender,
                                     gpointer self)
{
	__lambda45_ ((CandidatePanel*) self, _sender);
}

static void
__lambda46_ (CandidatePanel* self,
             CandidateArea* c)
{
	g_return_if_fail (c != NULL);
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_PAGE_DOWN_SIGNAL], 0);
}

static void
___lambda46__candidate_area_page_down (CandidateArea* _sender,
                                       gpointer self)
{
	__lambda46_ ((CandidatePanel*) self, _sender);
}

static void
__lambda47_ (CandidatePanel* self,
             CandidateArea* c)
{
	g_return_if_fail (c != NULL);
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_CURSOR_UP_SIGNAL], 0);
}

static void
___lambda47__candidate_area_cursor_up (CandidateArea* _sender,
                                       gpointer self)
{
	__lambda47_ ((CandidatePanel*) self, _sender);
}

static void
__lambda48_ (CandidatePanel* self,
             CandidateArea* c)
{
	g_return_if_fail (c != NULL);
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_CURSOR_DOWN_SIGNAL], 0);
}

static void
___lambda48__candidate_area_cursor_down (CandidateArea* _sender,
                                         gpointer self)
{
	__lambda48_ ((CandidatePanel*) self, _sender);
}

static void
candidate_panel_create_ui (CandidatePanel* self)
{
	GtkLabel* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	CandidateArea* _tmp14_;
	CandidateArea* _tmp15_;
	CandidateArea* _tmp16_;
	CandidateArea* _tmp17_;
	CandidateArea* _tmp18_;
	CandidateArea* _tmp19_;
	HSeparator* _tmp20_;
	HSeparator* _tmp21_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->m_preedit_label);
	self->priv->m_preedit_label = _tmp0_;
	_tmp1_ = self->priv->m_preedit_label;
	gtk_widget_set_size_request ((GtkWidget*) _tmp1_, 20, -1);
	_tmp2_ = self->priv->m_preedit_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_START);
	_tmp3_ = self->priv->m_preedit_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
	_tmp4_ = self->priv->m_preedit_label;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp4_, 8);
	_tmp5_ = self->priv->m_preedit_label;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp5_, 8);
	_tmp6_ = self->priv->m_preedit_label;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp6_, TRUE);
	_tmp7_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->m_aux_label);
	self->priv->m_aux_label = _tmp7_;
	_tmp8_ = self->priv->m_aux_label;
	gtk_widget_set_size_request ((GtkWidget*) _tmp8_, 20, -1);
	_tmp9_ = self->priv->m_aux_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_START);
	_tmp10_ = self->priv->m_aux_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp10_, GTK_ALIGN_CENTER);
	_tmp11_ = self->priv->m_aux_label;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp11_, 8);
	_tmp12_ = self->priv->m_aux_label;
	gtk_widget_set_margin_end ((GtkWidget*) _tmp12_, 8);
	_tmp13_ = self->priv->m_aux_label;
	gtk_widget_set_no_show_all ((GtkWidget*) _tmp13_, TRUE);
	_tmp14_ = candidate_area_new (self->priv->m_vertical_panel_system);
	g_object_ref_sink (_tmp14_);
	_g_object_unref0 (self->priv->m_candidate_area);
	self->priv->m_candidate_area = _tmp14_;
	_tmp15_ = self->priv->m_candidate_area;
	g_signal_connect_object (_tmp15_, "candidate-clicked", (GCallback) ___lambda44__candidate_area_candidate_clicked, self, 0);
	_tmp16_ = self->priv->m_candidate_area;
	g_signal_connect_object (_tmp16_, "page-up", (GCallback) ___lambda45__candidate_area_page_up, self, 0);
	_tmp17_ = self->priv->m_candidate_area;
	g_signal_connect_object (_tmp17_, "page-down", (GCallback) ___lambda46__candidate_area_page_down, self, 0);
	_tmp18_ = self->priv->m_candidate_area;
	g_signal_connect_object (_tmp18_, "cursor-up", (GCallback) ___lambda47__candidate_area_cursor_up, self, 0);
	_tmp19_ = self->priv->m_candidate_area;
	g_signal_connect_object (_tmp19_, "cursor-down", (GCallback) ___lambda48__candidate_area_cursor_down, self, 0);
	_tmp20_ = hseparator_new ();
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->m_hseparator);
	self->priv->m_hseparator = _tmp20_;
	_tmp21_ = self->priv->m_hseparator;
	gtk_widget_set_visible ((GtkWidget*) _tmp21_, TRUE);
	candidate_panel_pack_all_widgets (self);
}

static void
candidate_panel_pack_all_widgets (CandidatePanel* self)
{
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	GtkBox* _tmp2_;
	GtkLabel* _tmp3_;
	GtkBox* _tmp4_;
	HSeparator* _tmp5_;
	GtkBox* _tmp6_;
	CandidateArea* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->m_vbox;
	_tmp1_ = self->priv->m_preedit_label;
	gtk_box_pack_start (_tmp0_, (GtkWidget*) _tmp1_, FALSE, FALSE, (guint) 4);
	_tmp2_ = self->priv->m_vbox;
	_tmp3_ = self->priv->m_aux_label;
	gtk_box_pack_start (_tmp2_, (GtkWidget*) _tmp3_, FALSE, FALSE, (guint) 4);
	_tmp4_ = self->priv->m_vbox;
	_tmp5_ = self->priv->m_hseparator;
	gtk_box_pack_start (_tmp4_, (GtkWidget*) _tmp5_, FALSE, FALSE, (guint) 0);
	_tmp6_ = self->priv->m_vbox;
	_tmp7_ = self->priv->m_candidate_area;
	gtk_box_pack_start (_tmp6_, (GtkWidget*) _tmp7_, FALSE, FALSE, (guint) 0);
}

void
candidate_panel_show (CandidatePanel* self)
{
	GtkWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->m_toplevel;
	gtk_widget_show ((GtkWidget*) _tmp0_);
}

void
candidate_panel_hide (CandidatePanel* self)
{
	GtkWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	if (self->priv->m_is_wayland) {
		g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_REALIZE_SURFACE_SIGNAL], 0, NULL);
	}
	_tmp0_ = self->priv->m_toplevel;
	gtk_widget_hide ((GtkWidget*) _tmp0_);
}

/**
     * move:
     * @x: left position of the #CandidatePanel
     * @y: top position of the #CandidatePanel
     */
static void
candidate_panel_move (CandidatePanel* self,
                      gint x,
                      gint y)
{
	GtkWindow* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->m_toplevel;
	gtk_window_move (_tmp0_, x, y);
}

static void
candidate_panel_adjust_window_position (CandidatePanel* self,
                                        GtkWidget* window)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	if (!self->priv->m_vertical_writing) {
		candidate_panel_adjust_window_position_horizontal (self, window);
	} else {
		candidate_panel_adjust_window_position_vertical (self, window);
	}
}

/**
     * adjust_window_position_horizontal:
     * @window: A Gtk.Widget of the toplevel window.
     *
     * Horizontal writing mode but not the horizontal lookup table
     * when the allocation is emmitted.
     */
static void
candidate_panel_adjust_window_position_horizontal (CandidatePanel* self,
                                                   GtkWidget* window)
{
	GdkPoint cursor_left_bottom = {0};
	GdkRectangle _tmp0_;
	GdkRectangle _tmp1_;
	GdkRectangle _tmp2_;
	GdkPoint _tmp3_ = {0};
	GtkAllocation allocation = {0};
	GtkWindow* _tmp4_;
	GtkAllocation _tmp5_ = {0};
	GdkPoint window_right_bottom = {0};
	GdkPoint _tmp6_;
	GtkAllocation _tmp7_;
	GdkPoint _tmp8_;
	GtkAllocation _tmp9_;
	GdkPoint _tmp10_ = {0};
	GdkRectangle monitor_area = {0};
	GdkRectangle _tmp11_ = {0};
	gint monitor_right = 0;
	GdkRectangle _tmp12_;
	GdkRectangle _tmp13_;
	gint monitor_bottom = 0;
	GdkRectangle _tmp14_;
	GdkRectangle _tmp15_;
	gint x = 0;
	gint y = 0;
	GdkPoint _tmp16_;
	GdkPoint _tmp19_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	_tmp0_ = self->priv->m_cursor_location;
	_tmp1_ = self->priv->m_cursor_location;
	_tmp2_ = self->priv->m_cursor_location;
	_tmp3_.x = _tmp0_.x;
	_tmp3_.y = _tmp1_.y + _tmp2_.height;
	cursor_left_bottom = _tmp3_;
	_tmp4_ = self->priv->m_toplevel;
	gtk_widget_get_allocation ((GtkWidget*) _tmp4_, &_tmp5_);
	allocation = _tmp5_;
	_tmp6_ = cursor_left_bottom;
	_tmp7_ = allocation;
	_tmp8_ = cursor_left_bottom;
	_tmp9_ = allocation;
	_tmp10_.x = _tmp6_.x + _tmp7_.width;
	_tmp10_.y = _tmp8_.y + _tmp9_.height;
	window_right_bottom = _tmp10_;
	candidate_panel_get_monitor_geometry (self, window, &_tmp11_);
	monitor_area = _tmp11_;
	_tmp12_ = monitor_area;
	_tmp13_ = monitor_area;
	monitor_right = _tmp12_.x + _tmp13_.width;
	_tmp14_ = monitor_area;
	_tmp15_ = monitor_area;
	monitor_bottom = _tmp14_.y + _tmp15_.height;
	_tmp16_ = window_right_bottom;
	if (_tmp16_.x > monitor_right) {
		GtkAllocation _tmp17_;
		_tmp17_ = allocation;
		x = monitor_right - _tmp17_.width;
	} else {
		GdkPoint _tmp18_;
		_tmp18_ = cursor_left_bottom;
		x = _tmp18_.x;
	}
	if (x < 0) {
		x = 0;
	}
	_tmp19_ = window_right_bottom;
	if (_tmp19_.y > monitor_bottom) {
		GdkRectangle _tmp20_;
		GtkAllocation _tmp21_;
		_tmp20_ = self->priv->m_cursor_location;
		_tmp21_ = allocation;
		y = _tmp20_.y - _tmp21_.height;
	} else {
		GdkPoint _tmp22_;
		_tmp22_ = cursor_left_bottom;
		y = _tmp22_.y;
	}
	if (y < 0) {
		y = 0;
	}
	candidate_panel_move (self, x, y);
}

/**
     * adjust_window_position_vertical:
     * @window: A Gtk.Widget of the toplevel window.
     *
     * Vertical writing mode but not the vertical lookup table
     * when the allocation is emmitted.
     */
static void
candidate_panel_adjust_window_position_vertical (CandidatePanel* self,
                                                 GtkWidget* window)
{
	gint char_size = 0;
	GdkRectangle _tmp0_;
	GdkRectangle _tmp1_;
	GdkPoint cursor_right_bottom = {0};
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	GdkPoint _tmp4_ = {0};
	GtkAllocation allocation = {0};
	GtkWindow* _tmp5_;
	GtkAllocation _tmp6_ = {0};
	GdkPoint hwindow_right_bottom = {0};
	GdkRectangle _tmp7_;
	GtkAllocation _tmp8_;
	GdkPoint _tmp9_;
	GtkAllocation _tmp10_;
	GdkPoint _tmp11_ = {0};
	GdkPoint vwindow_left_bottom = {0};
	GdkRectangle _tmp12_;
	GtkAllocation _tmp13_;
	GdkRectangle _tmp14_;
	GtkAllocation _tmp15_;
	GdkPoint _tmp16_ = {0};
	GdkRectangle monitor_area = {0};
	GdkRectangle _tmp17_ = {0};
	gint monitor_right = 0;
	GdkRectangle _tmp18_;
	GdkRectangle _tmp19_;
	gint monitor_bottom = 0;
	GdkRectangle _tmp20_;
	GdkRectangle _tmp21_;
	gint x = 0;
	gint y = 0;
	CandidateArea* _tmp22_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	_tmp0_ = self->priv->m_cursor_location;
	_tmp1_ = self->priv->m_cursor_location;
	char_size = MAX (_tmp0_.width, _tmp1_.height);
	_tmp2_ = self->priv->m_cursor_location;
	_tmp3_ = self->priv->m_cursor_location;
	_tmp4_.x = _tmp2_.x + char_size;
	_tmp4_.y = _tmp3_.y + char_size;
	cursor_right_bottom = _tmp4_;
	_tmp5_ = self->priv->m_toplevel;
	gtk_widget_get_allocation ((GtkWidget*) _tmp5_, &_tmp6_);
	allocation = _tmp6_;
	_tmp7_ = self->priv->m_cursor_location;
	_tmp8_ = allocation;
	_tmp9_ = cursor_right_bottom;
	_tmp10_ = allocation;
	_tmp11_.x = _tmp7_.x + _tmp8_.width;
	_tmp11_.y = _tmp9_.y + _tmp10_.height;
	hwindow_right_bottom = _tmp11_;
	_tmp12_ = self->priv->m_cursor_location;
	_tmp13_ = allocation;
	_tmp14_ = self->priv->m_cursor_location;
	_tmp15_ = allocation;
	_tmp16_.x = _tmp12_.x - _tmp13_.width;
	_tmp16_.y = _tmp14_.y + _tmp15_.height;
	vwindow_left_bottom = _tmp16_;
	candidate_panel_get_monitor_geometry (self, window, &_tmp17_);
	monitor_area = _tmp17_;
	_tmp18_ = monitor_area;
	_tmp19_ = monitor_area;
	monitor_right = _tmp18_.x + _tmp19_.width;
	_tmp20_ = monitor_area;
	_tmp21_ = monitor_area;
	monitor_bottom = _tmp20_.y + _tmp21_.height;
	_tmp22_ = self->priv->m_candidate_area;
	if (!candidate_area_get_vertical (_tmp22_)) {
		GdkPoint _tmp23_;
		GdkPoint _tmp26_;
		_tmp23_ = hwindow_right_bottom;
		if (_tmp23_.x > monitor_right) {
			GtkAllocation _tmp24_;
			_tmp24_ = allocation;
			x = monitor_right - _tmp24_.width;
		} else {
			GdkRectangle _tmp25_;
			_tmp25_ = self->priv->m_cursor_location;
			x = _tmp25_.x;
		}
		_tmp26_ = hwindow_right_bottom;
		if (_tmp26_.y > monitor_bottom) {
			GdkRectangle _tmp27_;
			GtkAllocation _tmp28_;
			_tmp27_ = self->priv->m_cursor_location;
			_tmp28_ = allocation;
			y = _tmp27_.y - _tmp28_.height;
		} else {
			GdkPoint _tmp29_;
			_tmp29_ = cursor_right_bottom;
			y = _tmp29_.y;
		}
	} else {
		GdkPoint _tmp30_;
		GdkPoint _tmp35_;
		_tmp30_ = vwindow_left_bottom;
		if (_tmp30_.x > monitor_right) {
			GtkAllocation _tmp31_;
			_tmp31_ = allocation;
			x = monitor_right - _tmp31_.width;
		} else {
			GdkPoint _tmp32_;
			_tmp32_ = vwindow_left_bottom;
			if (_tmp32_.x < 0) {
				GdkPoint _tmp33_;
				_tmp33_ = cursor_right_bottom;
				x = _tmp33_.x;
			} else {
				GdkPoint _tmp34_;
				_tmp34_ = vwindow_left_bottom;
				x = _tmp34_.x;
			}
		}
		_tmp35_ = vwindow_left_bottom;
		if (_tmp35_.y > monitor_bottom) {
			GtkAllocation _tmp36_;
			_tmp36_ = allocation;
			y = monitor_bottom - _tmp36_.height;
		} else {
			GdkRectangle _tmp37_;
			_tmp37_ = self->priv->m_cursor_location;
			y = _tmp37_.y;
		}
	}
	if (x < 0) {
		x = 0;
	}
	if (y < 0) {
		y = 0;
	}
	candidate_panel_move (self, x, y);
}

static void
candidate_panel_get_monitor_geometry (CandidatePanel* self,
                                      GtkWidget* window,
                                      GdkRectangle* result)
{
	GdkRectangle monitor_area = {0};
	GdkRectangle _tmp0_ = {0};
	GdkMonitor* monitor = NULL;
	GdkDisplay* _tmp1_;
	GdkRectangle _tmp2_;
	GdkRectangle _tmp3_;
	GdkMonitor* _tmp4_;
	GdkMonitor* _tmp5_;
	GdkRectangle _tmp6_ = {0};
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	_tmp0_.x = 0;
	monitor_area = _tmp0_;
	_tmp1_ = gtk_widget_get_display (window);
	_tmp2_ = self->priv->m_cursor_location;
	_tmp3_ = self->priv->m_cursor_location;
	_tmp4_ = gdk_display_get_monitor_at_point (_tmp1_, _tmp2_.x, _tmp3_.y);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	monitor = _tmp5_;
	gdk_monitor_get_geometry (monitor, &_tmp6_);
	monitor_area = _tmp6_;
	*result = monitor_area;
	_g_object_unref0 (monitor);
	return;
}

static void
candidate_panel_realize_window (CandidatePanel* self,
                                gboolean initial)
{
	GdkWindow* window = NULL;
	GtkWindow* _tmp0_;
	GdkWindow* _tmp1_;
	GdkWindow* _tmp2_;
	GdkWindow* _tmp3_;
	GType instance_type = G_TYPE_NONE;
	GdkWindow* _tmp4_;
	GType wayland_type = G_TYPE_NONE;
	void* surface = NULL;
	GdkWindow* _tmp6_;
	void* _tmp7_;
	void* _tmp8_;
	g_return_if_fail (self != NULL);
	if (self->priv->m_no_wayland_panel) {
		return;
	}
	_tmp0_ = self->priv->m_toplevel;
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	window = _tmp2_;
	_tmp3_ = window;
	if (!gdk_window_ensure_native (_tmp3_)) {
		g_warning ("candidatepanel.vala:648: No native window.");
		_g_object_unref0 (window);
		return;
	}
	_tmp4_ = window;
	instance_type = G_TYPE_FROM_INSTANCE ((GObject*) _tmp4_);
	wayland_type = gdk_wayland_window_get_type ();
	if (!g_type_is_a (instance_type, wayland_type)) {
		g_warning ("candidatepanel.vala:654: Not GdkWindowWayland.");
		_g_object_unref0 (window);
		return;
	}
	if (initial) {
		GdkWindow* _tmp5_;
		_tmp5_ = window;
		gdk_wayland_window_set_use_custom_surface (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gdk_wayland_window_get_type (), GdkWaylandWindow));
	}
	_tmp6_ = window;
	_tmp7_ = gdk_wayland_window_get_wl_surface (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gdk_wayland_window_get_type (), GdkWaylandWindow));
	surface = _tmp7_;
	_tmp8_ = surface;
	g_signal_emit (self, candidate_panel_signals[CANDIDATE_PANEL_REALIZE_SURFACE_SIGNAL], 0, _tmp8_);
	_g_object_unref0 (window);
}

static void
g_cclosure_user_marshal_VOID__UINT_UINT_UINT (GClosure * closure,
                                              GValue * return_value,
                                              guint n_param_values,
                                              const GValue * param_values,
                                              gpointer invocation_hint,
                                              gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__UINT_UINT_UINT) (gpointer data1, guint arg_1, guint arg_2, guint arg_3, gpointer data2);
	register GMarshalFunc_VOID__UINT_UINT_UINT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__UINT_UINT_UINT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_uint (param_values + 1), g_value_get_uint (param_values + 2), g_value_get_uint (param_values + 3), data2);
}

static void
candidate_panel_class_init (CandidatePanelClass * klass,
                            gpointer klass_data)
{
	candidate_panel_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CandidatePanel_private_offset);
	G_OBJECT_CLASS (klass)->finalize = candidate_panel_finalize;
	candidate_panel_signals[CANDIDATE_PANEL_CURSOR_UP_SIGNAL] = g_signal_new ("cursor-up", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	candidate_panel_signals[CANDIDATE_PANEL_CURSOR_DOWN_SIGNAL] = g_signal_new ("cursor-down", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	candidate_panel_signals[CANDIDATE_PANEL_PAGE_UP_SIGNAL] = g_signal_new ("page-up", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	candidate_panel_signals[CANDIDATE_PANEL_PAGE_DOWN_SIGNAL] = g_signal_new ("page-down", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	candidate_panel_signals[CANDIDATE_PANEL_CANDIDATE_CLICKED_SIGNAL] = g_signal_new ("candidate-clicked", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
	candidate_panel_signals[CANDIDATE_PANEL_FORWARD_PROCESS_KEY_EVENT_SIGNAL] = g_signal_new ("forward-process-key-event", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__UINT_UINT_UINT, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT);
	candidate_panel_signals[CANDIDATE_PANEL_REALIZE_SURFACE_SIGNAL] = g_signal_new ("realize-surface", TYPE_CANDIDATE_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
}

static void
candidate_panel_instance_init (CandidatePanel * self,
                               gpointer klass)
{
	self->priv = candidate_panel_get_instance_private (self);
	self->priv->m_vertical_panel_system = TRUE;
}

static void
candidate_panel_finalize (GObject * obj)
{
	CandidatePanel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CANDIDATE_PANEL, CandidatePanel);
	_g_object_unref0 (self->priv->m_toplevel);
	_g_object_unref0 (self->priv->m_vbox);
	_g_object_unref0 (self->priv->m_preedit_label);
	_g_object_unref0 (self->priv->m_aux_label);
	_g_object_unref0 (self->priv->m_candidate_area);
	_g_object_unref0 (self->priv->m_hseparator);
	_pango_attribute_destroy0 (self->priv->m_language_attribute);
	G_OBJECT_CLASS (candidate_panel_parent_class)->finalize (obj);
}

static GType
candidate_panel_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CandidatePanelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) candidate_panel_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CandidatePanel), 0, (GInstanceInitFunc) candidate_panel_instance_init, NULL };
	GType candidate_panel_type_id;
	candidate_panel_type_id = g_type_register_static (gtk_box_get_type (), "CandidatePanel", &g_define_type_info, 0);
	CandidatePanel_private_offset = g_type_add_instance_private (candidate_panel_type_id, sizeof (CandidatePanelPrivate));
	return candidate_panel_type_id;
}

GType
candidate_panel_get_type (void)
{
	static volatile gsize candidate_panel_type_id__once = 0;
	if (g_once_init_enter (&candidate_panel_type_id__once)) {
		GType candidate_panel_type_id;
		candidate_panel_type_id = candidate_panel_get_type_once ();
		g_once_init_leave (&candidate_panel_type_id__once, candidate_panel_type_id);
	}
	return candidate_panel_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

