Logo Search packages:      
Sourcecode: caribou version File versions  Download package

xadapter.c

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


#include <glib.h>
#include <glib-object.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xregion.h>
#include <X11/XKBlib.h>
#include <libxklavier/xklavier.h>
#include <gdk/gdk.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdkx.h>
#include <X11/extensions/XTest.h>
#include <gobject/gvaluecollector.h>


#define CARIBOU_TYPE_XADAPTER (caribou_xadapter_get_type ())
#define CARIBOU_XADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_XADAPTER, CaribouXAdapter))
#define CARIBOU_XADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_XADAPTER, CaribouXAdapterClass))
#define CARIBOU_IS_XADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_XADAPTER))
#define CARIBOU_IS_XADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_XADAPTER))
#define CARIBOU_XADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_XADAPTER, CaribouXAdapterClass))

typedef struct _CaribouXAdapter CaribouXAdapter;
typedef struct _CaribouXAdapterClass CaribouXAdapterClass;
typedef struct _CaribouXAdapterPrivate CaribouXAdapterPrivate;

#define CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER (caribou_xadapter_key_button_handler_get_type ())
#define CARIBOU_XADAPTER_KEY_BUTTON_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER, CaribouXAdapterKeyButtonHandler))
#define CARIBOU_XADAPTER_KEY_BUTTON_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER, CaribouXAdapterKeyButtonHandlerClass))
#define CARIBOU_XADAPTER_IS_KEY_BUTTON_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER))
#define CARIBOU_XADAPTER_IS_KEY_BUTTON_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER))
#define CARIBOU_XADAPTER_KEY_BUTTON_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER, CaribouXAdapterKeyButtonHandlerClass))

typedef struct _CaribouXAdapterKeyButtonHandler CaribouXAdapterKeyButtonHandler;
typedef struct _CaribouXAdapterKeyButtonHandlerClass CaribouXAdapterKeyButtonHandlerClass;
#define _0(var) ((var == NULL) ? NULL : (var = ( (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _caribou_xadapter_key_button_handler_unref0(var) ((var == NULL) ? NULL : (var = (caribou_xadapter_key_button_handler_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _CaribouXAdapterKeyButtonHandlerPrivate CaribouXAdapterKeyButtonHandlerPrivate;
typedef struct _CaribouXAdapterParamSpecKeyButtonHandler CaribouXAdapterParamSpecKeyButtonHandler;

struct _CaribouXAdapter {
      GObject parent_instance;
      CaribouXAdapterPrivate * priv;
};

struct _CaribouXAdapterClass {
      GObjectClass parent_class;
};

00058 struct _CaribouXAdapterPrivate {
      Display* xdisplay;
      XID xid;
      XkbDescRec* xkbdesc;
      XklEngine* xkl_engine;
      guint reserved_keysym;
      guchar reserved_keycode;
      guchar modifiers;
      guchar group;
      GHashTable* button_funcs;
      GHashTable* key_funcs;
};

typedef void (*CaribouXAdapterKeyButtonCallback) (guint keybuttoncode, gboolean pressed, void* user_data);
00072 struct _CaribouXAdapterKeyButtonHandler {
      GTypeInstance parent_instance;
      volatile int ref_count;
      CaribouXAdapterKeyButtonHandlerPrivate * priv;
};

00078 struct _CaribouXAdapterKeyButtonHandlerClass {
      GTypeClass parent_class;
      void (*finalize) (CaribouXAdapterKeyButtonHandler *self);
};

00083 struct _CaribouXAdapterKeyButtonHandlerPrivate {
      CaribouXAdapterKeyButtonCallback _cb;
      gpointer _cb_target;
      GDestroyNotify _cb_target_destroy_notify;
};

00089 struct _CaribouXAdapterParamSpecKeyButtonHandler {
      GParamSpec parent_instance;
};


static gpointer caribou_xadapter_parent_class = NULL;
static CaribouXAdapter* caribou_xadapter_instance;
static CaribouXAdapter* caribou_xadapter_instance = NULL;
static gpointer caribou_xadapter_key_button_handler_parent_class = NULL;

GType caribou_xadapter_get_type (void) G_GNUC_CONST;
static gpointer caribou_xadapter_key_button_handler_ref (gpointer instance);
static void caribou_xadapter_key_button_handler_unref (gpointer instance);
static GParamSpec* caribou_xadapter_param_spec_key_button_handler (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) G_GNUC_UNUSED;
static void caribou_xadapter_value_set_key_button_handler (GValue* value, gpointer v_object) G_GNUC_UNUSED;
static void caribou_xadapter_value_take_key_button_handler (GValue* value, gpointer v_object) G_GNUC_UNUSED;
static gpointer caribou_xadapter_value_get_key_button_handler (const GValue* value) G_GNUC_UNUSED;
static GType caribou_xadapter_key_button_handler_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
#define CARIBOU_XADAPTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CARIBOU_TYPE_XADAPTER, CaribouXAdapterPrivate))
enum  {
      CARIBOU_XADAPTER_DUMMY_PROPERTY
};
CaribouXAdapter* caribou_xadapter_get_default (void);
CaribouXAdapter* caribou_xadapter_new (void);
CaribouXAdapter* caribou_xadapter_construct (GType object_type);
static GdkFilterReturn caribou_xadapter_x_event_filter (CaribouXAdapter* self, GdkXEvent* xevent, GdkEvent* event);
static CaribouXAdapterKeyButtonCallback caribou_xadapter_key_button_handler_get_cb (CaribouXAdapterKeyButtonHandler* self, gpointer* result_target);
static void caribou_xadapter_xkl_state_changed (XklEngine* xklengine, gint type, gint group, gboolean restore, CaribouXAdapter* _self_);
guint caribou_xadapter_get_current_group (CaribouXAdapter* self, gchar** group_name, gchar** variant_name);
static guchar caribou_xadapter_get_reserved_keycode (CaribouXAdapter* self);
static void caribou_xadapter_replace_keycode (CaribouXAdapter* self, guint keysym);
static gboolean caribou_xadapter_reset_reserved (CaribouXAdapter* self);
static gboolean _caribou_xadapter_reset_reserved_gsource_func (gpointer self);
static gboolean caribou_xadapter_best_keycode_keyval_match (CaribouXAdapter* self, guint keyval, guchar* keycode, guint* modmask);
static GdkKeymapKey* _vala_array_dup1 (GdkKeymapKey* self, int length);
static guchar caribou_xadapter_keycode_for_keyval (CaribouXAdapter* self, guint keyval, guint* modmask);
void caribou_xadapter_keyval_press (CaribouXAdapter* self, guint keyval);
void caribou_xadapter_mod_latch (CaribouXAdapter* self, guint mask);
void caribou_xadapter_keyval_release (CaribouXAdapter* self, guint keyval);
void caribou_xadapter_mod_lock (CaribouXAdapter* self, guint mask);
void caribou_xadapter_mod_unlock (CaribouXAdapter* self, guint mask);
void caribou_xadapter_mod_unlatch (CaribouXAdapter* self, guint mask);
void caribou_xadapter_get_groups (CaribouXAdapter* self, gchar*** group_names, int* group_names_length1, gchar*** variant_names, int* variant_names_length1);
void caribou_xadapter_register_key_func (CaribouXAdapter* self, guint keyval, CaribouXAdapterKeyButtonCallback func, void* func_target);
static CaribouXAdapterKeyButtonHandler* caribou_xadapter_key_button_handler_new (CaribouXAdapterKeyButtonCallback cb, void* cb_target);
static CaribouXAdapterKeyButtonHandler* caribou_xadapter_key_button_handler_construct (GType object_type, CaribouXAdapterKeyButtonCallback cb, void* cb_target);
void caribou_xadapter_register_button_func (CaribouXAdapter* self, guint button, CaribouXAdapterKeyButtonCallback func, void* func_target);
static void g_cclosure_user_marshal_VOID__UINT_STRING_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
static GObject * caribou_xadapter_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void _caribou_xadapter_key_button_handler_unref0_ (gpointer var);
static GdkFilterReturn _caribou_xadapter_x_event_filter_gdk_filter_func (GdkXEvent* xevent, GdkEvent* event, gpointer self);
#define CARIBOU_XADAPTER_KEY_BUTTON_HANDLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER, CaribouXAdapterKeyButtonHandlerPrivate))
enum  {
      CARIBOU_XADAPTER_KEY_BUTTON_HANDLER_DUMMY_PROPERTY
};
static void caribou_xadapter_key_button_handler_set_cb (CaribouXAdapterKeyButtonHandler* self, CaribouXAdapterKeyButtonCallback value, gpointer value_target);
static void caribou_xadapter_key_button_handler_finalize (CaribouXAdapterKeyButtonHandler* obj);
static void caribou_xadapter_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


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


CaribouXAdapter* caribou_xadapter_get_default (void) {
      CaribouXAdapter* result = NULL;
      CaribouXAdapter* _tmp0_;
      CaribouXAdapter* _tmp2_;
      CaribouXAdapter* _tmp3_;
      _tmp0_ = caribou_xadapter_instance;
      if (_tmp0_ == NULL) {
            CaribouXAdapter* _tmp1_;
            _tmp1_ = caribou_xadapter_new ();
            _g_object_unref0 (caribou_xadapter_instance);
            caribou_xadapter_instance = _tmp1_;
      }
      _tmp2_ = caribou_xadapter_instance;
      _tmp3_ = _g_object_ref0 (_tmp2_);
      result = _tmp3_;
      return result;
}


static gpointer _caribou_xadapter_key_button_handler_ref0 (gpointer self) {
      return self ? caribou_xadapter_key_button_handler_ref (self) : NULL;
}


static GdkFilterReturn caribou_xadapter_x_event_filter (CaribouXAdapter* self, GdkXEvent* xevent, GdkEvent* event) {
      GdkFilterReturn result = 0;
      void* pointer;
      void* _tmp0_;
      XkbEvent* xkbev;
      void* _tmp1_;
      XEvent* xev;
      XklEngine* _tmp2_;
      XEvent* _tmp3_;
      gboolean _tmp4_ = FALSE;
      XEvent* _tmp5_;
      gint _tmp6_;
      gboolean _tmp9_;
      g_return_val_if_fail (self != NULL, 0);
      g_return_val_if_fail (xevent != NULL, 0);
      g_return_val_if_fail (event != NULL, 0);
      pointer = xevent;
      _tmp0_ = pointer;
      xkbev = (XkbEvent*) _tmp0_;
      _tmp1_ = pointer;
      xev = (XEvent*) _tmp1_;
      _tmp2_ = self->priv->xkl_engine;
      _tmp3_ = xev;
      xkl_engine_filter_events (_tmp2_, _tmp3_);
      _tmp5_ = xev;
      _tmp6_ = (*_tmp5_).type;
      if (_tmp6_ == ((gint) ButtonPress)) {
            _tmp4_ = TRUE;
      } else {
            XEvent* _tmp7_;
            gint _tmp8_;
            _tmp7_ = xev;
            _tmp8_ = (*_tmp7_).type;
            _tmp4_ = _tmp8_ == ((gint) ButtonRelease);
      }
      _tmp9_ = _tmp4_;
      if (_tmp9_) {
            GHashTable* _tmp10_;
            XEvent* _tmp11_;
            XButtonEvent _tmp12_;
            guint _tmp13_;
            gconstpointer _tmp14_ = NULL;
            CaribouXAdapterKeyButtonHandler* _tmp15_;
            CaribouXAdapterKeyButtonHandler* handler;
            CaribouXAdapterKeyButtonHandler* _tmp16_;
            _tmp10_ = self->priv->button_funcs;
            _tmp11_ = xev;
            _tmp12_ = (*_tmp11_).xbutton;
            _tmp13_ = _tmp12_.button;
            _tmp14_ = g_hash_table_lookup (_tmp10_, GUINT_TO_POINTER (_tmp13_));
            _tmp15_ = _caribou_xadapter_key_button_handler_ref0 (CARIBOU_XADAPTER_KEY_BUTTON_HANDLER ((CaribouXAdapterKeyButtonHandler*) _tmp14_));
            handler = _tmp15_;
            _tmp16_ = handler;
            if (_tmp16_ != NULL) {
                  CaribouXAdapterKeyButtonHandler* _tmp17_;
                  CaribouXAdapterKeyButtonCallback _tmp18_;
                  void* _tmp18__target;
                  CaribouXAdapterKeyButtonCallback _tmp19_;
                  void* _tmp19__target;
                  XEvent* _tmp20_;
                  XButtonEvent _tmp21_;
                  guint _tmp22_;
                  XEvent* _tmp23_;
                  gint _tmp24_;
                  _tmp17_ = handler;
                  _tmp18_ = caribou_xadapter_key_button_handler_get_cb (_tmp17_, &_tmp18__target);
                  _tmp19_ = _tmp18_;
                  _tmp19__target = _tmp18__target;
                  _tmp20_ = xev;
                  _tmp21_ = (*_tmp20_).xbutton;
                  _tmp22_ = _tmp21_.button;
                  _tmp23_ = xev;
                  _tmp24_ = (*_tmp23_).type;
                  _tmp19_ (_tmp22_, _tmp24_ == ((gint) ButtonPress), _tmp19__target);
            }
            _caribou_xadapter_key_button_handler_unref0 (handler);
      } else {
            gboolean _tmp25_ = FALSE;
            XEvent* _tmp26_;
            gint _tmp27_;
            gboolean _tmp30_;
            _tmp26_ = xev;
            _tmp27_ = (*_tmp26_).type;
            if (_tmp27_ == ((gint) KeyPress)) {
                  _tmp25_ = TRUE;
            } else {
                  XEvent* _tmp28_;
                  gint _tmp29_;
                  _tmp28_ = xev;
                  _tmp29_ = (*_tmp28_).type;
                  _tmp25_ = _tmp29_ == ((gint) KeyRelease);
            }
            _tmp30_ = _tmp25_;
            if (_tmp30_) {
                  GHashTable* _tmp31_;
                  XEvent* _tmp32_;
                  XKeyEvent _tmp33_;
                  guint _tmp34_;
                  gconstpointer _tmp35_ = NULL;
                  CaribouXAdapterKeyButtonHandler* _tmp36_;
                  CaribouXAdapterKeyButtonHandler* handler;
                  CaribouXAdapterKeyButtonHandler* _tmp37_;
                  _tmp31_ = self->priv->key_funcs;
                  _tmp32_ = xev;
                  _tmp33_ = (*_tmp32_).xkey;
                  _tmp34_ = _tmp33_.keycode;
                  _tmp35_ = g_hash_table_lookup (_tmp31_, GUINT_TO_POINTER (_tmp34_));
                  _tmp36_ = _caribou_xadapter_key_button_handler_ref0 (CARIBOU_XADAPTER_KEY_BUTTON_HANDLER ((CaribouXAdapterKeyButtonHandler*) _tmp35_));
                  handler = _tmp36_;
                  _tmp37_ = handler;
                  if (_tmp37_ != NULL) {
                        CaribouXAdapterKeyButtonHandler* _tmp38_;
                        CaribouXAdapterKeyButtonCallback _tmp39_;
                        void* _tmp39__target;
                        CaribouXAdapterKeyButtonCallback _tmp40_;
                        void* _tmp40__target;
                        XEvent* _tmp41_;
                        XKeyEvent _tmp42_;
                        guint _tmp43_;
                        XEvent* _tmp44_;
                        gint _tmp45_;
                        _tmp38_ = handler;
                        _tmp39_ = caribou_xadapter_key_button_handler_get_cb (_tmp38_, &_tmp39__target);
                        _tmp40_ = _tmp39_;
                        _tmp40__target = _tmp39__target;
                        _tmp41_ = xev;
                        _tmp42_ = (*_tmp41_).xkey;
                        _tmp43_ = _tmp42_.keycode;
                        _tmp44_ = xev;
                        _tmp45_ = (*_tmp44_).type;
                        _tmp40_ (_tmp43_, _tmp45_ == ((gint) KeyPress), _tmp40__target);
                  }
                  _caribou_xadapter_key_button_handler_unref0 (handler);
            } else {
                  XkbEvent* _tmp46_;
                  XkbAnyEvent _tmp47_;
                  gint _tmp48_;
                  gint _tmp49_;
                  _tmp46_ = xkbev;
                  _tmp47_ = (*_tmp46_).any;
                  _tmp48_ = _tmp47_.xkb_type;
                  _tmp49_ = XkbStateNotify;
                  if (_tmp48_ == _tmp49_) {
                        XkbEvent* _tmp50_;
                        XkbStateNotifyEvent* sevent;
                        XkbStateNotifyEvent* _tmp51_;
                        guint _tmp52_;
                        gint _tmp53_;
                        _tmp50_ = xkbev;
                        sevent = &(*_tmp50_).state;
                        _tmp51_ = sevent;
                        _tmp52_ = (*_tmp51_).changed;
                        _tmp53_ = XkbModifierStateMask;
                        if ((_tmp52_ & _tmp53_) != ((guint) 0)) {
                              XkbStateNotifyEvent* _tmp54_;
                              guint _tmp55_;
                              _tmp54_ = sevent;
                              _tmp55_ = (*_tmp54_).mods;
                              self->priv->modifiers = (guchar) _tmp55_;
                        }
                  }
            }
      }
      result = GDK_FILTER_CONTINUE;
      return result;
}


static void caribou_xadapter_xkl_state_changed (XklEngine* xklengine, gint type, gint group, gboolean restore, CaribouXAdapter* _self_) {
      gchar* group_name = NULL;
      gchar* variant_name = NULL;
      CaribouXAdapter* _tmp0_;
      gint _tmp1_;
      CaribouXAdapter* _tmp2_;
      gchar* _tmp3_ = NULL;
      gchar* _tmp4_ = NULL;
      CaribouXAdapter* _tmp5_;
      CaribouXAdapter* _tmp6_;
      guchar _tmp7_;
      g_return_if_fail (xklengine != NULL);
      g_return_if_fail (_self_ != NULL);
      _tmp0_ = _self_;
      _tmp1_ = group;
      _tmp0_->priv->group = (guchar) _tmp1_;
      _tmp2_ = _self_;
      caribou_xadapter_get_current_group (_tmp2_, &_tmp3_, &_tmp4_);
      _g_free0 (group_name);
      group_name = _tmp3_;
      _g_free0 (variant_name);
      variant_name = _tmp4_;
      _tmp5_ = _self_;
      _tmp6_ = _self_;
      _tmp7_ = _tmp6_->priv->group;
      g_signal_emit_by_name (_tmp5_, "group-changed", (guint) _tmp7_, group_name, variant_name);
      _g_free0 (variant_name);
      _g_free0 (group_name);
}


static guchar caribou_xadapter_get_reserved_keycode (CaribouXAdapter* self) {
      guchar result = '\0';
      guchar i = '\0';
      XkbDescRec* _tmp0_;
      XkbDescRec* xkbdesc;
      Display* _tmp27_;
      guchar _tmp28_ = '\0';
      g_return_val_if_fail (self != NULL, '\0');
      _tmp0_ = self->priv->xkbdesc;
      xkbdesc = _tmp0_;
      {
            XkbDescRec* _tmp1_;
            gchar _tmp2_;
            gboolean _tmp3_;
            _tmp1_ = xkbdesc;
            _tmp2_ = _tmp1_->max_key_code;
            i = (guchar) _tmp2_;
            _tmp3_ = TRUE;
            while (TRUE) {
                  gboolean _tmp4_;
                  guchar _tmp6_;
                  XkbDescRec* _tmp7_;
                  gchar _tmp8_;
                  XkbDescRec* _tmp9_;
                  XkbClientMapRec* _tmp10_;
                  XkbSymMapRec* _tmp11_;
                  gint _tmp11__length1;
                  guchar _tmp12_;
                  XkbSymMapRec _tmp13_;
                  guchar _tmp14_;
                  gint _tmp15_;
                  _tmp4_ = _tmp3_;
                  if (!_tmp4_) {
                        guchar _tmp5_;
                        _tmp5_ = i;
                        i = (guchar) (_tmp5_ - 1);
                  }
                  _tmp3_ = FALSE;
                  _tmp6_ = i;
                  _tmp7_ = xkbdesc;
                  _tmp8_ = _tmp7_->min_key_code;
                  if (!(_tmp6_ >= ((guchar) _tmp8_))) {
                        break;
                  }
                  _tmp9_ = xkbdesc;
                  _tmp10_ = _tmp9_->map;
                  _tmp11_ = _tmp10_->key_sym_map;
                  _tmp11__length1 = _vala_array_length (_tmp10_->key_sym_map);
                  _tmp12_ = i;
                  _tmp13_ = _tmp11_[_tmp12_];
                  _tmp14_ = _tmp13_.kt_index[0];
                  _tmp15_ = XkbOneLevelIndex;
                  if (((gint) _tmp14_) == _tmp15_) {
                        Display* _tmp16_;
                        guchar _tmp17_;
                        gint _tmp18_ = 0;
                        _tmp16_ = self->priv->xdisplay;
                        _tmp17_ = i;
                        _tmp18_ = XKeycodeToKeysym (_tmp16_, _tmp17_, 0);
                        if (_tmp18_ != 0) {
                              Display* _tmp19_;
                              guchar _tmp20_;
                              Window _tmp21_ = 0;
                              Display* _tmp22_;
                              Display* _tmp23_;
                              guchar _tmp24_;
                              Window _tmp25_ = 0;
                              gint _tmp26_ = 0;
                              gdk_error_trap_push ();
                              _tmp19_ = self->priv->xdisplay;
                              _tmp20_ = i;
                              _tmp21_ = gdk_x11_get_default_root_xwindow ();
                              XGrabKey (_tmp19_, (gint) _tmp20_, (guint) 0, _tmp21_, TRUE, (gint) GrabModeSync, (gint) GrabModeSync);
                              _tmp22_ = self->priv->xdisplay;
                              XFlush (_tmp22_);
                              _tmp23_ = self->priv->xdisplay;
                              _tmp24_ = i;
                              _tmp25_ = gdk_x11_get_default_root_xwindow ();
                              XUngrabKey (_tmp23_, (gint) _tmp24_, (guint) 0, _tmp25_);
                              _tmp26_ = gdk_error_trap_pop ();
                              if (_tmp26_ == 0) {
                                    result = i;
                                    return result;
                              }
                        }
                  }
            }
      }
      _tmp27_ = self->priv->xdisplay;
      _tmp28_ = XKeysymToKeycode (_tmp27_, (gulong) 0x0023);
      result = (guchar) _tmp28_;
      return result;
}


static gboolean _caribou_xadapter_reset_reserved_gsource_func (gpointer self) {
      gboolean result;
      result = caribou_xadapter_reset_reserved (self);
      return result;
}


static void caribou_xadapter_replace_keycode (CaribouXAdapter* self, guint keysym) {
      guchar _tmp0_;
      Display* _tmp5_;
      XkbDescRec* _tmp6_;
      XkbClientMapRec* _tmp7_;
      XkbSymMapRec* _tmp8_;
      gint _tmp8__length1;
      guchar _tmp9_;
      XkbSymMapRec _tmp10_;
      gushort _tmp11_;
      guint offset;
      XkbDescRec* _tmp12_;
      XkbClientMapRec* _tmp13_;
      guint* _tmp14_;
      gint _tmp14__length1;
      guint _tmp15_;
      guint _tmp16_;
      guint _tmp17_;
      Display* _tmp18_;
      gint _tmp19_;
      XkbDescRec* _tmp20_;
      Display* _tmp21_;
      guint _tmp22_;
      guint _tmp23_;
      g_return_if_fail (self != NULL);
      _tmp0_ = self->priv->reserved_keycode;
      if (((gint) _tmp0_) == 0) {
            guchar _tmp1_ = '\0';
            Display* _tmp2_;
            guchar _tmp3_;
            gint _tmp4_ = 0;
            _tmp1_ = caribou_xadapter_get_reserved_keycode (self);
            self->priv->reserved_keycode = _tmp1_;
            _tmp2_ = self->priv->xdisplay;
            _tmp3_ = self->priv->reserved_keycode;
            _tmp4_ = XKeycodeToKeysym (_tmp2_, _tmp3_, 0);
            self->priv->reserved_keysym = (guint) _tmp4_;
      }
      _tmp5_ = self->priv->xdisplay;
      XFlush (_tmp5_);
      _tmp6_ = self->priv->xkbdesc;
      _tmp7_ = _tmp6_->map;
      _tmp8_ = _tmp7_->key_sym_map;
      _tmp8__length1 = _vala_array_length (_tmp7_->key_sym_map);
      _tmp9_ = self->priv->reserved_keycode;
      _tmp10_ = _tmp8_[_tmp9_];
      _tmp11_ = _tmp10_.offset;
      offset = (guint) _tmp11_;
      _tmp12_ = self->priv->xkbdesc;
      _tmp13_ = _tmp12_->map;
      _tmp14_ = _tmp13_->syms;
      _tmp14__length1 = _vala_array_length (_tmp13_->syms);
      _tmp15_ = offset;
      _tmp16_ = keysym;
      _tmp14_[_tmp15_] = _tmp16_;
      _tmp17_ = _tmp14_[_tmp15_];
      _tmp18_ = self->priv->xdisplay;
      _tmp19_ = XkbAllMapComponentsMask;
      _tmp20_ = self->priv->xkbdesc;
      XkbSetMap (_tmp18_, (guint) _tmp19_, _tmp20_);
      _tmp21_ = self->priv->xdisplay;
      XFlush (_tmp21_);
      _tmp22_ = keysym;
      _tmp23_ = self->priv->reserved_keysym;
      if (_tmp22_ != _tmp23_) {
            g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 500, _caribou_xadapter_reset_reserved_gsource_func, g_object_ref (self), g_object_unref);
      }
}


static gboolean caribou_xadapter_reset_reserved (CaribouXAdapter* self) {
      gboolean result = FALSE;
      guint _tmp0_;
      g_return_val_if_fail (self != NULL, FALSE);
      _tmp0_ = self->priv->reserved_keysym;
      caribou_xadapter_replace_keycode (self, _tmp0_);
      result = FALSE;
      return result;
}


static GdkKeymapKey* _vala_array_dup1 (GdkKeymapKey* self, int length) {
      return g_memdup (self, length * sizeof (GdkKeymapKey));
}


static gboolean caribou_xadapter_best_keycode_keyval_match (CaribouXAdapter* self, guint keyval, guchar* keycode, guint* modmask) {
      guchar _vala_keycode = '\0';
      guint _vala_modmask = 0U;
      gboolean result = FALSE;
      GdkKeymap* _tmp0_ = NULL;
      GdkKeymap* _tmp1_;
      GdkKeymap* kmap;
      GdkKeymapKey* kmk = NULL;
      gint kmk_length1 = 0;
      gint _kmk_size_ = 0;
      GdkKeymap* _tmp2_;
      guint _tmp3_;
      GdkKeymapKey* _tmp4_ = NULL;
      gint _tmp5_ = 0;
      gboolean _tmp6_ = FALSE;
      GdkKeymapKey* _tmp7_;
      gint _tmp7__length1;
      GdkKeymapKey* _tmp8_;
      gint _tmp8__length1;
      GdkKeymapKey _tmp9_;
      GdkKeymapKey best_match;
      GdkKeymapKey* _tmp10_;
      gint _tmp10__length1;
      GdkKeymapKey _tmp15_;
      guint _tmp16_;
      GdkModifierType _tmp17_ = 0;
      GdkKeymapKey _tmp18_;
      gint _tmp19_;
      GdkModifierType _tmp20_;
      g_return_val_if_fail (self != NULL, FALSE);
      _tmp0_ = gdk_keymap_get_default ();
      _tmp1_ = _g_object_ref0 (_tmp0_);
      kmap = _tmp1_;
      _tmp2_ = kmap;
      _tmp3_ = keyval;
      _tmp6_ = gdk_keymap_get_entries_for_keyval (_tmp2_, _tmp3_, &_tmp4_, &_tmp5_);
      kmk = (g_free (kmk), NULL);
      _tmp7_ = (_tmp4_ != NULL) ? _vala_array_dup1 (_tmp4_, _tmp5_) : ((gpointer) _tmp4_);
      _tmp7__length1 = _tmp5_;
      kmk = _tmp7_;
      kmk_length1 = _tmp7__length1;
      _kmk_size_ = kmk_length1;
      if (!_tmp6_) {
            result = FALSE;
            kmk = (g_free (kmk), NULL);
            _g_object_unref0 (kmap);
            if (keycode) {
                  *keycode = _vala_keycode;
            }
            if (modmask) {
                  *modmask = _vala_modmask;
            }
            return result;
      }
      _tmp8_ = kmk;
      _tmp8__length1 = kmk_length1;
      _tmp9_ = _tmp8_[0];
      best_match = _tmp9_;
      _tmp10_ = kmk;
      _tmp10__length1 = kmk_length1;
      {
            GdkKeymapKey* km_collection = NULL;
            gint km_collection_length1 = 0;
            gint _km_collection_size_ = 0;
            gint km_it = 0;
            km_collection = _tmp10_;
            km_collection_length1 = _tmp10__length1;
            for (km_it = 0; km_it < _tmp10__length1; km_it = km_it + 1) {
                  GdkKeymapKey km = {0};
                  km = km_collection[km_it];
                  {
                        GdkKeymapKey _tmp11_;
                        gint _tmp12_;
                        guchar _tmp13_;
                        _tmp11_ = km;
                        _tmp12_ = _tmp11_.group;
                        _tmp13_ = self->priv->group;
                        if (_tmp12_ == ((gint) _tmp13_)) {
                              GdkKeymapKey _tmp14_;
                              _tmp14_ = km;
                              best_match = _tmp14_;
                        }
                  }
            }
      }
      _tmp15_ = best_match;
      _tmp16_ = _tmp15_.keycode;
      _vala_keycode = (guchar) _tmp16_;
      _tmp18_ = best_match;
      _tmp19_ = _tmp18_.level;
      if (_tmp19_ == 1) {
            _tmp17_ = GDK_SHIFT_MASK;
      } else {
            _tmp17_ = 0;
      }
      _tmp20_ = _tmp17_;
      _vala_modmask = (guint) _tmp20_;
      result = TRUE;
      kmk = (g_free (kmk), NULL);
      _g_object_unref0 (kmap);
      if (keycode) {
            *keycode = _vala_keycode;
      }
      if (modmask) {
            *modmask = _vala_modmask;
      }
      return result;
}


static guchar caribou_xadapter_keycode_for_keyval (CaribouXAdapter* self, guint keyval, guint* modmask) {
      guint _vala_modmask = 0U;
      guchar result = '\0';
      guchar keycode;
      guint _tmp0_;
      guchar _tmp1_ = '\0';
      guint _tmp2_ = 0U;
      gboolean _tmp3_ = FALSE;
      g_return_val_if_fail (self != NULL, '\0');
      keycode = (guchar) 0;
      _tmp0_ = keyval;
      _tmp3_ = caribou_xadapter_best_keycode_keyval_match (self, _tmp0_, &_tmp1_, &_tmp2_);
      keycode = _tmp1_;
      _vala_modmask = _tmp2_;
      if (!_tmp3_) {
            guint _tmp4_;
            guchar _tmp5_;
            _tmp4_ = keyval;
            caribou_xadapter_replace_keycode (self, _tmp4_);
            _tmp5_ = self->priv->reserved_keycode;
            keycode = _tmp5_;
            _vala_modmask = (guint) 0;
      }
      result = keycode;
      if (modmask) {
            *modmask = _vala_modmask;
      }
      return result;
}


void caribou_xadapter_keyval_press (CaribouXAdapter* self, guint keyval) {
      guint mask = 0U;
      guint _tmp0_;
      guint _tmp1_ = 0U;
      guchar _tmp2_ = '\0';
      guchar keycode;
      guint _tmp3_;
      Display* _tmp5_;
      guchar _tmp6_;
      Display* _tmp7_;
      g_return_if_fail (self != NULL);
      _tmp0_ = keyval;
      _tmp2_ = caribou_xadapter_keycode_for_keyval (self, _tmp0_, &_tmp1_);
      mask = _tmp1_;
      keycode = _tmp2_;
      _tmp3_ = mask;
      if (_tmp3_ != ((guint) 0)) {
            guint _tmp4_;
            _tmp4_ = mask;
            caribou_xadapter_mod_latch (self, _tmp4_);
      }
      _tmp5_ = self->priv->xdisplay;
      _tmp6_ = keycode;
      XTestFakeKeyEvent (_tmp5_, _tmp6_, TRUE, CurrentTime);
      _tmp7_ = self->priv->xdisplay;
      XFlush (_tmp7_);
}


void caribou_xadapter_keyval_release (CaribouXAdapter* self, guint keyval) {
      guint _tmp0_;
      guchar _tmp1_ = '\0';
      guchar keycode;
      Display* _tmp2_;
      Display* _tmp3_;
      g_return_if_fail (self != NULL);
      _tmp0_ = keyval;
      _tmp1_ = caribou_xadapter_keycode_for_keyval (self, _tmp0_, NULL);
      keycode = _tmp1_;
      _tmp2_ = self->priv->xdisplay;
      XTestFakeKeyEvent (_tmp2_, keycode, FALSE, CurrentTime);
      _tmp3_ = self->priv->xdisplay;
      XFlush (_tmp3_);
}


void caribou_xadapter_mod_lock (CaribouXAdapter* self, guint mask) {
      Display* _tmp0_;
      gint _tmp1_;
      guint _tmp2_;
      guint _tmp3_;
      Display* _tmp4_;
      g_return_if_fail (self != NULL);
      _tmp0_ = self->priv->xdisplay;
      _tmp1_ = XkbUseCoreKbd;
      _tmp2_ = mask;
      _tmp3_ = mask;
      XkbLockModifiers (_tmp0_, (guint) _tmp1_, _tmp2_, _tmp3_);
      _tmp4_ = self->priv->xdisplay;
      XFlush (_tmp4_);
}


void caribou_xadapter_mod_unlock (CaribouXAdapter* self, guint mask) {
      Display* _tmp0_;
      gint _tmp1_;
      guint _tmp2_;
      Display* _tmp3_;
      g_return_if_fail (self != NULL);
      _tmp0_ = self->priv->xdisplay;
      _tmp1_ = XkbUseCoreKbd;
      _tmp2_ = mask;
      XkbLockModifiers (_tmp0_, (guint) _tmp1_, _tmp2_, (guint) 0);
      _tmp3_ = self->priv->xdisplay;
      XFlush (_tmp3_);
}


void caribou_xadapter_mod_latch (CaribouXAdapter* self, guint mask) {
      Display* _tmp0_;
      gint _tmp1_;
      guint _tmp2_;
      guint _tmp3_;
      Display* _tmp4_;
      g_return_if_fail (self != NULL);
      _tmp0_ = self->priv->xdisplay;
      _tmp1_ = XkbUseCoreKbd;
      _tmp2_ = mask;
      _tmp3_ = mask;
      XkbLatchModifiers (_tmp0_, (guint) _tmp1_, _tmp2_, _tmp3_);
      _tmp4_ = self->priv->xdisplay;
      XFlush (_tmp4_);
}


void caribou_xadapter_mod_unlatch (CaribouXAdapter* self, guint mask) {
      Display* _tmp0_;
      gint _tmp1_;
      guint _tmp2_;
      Display* _tmp3_;
      g_return_if_fail (self != NULL);
      _tmp0_ = self->priv->xdisplay;
      _tmp1_ = XkbUseCoreKbd;
      _tmp2_ = mask;
      XkbLatchModifiers (_tmp0_, (guint) _tmp1_, _tmp2_, (guint) 0);
      _tmp3_ = self->priv->xdisplay;
      XFlush (_tmp3_);
}


guint caribou_xadapter_get_current_group (CaribouXAdapter* self, gchar** group_name, gchar** variant_name) {
      gchar* _vala_group_name = NULL;
      gchar* _vala_variant_name = NULL;
      guint result = 0U;
      XklConfigRec* _tmp0_;
      XklConfigRec* config_rec;
      XklConfigRec* _tmp1_;
      XklEngine* _tmp2_;
      XklConfigRec* _tmp3_;
      gchar** _tmp4_;
      gint _tmp4__length1;
      guchar _tmp5_;
      const gchar* _tmp6_;
      gchar* _tmp7_;
      XklConfigRec* _tmp8_;
      gchar** _tmp9_;
      gint _tmp9__length1;
      guchar _tmp10_;
      const gchar* _tmp11_;
      gchar* _tmp12_;
      const gchar* _tmp13_;
      guchar _tmp15_;
      g_return_val_if_fail (self != NULL, 0U);
      _tmp0_ = xkl_config_rec_new ();
      config_rec = _tmp0_;
      _tmp1_ = config_rec;
      _tmp2_ = self->priv->xkl_engine;
      xkl_config_rec_get_from_server (_tmp1_, _tmp2_);
      _tmp3_ = config_rec;
      _tmp4_ = _tmp3_->layouts;
      _tmp4__length1 = _vala_array_length (_tmp3_->layouts);
      _tmp5_ = self->priv->group;
      _tmp6_ = _tmp4_[_tmp5_];
      _tmp7_ = g_strdup (_tmp6_);
      _g_free0 (_vala_group_name);
      _vala_group_name = _tmp7_;
      _tmp8_ = config_rec;
      _tmp9_ = _tmp8_->variants;
      _tmp9__length1 = _vala_array_length (_tmp8_->variants);
      _tmp10_ = self->priv->group;
      _tmp11_ = _tmp9_[_tmp10_];
      _tmp12_ = g_strdup (_tmp11_);
      _g_free0 (_vala_variant_name);
      _vala_variant_name = _tmp12_;
      _tmp13_ = _vala_variant_name;
      if (_tmp13_ == NULL) {
            gchar* _tmp14_;
            _tmp14_ = g_strdup ("");
            _g_free0 (_vala_variant_name);
            _vala_variant_name = _tmp14_;
      }
      _tmp15_ = self->priv->group;
      result = (guint) _tmp15_;
      _g_object_unref0 (config_rec);
      if (group_name) {
            *group_name = _vala_group_name;
      } else {
            _g_free0 (_vala_group_name);
      }
      if (variant_name) {
            *variant_name = _vala_variant_name;
      } else {
            _g_free0 (_vala_variant_name);
      }
      return result;
}


void caribou_xadapter_get_groups (CaribouXAdapter* self, gchar*** group_names, int* group_names_length1, gchar*** variant_names, int* variant_names_length1) {
      gchar** _vala_group_names = NULL;
      int _vala_group_names_length1 = 0;
      gchar** _vala_variant_names = NULL;
      int _vala_variant_names_length1 = 0;
      gint i = 0;
      XklConfigRec* _tmp0_;
      XklConfigRec* config_rec;
      XklConfigRec* _tmp1_;
      XklEngine* _tmp2_;
      gint _tmp12_;
      gchar** _tmp13_ = NULL;
      gint _tmp14_;
      gchar** _tmp15_ = NULL;
      g_return_if_fail (self != NULL);
      _tmp0_ = xkl_config_rec_new ();
      config_rec = _tmp0_;
      _tmp1_ = config_rec;
      _tmp2_ = self->priv->xkl_engine;
      xkl_config_rec_get_from_server (_tmp1_, _tmp2_);
      {
            gboolean _tmp3_;
            i = 0;
            _tmp3_ = TRUE;
            while (TRUE) {
                  gboolean _tmp4_;
                  gint _tmp6_;
                  XklConfigRec* _tmp7_;
                  gchar** _tmp8_;
                  gint _tmp8__length1;
                  gint _tmp9_;
                  const gchar* _tmp10_;
                  _tmp4_ = _tmp3_;
                  if (!_tmp4_) {
                        gint _tmp5_;
                        _tmp5_ = i;
                        i = _tmp5_ + 1;
                  }
                  _tmp3_ = FALSE;
                  _tmp6_ = i;
                  if (!(_tmp6_ < 4)) {
                        break;
                  }
                  _tmp7_ = config_rec;
                  _tmp8_ = _tmp7_->layouts;
                  _tmp8__length1 = _vala_array_length (_tmp7_->layouts);
                  _tmp9_ = i;
                  _tmp10_ = _tmp8_[_tmp9_];
                  if (_tmp10_ == NULL) {
                        gint _tmp11_;
                        _tmp11_ = i;
                        i = _tmp11_ - 1;
                        break;
                  }
            }
      }
      _tmp12_ = i;
      _tmp13_ = g_new0 (gchar*, (_tmp12_ + 1) + 1);
      _vala_group_names = (_vala_array_free (_vala_group_names, _vala_group_names_length1, (GDestroyNotify) g_free), NULL);
      _vala_group_names = _tmp13_;
      _vala_group_names_length1 = _tmp12_ + 1;
      _tmp14_ = i;
      _tmp15_ = g_new0 (gchar*, (_tmp14_ + 1) + 1);
      _vala_variant_names = (_vala_array_free (_vala_variant_names, _vala_variant_names_length1, (GDestroyNotify) g_free), NULL);
      _vala_variant_names = _tmp15_;
      _vala_variant_names_length1 = _tmp14_ + 1;
      {
            gboolean _tmp16_;
            _tmp16_ = TRUE;
            while (TRUE) {
                  gboolean _tmp17_;
                  gint _tmp19_;
                  gchar** _tmp20_;
                  gint _tmp20__length1;
                  gint _tmp21_;
                  XklConfigRec* _tmp22_;
                  gchar** _tmp23_;
                  gint _tmp23__length1;
                  gint _tmp24_;
                  const gchar* _tmp25_;
                  gchar* _tmp26_;
                  gchar* _tmp27_;
                  XklConfigRec* _tmp28_;
                  gchar** _tmp29_;
                  gint _tmp29__length1;
                  gint _tmp30_;
                  const gchar* _tmp31_;
                  _tmp17_ = _tmp16_;
                  if (!_tmp17_) {
                        gint _tmp18_;
                        _tmp18_ = i;
                        i = _tmp18_ - 1;
                  }
                  _tmp16_ = FALSE;
                  _tmp19_ = i;
                  if (!(_tmp19_ >= 0)) {
                        break;
                  }
                  _tmp20_ = _vala_group_names;
                  _tmp20__length1 = _vala_group_names_length1;
                  _tmp21_ = i;
                  _tmp22_ = config_rec;
                  _tmp23_ = _tmp22_->layouts;
                  _tmp23__length1 = _vala_array_length (_tmp22_->layouts);
                  _tmp24_ = i;
                  _tmp25_ = _tmp23_[_tmp24_];
                  _tmp26_ = g_strdup (_tmp25_);
                  _g_free0 (_tmp20_[_tmp21_]);
                  _tmp20_[_tmp21_] = _tmp26_;
                  _tmp27_ = _tmp20_[_tmp21_];
                  _tmp28_ = config_rec;
                  _tmp29_ = _tmp28_->variants;
                  _tmp29__length1 = _vala_array_length (_tmp28_->variants);
                  _tmp30_ = i;
                  _tmp31_ = _tmp29_[_tmp30_];
                  if (_tmp31_ != NULL) {
                        gchar** _tmp32_;
                        gint _tmp32__length1;
                        gint _tmp33_;
                        XklConfigRec* _tmp34_;
                        gchar** _tmp35_;
                        gint _tmp35__length1;
                        gint _tmp36_;
                        const gchar* _tmp37_;
                        gchar* _tmp38_;
                        gchar* _tmp39_;
                        _tmp32_ = _vala_variant_names;
                        _tmp32__length1 = _vala_variant_names_length1;
                        _tmp33_ = i;
                        _tmp34_ = config_rec;
                        _tmp35_ = _tmp34_->variants;
                        _tmp35__length1 = _vala_array_length (_tmp34_->variants);
                        _tmp36_ = i;
                        _tmp37_ = _tmp35_[_tmp36_];
                        _tmp38_ = g_strdup (_tmp37_);
                        _g_free0 (_tmp32_[_tmp33_]);
                        _tmp32_[_tmp33_] = _tmp38_;
                        _tmp39_ = _tmp32_[_tmp33_];
                  } else {
                        gchar** _tmp40_;
                        gint _tmp40__length1;
                        gint _tmp41_;
                        gchar* _tmp42_;
                        gchar* _tmp43_;
                        _tmp40_ = _vala_variant_names;
                        _tmp40__length1 = _vala_variant_names_length1;
                        _tmp41_ = i;
                        _tmp42_ = g_strdup ("");
                        _g_free0 (_tmp40_[_tmp41_]);
                        _tmp40_[_tmp41_] = _tmp42_;
                        _tmp43_ = _tmp40_[_tmp41_];
                  }
            }
      }
      _g_object_unref0 (config_rec);
      if (group_names) {
            *group_names = _vala_group_names;
      } else {
            _vala_group_names = (_vala_array_free (_vala_group_names, _vala_group_names_length1, (GDestroyNotify) g_free), NULL);
      }
      if (group_names_length1) {
            *group_names_length1 = _vala_group_names_length1;
      }
      if (variant_names) {
            *variant_names = _vala_variant_names;
      } else {
            _vala_variant_names = (_vala_array_free (_vala_variant_names, _vala_variant_names_length1, (GDestroyNotify) g_free), NULL);
      }
      if (variant_names_length1) {
            *variant_names_length1 = _vala_variant_names_length1;
      }
}


void caribou_xadapter_register_key_func (CaribouXAdapter* self, guint keyval, CaribouXAdapterKeyButtonCallback func, void* func_target) {
      guchar keycode = '\0';
      guint modmask = 0U;
      guint _tmp0_;
      guchar _tmp1_ = '\0';
      guint _tmp2_ = 0U;
      gboolean _tmp3_ = FALSE;
      CaribouXAdapterKeyButtonCallback _tmp5_;
      void* _tmp5__target;
      g_return_if_fail (self != NULL);
      _tmp0_ = keyval;
      _tmp3_ = caribou_xadapter_best_keycode_keyval_match (self, _tmp0_, &_tmp1_, &_tmp2_);
      keycode = _tmp1_;
      modmask = _tmp2_;
      if (!_tmp3_) {
            guint _tmp4_;
            _tmp4_ = keyval;
            g_warning ("xadapter.vala:290: No good keycode for %d", (gint) _tmp4_);
            return;
      }
      _tmp5_ = func;
      _tmp5__target = func_target;
      if (_tmp5_ != NULL) {
            CaribouXAdapterKeyButtonCallback _tmp6_;
            void* _tmp6__target;
            CaribouXAdapterKeyButtonHandler* _tmp7_;
            CaribouXAdapterKeyButtonHandler* handler;
            GHashTable* _tmp8_;
            guchar _tmp9_;
            CaribouXAdapterKeyButtonHandler* _tmp10_;
            CaribouXAdapterKeyButtonHandler* _tmp11_;
            Display* _tmp12_;
            guchar _tmp13_;
            XID _tmp14_;
            _tmp6_ = func;
            _tmp6__target = func_target;
            _tmp7_ = caribou_xadapter_key_button_handler_new (_tmp6_, _tmp6__target);
            handler = _tmp7_;
            _tmp8_ = self->priv->key_funcs;
            _tmp9_ = keycode;
            _tmp10_ = handler;
            _tmp11_ = _caribou_xadapter_key_button_handler_ref0 (_tmp10_);
            g_hash_table_insert (_tmp8_, GUINT_TO_POINTER ((guint) _tmp9_), _tmp11_);
            _tmp12_ = self->priv->xdisplay;
            _tmp13_ = keycode;
            _tmp14_ = self->priv->xid;
            XGrabKey (_tmp12_, (gint) _tmp13_, (guint) 0, (Window) _tmp14_, TRUE, (gint) GrabModeAsync, (gint) GrabModeAsync);
            _caribou_xadapter_key_button_handler_unref0 (handler);
      } else {
            GHashTable* _tmp15_;
            guchar _tmp16_;
            Display* _tmp17_;
            guchar _tmp18_;
            XID _tmp19_;
            _tmp15_ = self->priv->key_funcs;
            _tmp16_ = keycode;
            g_hash_table_remove (_tmp15_, GUINT_TO_POINTER ((guint) _tmp16_));
            _tmp17_ = self->priv->xdisplay;
            _tmp18_ = keycode;
            _tmp19_ = self->priv->xid;
            XUngrabKey (_tmp17_, (gint) _tmp18_, (guint) 0, (Window) _tmp19_);
      }
}


void caribou_xadapter_register_button_func (CaribouXAdapter* self, guint button, CaribouXAdapterKeyButtonCallback func, void* func_target) {
      CaribouXAdapterKeyButtonCallback _tmp0_;
      void* _tmp0__target;
      g_return_if_fail (self != NULL);
      _tmp0_ = func;
      _tmp0__target = func_target;
      if (_tmp0_ != NULL) {
            CaribouXAdapterKeyButtonCallback _tmp1_;
            void* _tmp1__target;
            CaribouXAdapterKeyButtonHandler* _tmp2_;
            CaribouXAdapterKeyButtonHandler* handler;
            GHashTable* _tmp3_;
            guint _tmp4_;
            CaribouXAdapterKeyButtonHandler* _tmp5_;
            CaribouXAdapterKeyButtonHandler* _tmp6_;
            Display* _tmp7_;
            guint _tmp8_;
            XID _tmp9_;
            _tmp1_ = func;
            _tmp1__target = func_target;
            _tmp2_ = caribou_xadapter_key_button_handler_new (_tmp1_, _tmp1__target);
            handler = _tmp2_;
            _tmp3_ = self->priv->button_funcs;
            _tmp4_ = button;
            _tmp5_ = handler;
            _tmp6_ = _caribou_xadapter_key_button_handler_ref0 (_tmp5_);
            g_hash_table_insert (_tmp3_, GUINT_TO_POINTER (_tmp4_), _tmp6_);
            _tmp7_ = self->priv->xdisplay;
            _tmp8_ = button;
            _tmp9_ = self->priv->xid;
            XGrabButton (_tmp7_, _tmp8_, (guint) 0, (Window) _tmp9_, TRUE, (guint) (ButtonPressMask | ButtonReleaseMask), (gint) GrabModeAsync, (gint) GrabModeAsync, (Window) 0, (guint) 0);
            _caribou_xadapter_key_button_handler_unref0 (handler);
      } else {
            GHashTable* _tmp10_;
            guint _tmp11_;
            Display* _tmp12_;
            guint _tmp13_;
            XID _tmp14_;
            _tmp10_ = self->priv->button_funcs;
            _tmp11_ = button;
            g_hash_table_remove (_tmp10_, GUINT_TO_POINTER (_tmp11_));
            _tmp12_ = self->priv->xdisplay;
            _tmp13_ = button;
            _tmp14_ = self->priv->xid;
            XUngrabButton (_tmp12_, _tmp13_, (guint) 0, (Window) _tmp14_);
      }
}


CaribouXAdapter* caribou_xadapter_construct (GType object_type) {
      CaribouXAdapter * self = NULL;
      self = (CaribouXAdapter*) g_object_new (object_type, NULL);
      return self;
}


CaribouXAdapter* caribou_xadapter_new (void) {
      return caribou_xadapter_construct (CARIBOU_TYPE_XADAPTER);
}


static void g_cclosure_user_marshal_VOID__UINT_STRING_STRING (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
      typedef void (*GMarshalFunc_VOID__UINT_STRING_STRING) (gpointer data1, guint arg_1, const char* arg_2, const char* arg_3, gpointer data2);
      register GMarshalFunc_VOID__UINT_STRING_STRING 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_STRING_STRING) (marshal_data ? marshal_data : cc->callback);
      callback (data1, g_value_get_uint (param_values + 1), g_value_get_string (param_values + 2), g_value_get_string (param_values + 3), data2);
}


static void _caribou_xadapter_key_button_handler_unref0_ (gpointer var) {
      (var == NULL) ? NULL : (var = (caribou_xadapter_key_button_handler_unref (var), NULL));
}


static GdkFilterReturn _caribou_xadapter_x_event_filter_gdk_filter_func (GdkXEvent* xevent, GdkEvent* event, gpointer self) {
      GdkFilterReturn result;
      result = caribou_xadapter_x_event_filter (self, xevent, event);
      return result;
}


static GObject * caribou_xadapter_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
      GObject * obj;
      GObjectClass * parent_class;
      CaribouXAdapter * self;
      XkbStateRec xkb_state = {0};
      XklState* xkl_state = NULL;
      GdkWindow* _tmp0_ = NULL;
      GdkWindow* _tmp1_;
      GdkWindow* rootwin;
      GdkWindow* _tmp2_;
      GdkDisplay* _tmp3_ = NULL;
      Display* _tmp4_ = NULL;
      GdkWindow* _tmp5_;
      Window _tmp6_ = 0;
      Display* _tmp7_;
      gint _tmp8_;
      gint _tmp9_;
      XkbDescRec* _tmp10_ = NULL;
      Display* _tmp11_;
      XklEngine* _tmp12_ = NULL;
      XklEngine* _tmp13_;
      XklEngine* _tmp14_;
      XklEngine* _tmp15_;
      XklState* _tmp16_ = NULL;
      XklState* _tmp17_;
      gint32 _tmp18_;
      XklEngine* _tmp19_;
      Display* _tmp20_;
      gint _tmp21_;
      XkbStateRec _tmp22_ = {0};
      XkbStateRec _tmp23_;
      guchar _tmp24_;
      GHashFunc _tmp25_;
      GEqualFunc _tmp26_;
      GHashTable* _tmp27_;
      GHashFunc _tmp28_;
      GEqualFunc _tmp29_;
      GHashTable* _tmp30_;
      Display* _tmp31_;
      gint _tmp32_;
      gint _tmp33_;
      gint _tmp34_;
      gint _tmp35_;
      gint _tmp36_;
      parent_class = G_OBJECT_CLASS (caribou_xadapter_parent_class);
      obj = parent_class->constructor (type, n_construct_properties, construct_properties);
      self = CARIBOU_XADAPTER (obj);
      _tmp0_ = gdk_get_default_root_window ();
      _tmp1_ = _g_object_ref0 (_tmp0_);
      rootwin = _tmp1_;
      _tmp2_ = rootwin;
      _tmp3_ = gdk_window_get_display (_tmp2_);
      _tmp4_ = gdk_x11_display_get_xdisplay (_tmp3_);
      self->priv->xdisplay = _tmp4_;
      _tmp5_ = rootwin;
      _tmp6_ = gdk_x11_window_get_xid (_tmp5_);
      self->priv->xid = (XID) _tmp6_;
      _tmp7_ = self->priv->xdisplay;
      _tmp8_ = XkbGBN_AllComponentsMask;
      _tmp9_ = XkbUseCoreKbd;
      _tmp10_ = XkbGetKeyboard (_tmp7_, (guint) _tmp8_, (guint) _tmp9_);
      _0 (self->priv->xkbdesc);
      self->priv->xkbdesc = _tmp10_;
      _tmp11_ = self->priv->xdisplay;
      _tmp12_ = xkl_engine_get_instance (_tmp11_);
      _tmp13_ = _g_object_ref0 (_tmp12_);
      _g_object_unref0 (self->priv->xkl_engine);
      self->priv->xkl_engine = _tmp13_;
      _tmp14_ = self->priv->xkl_engine;
      xkl_engine_start_listen (_tmp14_, (guint) XKLL_TRACK_KEYBOARD_STATE);
      _tmp15_ = self->priv->xkl_engine;
      _tmp16_ = xkl_engine_get_current_state (_tmp15_);
      xkl_state = _tmp16_;
      _tmp17_ = xkl_state;
      _tmp18_ = _tmp17_->group;
      self->priv->group = (guchar) _tmp18_;
      _tmp19_ = self->priv->xkl_engine;
      g_signal_connect_object (_tmp19_, "X-state-changed", (GCallback) caribou_xadapter_xkl_state_changed, (GObject*) self, G_CONNECT_AFTER);
      _tmp20_ = self->priv->xdisplay;
      _tmp21_ = XkbUseCoreKbd;
      XkbGetState (_tmp20_, (guint) _tmp21_, &_tmp22_);
      xkb_state = _tmp22_;
      _tmp23_ = xkb_state;
      _tmp24_ = _tmp23_.mods;
      self->priv->modifiers = _tmp24_;
      self->priv->reserved_keycode = (guchar) 0;
      _tmp25_ = g_direct_hash;
      _tmp26_ = g_direct_equal;
      _tmp27_ = g_hash_table_new_full (_tmp25_, _tmp26_, NULL, _caribou_xadapter_key_button_handler_unref0_);
      _g_hash_table_unref0 (self->priv->button_funcs);
      self->priv->button_funcs = _tmp27_;
      _tmp28_ = g_direct_hash;
      _tmp29_ = g_direct_equal;
      _tmp30_ = g_hash_table_new_full (_tmp28_, _tmp29_, NULL, _caribou_xadapter_key_button_handler_unref0_);
      _g_hash_table_unref0 (self->priv->key_funcs);
      self->priv->key_funcs = _tmp30_;
      _tmp31_ = self->priv->xdisplay;
      _tmp32_ = XkbUseCoreKbd;
      _tmp33_ = XkbStateNotifyMask;
      _tmp34_ = XkbAccessXNotifyMask;
      _tmp35_ = XkbStateNotifyMask;
      _tmp36_ = XkbAccessXNotifyMask;
      XkbSelectEvents (_tmp31_, (guint) _tmp32_, (gulong) (_tmp33_ | _tmp34_), (gulong) (_tmp35_ | _tmp36_));
      gdk_window_add_filter (GDK_WINDOW (NULL), _caribou_xadapter_x_event_filter_gdk_filter_func, self);
      _g_object_unref0 (rootwin);
      return obj;
}


static CaribouXAdapterKeyButtonHandler* caribou_xadapter_key_button_handler_construct (GType object_type, CaribouXAdapterKeyButtonCallback cb, void* cb_target) {
      CaribouXAdapterKeyButtonHandler* self = NULL;
      CaribouXAdapterKeyButtonCallback _tmp0_;
      void* _tmp0__target;
      self = (CaribouXAdapterKeyButtonHandler*) g_type_create_instance (object_type);
      _tmp0_ = cb;
      _tmp0__target = cb_target;
      caribou_xadapter_key_button_handler_set_cb (self, _tmp0_, _tmp0__target);
      return self;
}


static CaribouXAdapterKeyButtonHandler* caribou_xadapter_key_button_handler_new (CaribouXAdapterKeyButtonCallback cb, void* cb_target) {
      return caribou_xadapter_key_button_handler_construct (CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER, cb, cb_target);
}


static CaribouXAdapterKeyButtonCallback caribou_xadapter_key_button_handler_get_cb (CaribouXAdapterKeyButtonHandler* self, gpointer* result_target) {
      CaribouXAdapterKeyButtonCallback result;
      CaribouXAdapterKeyButtonCallback _tmp0_;
      void* _tmp0__target;
      CaribouXAdapterKeyButtonCallback _tmp1_;
      void* _tmp1__target;
      g_return_val_if_fail (self != NULL, NULL);
      _tmp0_ = self->priv->_cb;
      _tmp0__target = self->priv->_cb_target;
      _tmp1_ = _tmp0_;
      _tmp1__target = _tmp0__target;
      *result_target = _tmp1__target;
      result = _tmp1_;
      return result;
}


static void caribou_xadapter_key_button_handler_set_cb (CaribouXAdapterKeyButtonHandler* self, CaribouXAdapterKeyButtonCallback value, gpointer value_target) {
      CaribouXAdapterKeyButtonCallback _tmp0_;
      void* _tmp0__target;
      g_return_if_fail (self != NULL);
      _tmp0_ = value;
      _tmp0__target = value_target;
      (self->priv->_cb_target_destroy_notify == NULL) ? NULL : (self->priv->_cb_target_destroy_notify (self->priv->_cb_target), NULL);
      self->priv->_cb = NULL;
      self->priv->_cb_target = NULL;
      self->priv->_cb_target_destroy_notify = NULL;
      self->priv->_cb = _tmp0_;
      self->priv->_cb_target = _tmp0__target;
      self->priv->_cb_target_destroy_notify = NULL;
}


static void caribou_xadapter_value_key_button_handler_init (GValue* value) {
      value->data[0].v_pointer = NULL;
}


static void caribou_xadapter_value_key_button_handler_free_value (GValue* value) {
      if (value->data[0].v_pointer) {
            caribou_xadapter_key_button_handler_unref (value->data[0].v_pointer);
      }
}


static void caribou_xadapter_value_key_button_handler_copy_value (const GValue* src_value, GValue* dest_value) {
      if (src_value->data[0].v_pointer) {
            dest_value->data[0].v_pointer = caribou_xadapter_key_button_handler_ref (src_value->data[0].v_pointer);
      } else {
            dest_value->data[0].v_pointer = NULL;
      }
}


static gpointer caribou_xadapter_value_key_button_handler_peek_pointer (const GValue* value) {
      return value->data[0].v_pointer;
}


static gchar* caribou_xadapter_value_key_button_handler_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
      if (collect_values[0].v_pointer) {
            CaribouXAdapterKeyButtonHandler* object;
            object = collect_values[0].v_pointer;
            if (object->parent_instance.g_class == NULL) {
                  return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
            } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
                  return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
            }
            value->data[0].v_pointer = caribou_xadapter_key_button_handler_ref (object);
      } else {
            value->data[0].v_pointer = NULL;
      }
      return NULL;
}


static gchar* caribou_xadapter_value_key_button_handler_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
      CaribouXAdapterKeyButtonHandler** object_p;
      object_p = collect_values[0].v_pointer;
      if (!object_p) {
            return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
      }
      if (!value->data[0].v_pointer) {
            *object_p = NULL;
      } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
            *object_p = value->data[0].v_pointer;
      } else {
            *object_p = caribou_xadapter_key_button_handler_ref (value->data[0].v_pointer);
      }
      return NULL;
}


static GParamSpec* caribou_xadapter_param_spec_key_button_handler (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
      CaribouXAdapterParamSpecKeyButtonHandler* spec;
      g_return_val_if_fail (g_type_is_a (object_type, CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER), NULL);
      spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
      G_PARAM_SPEC (spec)->value_type = object_type;
      return G_PARAM_SPEC (spec);
}


static gpointer caribou_xadapter_value_get_key_button_handler (const GValue* value) {
      g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER), NULL);
      return value->data[0].v_pointer;
}


static void caribou_xadapter_value_set_key_button_handler (GValue* value, gpointer v_object) {
      CaribouXAdapterKeyButtonHandler* old;
      g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER));
      old = value->data[0].v_pointer;
      if (v_object) {
            g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER));
            g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
            value->data[0].v_pointer = v_object;
            caribou_xadapter_key_button_handler_ref (value->data[0].v_pointer);
      } else {
            value->data[0].v_pointer = NULL;
      }
      if (old) {
            caribou_xadapter_key_button_handler_unref (old);
      }
}


static void caribou_xadapter_value_take_key_button_handler (GValue* value, gpointer v_object) {
      CaribouXAdapterKeyButtonHandler* old;
      g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER));
      old = value->data[0].v_pointer;
      if (v_object) {
            g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, CARIBOU_XADAPTER_TYPE_KEY_BUTTON_HANDLER));
            g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
            value->data[0].v_pointer = v_object;
      } else {
            value->data[0].v_pointer = NULL;
      }
      if (old) {
            caribou_xadapter_key_button_handler_unref (old);
      }
}


static void caribou_xadapter_key_button_handler_class_init (CaribouXAdapterKeyButtonHandlerClass * klass) {
      caribou_xadapter_key_button_handler_parent_class = g_type_class_peek_parent (klass);
      CARIBOU_XADAPTER_KEY_BUTTON_HANDLER_CLASS (klass)->finalize = caribou_xadapter_key_button_handler_finalize;
      g_type_class_add_private (klass, sizeof (CaribouXAdapterKeyButtonHandlerPrivate));
}


static void caribou_xadapter_key_button_handler_instance_init (CaribouXAdapterKeyButtonHandler * self) {
      self->priv = CARIBOU_XADAPTER_KEY_BUTTON_HANDLER_GET_PRIVATE (self);
      self->ref_count = 1;
}


static void caribou_xadapter_key_button_handler_finalize (CaribouXAdapterKeyButtonHandler* obj) {
      CaribouXAdapterKeyButtonHandler * self;
      self = CARIBOU_XADAPTER_KEY_BUTTON_HANDLER (obj);
      (self->priv->_cb_target_destroy_notify == NULL) ? NULL : (self->priv->_cb_target_destroy_notify (self->priv->_cb_target), NULL);
      self->priv->_cb = NULL;
      self->priv->_cb_target = NULL;
      self->priv->_cb_target_destroy_notify = NULL;
}


static GType caribou_xadapter_key_button_handler_get_type (void) {
      static volatile gsize caribou_xadapter_key_button_handler_type_id__volatile = 0;
      if (g_once_init_enter (&caribou_xadapter_key_button_handler_type_id__volatile)) {
            static const GTypeValueTable g_define_type_value_table = { caribou_xadapter_value_key_button_handler_init, caribou_xadapter_value_key_button_handler_free_value, caribou_xadapter_value_key_button_handler_copy_value, caribou_xadapter_value_key_button_handler_peek_pointer, "p", caribou_xadapter_value_key_button_handler_collect_value, "p", caribou_xadapter_value_key_button_handler_lcopy_value };
            static const GTypeInfo g_define_type_info = { sizeof (CaribouXAdapterKeyButtonHandlerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_xadapter_key_button_handler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouXAdapterKeyButtonHandler), 0, (GInstanceInitFunc) caribou_xadapter_key_button_handler_instance_init, &g_define_type_value_table };
            static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
            GType caribou_xadapter_key_button_handler_type_id;
            caribou_xadapter_key_button_handler_type_id = g_type_register_fundamental (g_type_fundamental_next (), "CaribouXAdapterKeyButtonHandler", &g_define_type_info, &g_define_type_fundamental_info, 0);
            g_once_init_leave (&caribou_xadapter_key_button_handler_type_id__volatile, caribou_xadapter_key_button_handler_type_id);
      }
      return caribou_xadapter_key_button_handler_type_id__volatile;
}


static gpointer caribou_xadapter_key_button_handler_ref (gpointer instance) {
      CaribouXAdapterKeyButtonHandler* self;
      self = instance;
      g_atomic_int_inc (&self->ref_count);
      return instance;
}


static void caribou_xadapter_key_button_handler_unref (gpointer instance) {
      CaribouXAdapterKeyButtonHandler* self;
      self = instance;
      if (g_atomic_int_dec_and_test (&self->ref_count)) {
            CARIBOU_XADAPTER_KEY_BUTTON_HANDLER_GET_CLASS (self)->finalize (self);
            g_type_free_instance ((GTypeInstance *) self);
      }
}


static void caribou_xadapter_class_init (CaribouXAdapterClass * klass) {
      caribou_xadapter_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (CaribouXAdapterPrivate));
      G_OBJECT_CLASS (klass)->constructor = caribou_xadapter_constructor;
      G_OBJECT_CLASS (klass)->finalize = caribou_xadapter_finalize;
      g_signal_new ("modifiers_changed", CARIBOU_TYPE_XADAPTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
      g_signal_new ("group_changed", CARIBOU_TYPE_XADAPTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__UINT_STRING_STRING, G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
}


static void caribou_xadapter_instance_init (CaribouXAdapter * self) {
      self->priv = CARIBOU_XADAPTER_GET_PRIVATE (self);
}


static void caribou_xadapter_finalize (GObject* obj) {
      CaribouXAdapter * self;
      XkbDescRec* _tmp0_;
      gint _tmp1_;
      self = CARIBOU_XADAPTER (obj);
      _tmp0_ = self->priv->xkbdesc;
      _tmp1_ = XkbGBN_AllComponentsMask;
      XkbFreeKeyboard (_tmp0_, (guint) _tmp1_, TRUE);
      _0 (self->priv->xkbdesc);
      _g_object_unref0 (self->priv->xkl_engine);
      _g_hash_table_unref0 (self->priv->button_funcs);
      _g_hash_table_unref0 (self->priv->key_funcs);
      G_OBJECT_CLASS (caribou_xadapter_parent_class)->finalize (obj);
}


GType caribou_xadapter_get_type (void) {
      static volatile gsize caribou_xadapter_type_id__volatile = 0;
      if (g_once_init_enter (&caribou_xadapter_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (CaribouXAdapterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_xadapter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouXAdapter), 0, (GInstanceInitFunc) caribou_xadapter_instance_init, NULL };
            GType caribou_xadapter_type_id;
            caribou_xadapter_type_id = g_type_register_static (G_TYPE_OBJECT, "CaribouXAdapter", &g_define_type_info, 0);
            g_once_init_leave (&caribou_xadapter_type_id__volatile, caribou_xadapter_type_id);
      }
      return caribou_xadapter_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
      if ((array != NULL) && (destroy_func != NULL)) {
            int 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, gint array_length, GDestroyNotify destroy_func) {
      _vala_array_destroy (array, array_length, destroy_func);
      g_free (array);
}


static gint _vala_array_length (gpointer array) {
      int length;
      length = 0;
      if (array) {
            while (((gpointer*) array)[length]) {
                  length++;
            }
      }
      return length;
}




Generated by  Doxygen 1.6.0   Back to index