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

/* vim:set et sts=4 sw=4:
 *
 * ibus - The Input Bus
 *
 * Copyright(c) 2011 Peng Huang <shawn.p.huang@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 <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <string.h>
#include <cairo.h>
#include <float.h>
#include <math.h>


#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;
typedef struct _HandlePrivate HandlePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _Handle {
	GtkEventBox parent_instance;
	HandlePrivate * priv;
};

struct _HandleClass {
	GtkEventBoxClass parent_class;
};

struct _HandlePrivate {
	gboolean m_move_begined;
	GdkRectangle m_workarea;
	GdkPoint m_press_pos;
};


static gpointer handle_parent_class = NULL;

GType handle_get_type (void) G_GNUC_CONST;
#define HANDLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_HANDLE, HandlePrivate))
enum  {
	HANDLE_DUMMY_PROPERTY
};
Handle* handle_new (void);
Handle* handle_construct (GType object_type);
static void handle_real_realize (GtkWidget* base);
static gboolean handle_real_button_press_event (GtkWidget* base, GdkEventButton* event);
static gboolean handle_real_button_release_event (GtkWidget* base, GdkEventButton* event);
static gboolean handle_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event);
static gboolean handle_real_draw (GtkWidget* base, cairo_t* cr);
static void handle_finalize (GObject* obj);


Handle* handle_construct (GType object_type) {
	Handle * self = NULL;
	GdkEventMask mask;
	self = (Handle*) g_object_new (object_type, NULL);
	gtk_widget_set_size_request ((GtkWidget*) self, 6, -1);
	mask = ((GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK) | GDK_BUTTON_RELEASE_MASK) | GDK_BUTTON1_MOTION_MASK;
	gtk_widget_set_events ((GtkWidget*) self, (gint) mask);
	self->priv->m_move_begined = FALSE;
	return self;
}


Handle* handle_new (void) {
	return handle_construct (TYPE_HANDLE);
}


static void handle_real_realize (GtkWidget* base) {
	Handle * self;
	self = (Handle*) base;
	GTK_WIDGET_CLASS (handle_parent_class)->realize ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, GTK_TYPE_EVENT_BOX, GtkEventBox));
}


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


static gboolean handle_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
	Handle * self;
	gboolean result = FALSE;
	GdkEventButton _tmp0_;
	guint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	GdkRectangle _tmp4_ = {0};
	GdkRectangle _tmp5_;
	gint x = 0;
	gint y = 0;
	GtkWidget* _tmp115_ = NULL;
	GtkWindow* _tmp116_;
	GtkWindow* toplevel;
	GtkWindow* _tmp117_;
	gint _tmp118_ = 0;
	gint _tmp119_ = 0;
	GdkEventButton _tmp120_;
	gdouble _tmp121_;
	gint _tmp122_;
	GdkEventButton _tmp123_;
	gdouble _tmp124_;
	gint _tmp125_;
	self = (Handle*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = *event;
	_tmp1_ = _tmp0_.button;
	if (_tmp1_ != ((guint) 1)) {
		result = FALSE;
		return result;
	}
	_tmp2_ = G_MAXINT;
	_tmp3_ = G_MAXINT;
	memset (&_tmp4_, 0, sizeof (GdkRectangle));
	_tmp4_.x = 0;
	_tmp4_.y = 0;
	_tmp4_.width = _tmp2_;
	_tmp4_.height = _tmp3_;
	self->priv->m_workarea = _tmp4_;
	_tmp5_ = self->priv->m_workarea;
	{
		gboolean _tmp6_;
		_tmp6_ = TRUE;
		while (TRUE) {
			gboolean _tmp7_;
			GdkWindow* _tmp8_ = NULL;
			GdkWindow* _tmp9_;
			GdkWindow* root;
			GdkAtom _tmp10_ = 0U;
			GdkAtom property;
			GdkAtom _tmp11_ = 0U;
			GdkAtom type;
			GdkAtom actual_type = 0U;
			gint format = 0;
			guchar* data = NULL;
			gint data_length1 = 0;
			gint _data_size_ = 0;
			gboolean _result_ = FALSE;
			GdkWindow* _tmp12_;
			GdkAtom _tmp13_;
			GdkAtom _tmp14_;
			glong _tmp15_;
			GdkAtom _tmp16_ = 0U;
			gint _tmp17_ = 0;
			guint8* _tmp18_ = NULL;
			gint _tmp19_ = 0;
			gboolean _tmp20_ = FALSE;
			gboolean _tmp21_ = FALSE;
			gboolean _tmp22_ = FALSE;
			gboolean _tmp23_ = FALSE;
			gboolean _tmp24_;
			gboolean _tmp27_;
			gboolean _tmp29_;
			gboolean _tmp31_;
			guchar* _tmp32_;
			gint _tmp32__length1;
			guchar _tmp33_;
			guchar* _tmp34_;
			gint _tmp34__length1;
			guchar _tmp35_;
			guchar* _tmp36_;
			gint _tmp36__length1;
			guchar _tmp37_;
			guchar* _tmp38_;
			gint _tmp38__length1;
			guchar _tmp39_;
			gint index;
			GdkAtom _tmp40_ = 0U;
			GdkAtom _tmp41_ = 0U;
			GdkWindow* _tmp42_;
			GdkAtom _tmp43_;
			GdkAtom _tmp44_;
			glong _tmp45_;
			GdkAtom _tmp46_ = 0U;
			gint _tmp47_ = 0;
			guint8* _tmp48_ = NULL;
			gint _tmp49_ = 0;
			gboolean _tmp50_ = FALSE;
			gboolean _tmp51_ = FALSE;
			gboolean _tmp52_ = FALSE;
			gboolean _tmp53_ = FALSE;
			gboolean _tmp54_;
			gboolean _tmp57_;
			gboolean _tmp59_;
			gboolean _tmp62_;
			gint _tmp63_;
			gint i;
			guchar* _tmp64_;
			gint _tmp64__length1;
			gint _tmp65_;
			guchar _tmp66_;
			guchar* _tmp67_;
			gint _tmp67__length1;
			gint _tmp68_;
			guchar _tmp69_;
			guchar* _tmp70_;
			gint _tmp70__length1;
			gint _tmp71_;
			guchar _tmp72_;
			guchar* _tmp73_;
			gint _tmp73__length1;
			gint _tmp74_;
			guchar _tmp75_;
			gint _tmp76_;
			guchar* _tmp77_;
			gint _tmp77__length1;
			gint _tmp78_;
			guchar _tmp79_;
			guchar* _tmp80_;
			gint _tmp80__length1;
			gint _tmp81_;
			guchar _tmp82_;
			guchar* _tmp83_;
			gint _tmp83__length1;
			gint _tmp84_;
			guchar _tmp85_;
			guchar* _tmp86_;
			gint _tmp86__length1;
			gint _tmp87_;
			guchar _tmp88_;
			gint _tmp89_;
			guchar* _tmp90_;
			gint _tmp90__length1;
			gint _tmp91_;
			guchar _tmp92_;
			guchar* _tmp93_;
			gint _tmp93__length1;
			gint _tmp94_;
			guchar _tmp95_;
			guchar* _tmp96_;
			gint _tmp96__length1;
			gint _tmp97_;
			guchar _tmp98_;
			guchar* _tmp99_;
			gint _tmp99__length1;
			gint _tmp100_;
			guchar _tmp101_;
			gint _tmp102_;
			guchar* _tmp103_;
			gint _tmp103__length1;
			gint _tmp104_;
			guchar _tmp105_;
			guchar* _tmp106_;
			gint _tmp106__length1;
			gint _tmp107_;
			guchar _tmp108_;
			guchar* _tmp109_;
			gint _tmp109__length1;
			gint _tmp110_;
			guchar _tmp111_;
			guchar* _tmp112_;
			gint _tmp112__length1;
			gint _tmp113_;
			guchar _tmp114_;
			_tmp7_ = _tmp6_;
			if (!_tmp7_) {
				if (!FALSE) {
					break;
				}
			}
			_tmp6_ = FALSE;
			_tmp8_ = gdk_get_default_root_window ();
			_tmp9_ = _g_object_ref0 (_tmp8_);
			root = _tmp9_;
			_tmp10_ = gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE);
			property = _tmp10_;
			_tmp11_ = gdk_atom_intern ("CARDINAL", FALSE);
			type = _tmp11_;
			_tmp12_ = root;
			_tmp13_ = property;
			_tmp14_ = type;
			_tmp15_ = G_MAXLONG;
			_tmp20_ = gdk_property_get (_tmp12_, _tmp13_, _tmp14_, (gulong) 0, (gulong) _tmp15_, 0, &_tmp16_, &_tmp17_, &_tmp19_, &_tmp18_);
			actual_type = _tmp16_;
			format = _tmp17_;
			data = (g_free (data), NULL);
			data = _tmp18_;
			data_length1 = _tmp19_;
			_data_size_ = data_length1;
			_result_ = _tmp20_;
			_tmp24_ = _result_;
			if (!_tmp24_) {
				_tmp23_ = TRUE;
			} else {
				GdkAtom _tmp25_;
				GdkAtom _tmp26_;
				_tmp25_ = actual_type;
				_tmp26_ = type;
				_tmp23_ = _tmp25_ != _tmp26_;
			}
			_tmp27_ = _tmp23_;
			if (_tmp27_) {
				_tmp22_ = TRUE;
			} else {
				gint _tmp28_;
				_tmp28_ = format;
				_tmp22_ = _tmp28_ != 32;
			}
			_tmp29_ = _tmp22_;
			if (_tmp29_) {
				_tmp21_ = TRUE;
			} else {
				guchar* _tmp30_;
				gint _tmp30__length1;
				_tmp30_ = data;
				_tmp30__length1 = data_length1;
				_tmp21_ = _tmp30__length1 != 4;
			}
			_tmp31_ = _tmp21_;
			if (_tmp31_) {
				data = (g_free (data), NULL);
				_g_object_unref0 (root);
				break;
			}
			_tmp32_ = data;
			_tmp32__length1 = data_length1;
			_tmp33_ = _tmp32_[0];
			_tmp34_ = data;
			_tmp34__length1 = data_length1;
			_tmp35_ = _tmp34_[1];
			_tmp36_ = data;
			_tmp36__length1 = data_length1;
			_tmp37_ = _tmp36_[2];
			_tmp38_ = data;
			_tmp38__length1 = data_length1;
			_tmp39_ = _tmp38_[3];
			index = (gint) (((_tmp33_ | (_tmp35_ << 8)) | (_tmp37_ << 16)) | (_tmp39_ << 24));
			_tmp40_ = gdk_atom_intern ("_NET_WORKAREA", FALSE);
			property = _tmp40_;
			_tmp41_ = gdk_atom_intern ("CARDINAL", FALSE);
			type = _tmp41_;
			_tmp42_ = root;
			_tmp43_ = property;
			_tmp44_ = type;
			_tmp45_ = G_MAXLONG;
			_tmp50_ = gdk_property_get (_tmp42_, _tmp43_, _tmp44_, (gulong) 0, (gulong) _tmp45_, 0, &_tmp46_, &_tmp47_, &_tmp49_, &_tmp48_);
			actual_type = _tmp46_;
			format = _tmp47_;
			data = (g_free (data), NULL);
			data = _tmp48_;
			data_length1 = _tmp49_;
			_data_size_ = data_length1;
			_result_ = _tmp50_;
			_tmp54_ = _result_;
			if (!_tmp54_) {
				_tmp53_ = TRUE;
			} else {
				GdkAtom _tmp55_;
				GdkAtom _tmp56_;
				_tmp55_ = actual_type;
				_tmp56_ = type;
				_tmp53_ = _tmp55_ != _tmp56_;
			}
			_tmp57_ = _tmp53_;
			if (_tmp57_) {
				_tmp52_ = TRUE;
			} else {
				gint _tmp58_;
				_tmp58_ = format;
				_tmp52_ = _tmp58_ != 32;
			}
			_tmp59_ = _tmp52_;
			if (_tmp59_) {
				_tmp51_ = TRUE;
			} else {
				guchar* _tmp60_;
				gint _tmp60__length1;
				gint _tmp61_;
				_tmp60_ = data;
				_tmp60__length1 = data_length1;
				_tmp61_ = index;
				_tmp51_ = _tmp60__length1 < ((_tmp61_ + 1) * 16);
			}
			_tmp62_ = _tmp51_;
			if (_tmp62_) {
				data = (g_free (data), NULL);
				_g_object_unref0 (root);
				break;
			}
			_tmp63_ = index;
			i = (_tmp63_ * 4) * 4;
			_tmp64_ = data;
			_tmp64__length1 = data_length1;
			_tmp65_ = i;
			_tmp66_ = _tmp64_[_tmp65_];
			_tmp67_ = data;
			_tmp67__length1 = data_length1;
			_tmp68_ = i;
			_tmp69_ = _tmp67_[_tmp68_ + 1];
			_tmp70_ = data;
			_tmp70__length1 = data_length1;
			_tmp71_ = i;
			_tmp72_ = _tmp70_[_tmp71_ + 2];
			_tmp73_ = data;
			_tmp73__length1 = data_length1;
			_tmp74_ = i;
			_tmp75_ = _tmp73_[_tmp74_ + 3];
			self->priv->m_workarea.x = (gint) (((_tmp66_ | (_tmp69_ << 8)) | (_tmp72_ << 16)) | (_tmp75_ << 24));
			_tmp76_ = i;
			i = _tmp76_ + 4;
			_tmp77_ = data;
			_tmp77__length1 = data_length1;
			_tmp78_ = i;
			_tmp79_ = _tmp77_[_tmp78_];
			_tmp80_ = data;
			_tmp80__length1 = data_length1;
			_tmp81_ = i;
			_tmp82_ = _tmp80_[_tmp81_ + 1];
			_tmp83_ = data;
			_tmp83__length1 = data_length1;
			_tmp84_ = i;
			_tmp85_ = _tmp83_[_tmp84_ + 2];
			_tmp86_ = data;
			_tmp86__length1 = data_length1;
			_tmp87_ = i;
			_tmp88_ = _tmp86_[_tmp87_ + 3];
			self->priv->m_workarea.y = (gint) (((_tmp79_ | (_tmp82_ << 8)) | (_tmp85_ << 16)) | (_tmp88_ << 24));
			_tmp89_ = i;
			i = _tmp89_ + 4;
			_tmp90_ = data;
			_tmp90__length1 = data_length1;
			_tmp91_ = i;
			_tmp92_ = _tmp90_[_tmp91_];
			_tmp93_ = data;
			_tmp93__length1 = data_length1;
			_tmp94_ = i;
			_tmp95_ = _tmp93_[_tmp94_ + 1];
			_tmp96_ = data;
			_tmp96__length1 = data_length1;
			_tmp97_ = i;
			_tmp98_ = _tmp96_[_tmp97_ + 2];
			_tmp99_ = data;
			_tmp99__length1 = data_length1;
			_tmp100_ = i;
			_tmp101_ = _tmp99_[_tmp100_ + 3];
			self->priv->m_workarea.width = (gint) (((_tmp92_ | (_tmp95_ << 8)) | (_tmp98_ << 16)) | (_tmp101_ << 24));
			_tmp102_ = i;
			i = _tmp102_ + 4;
			_tmp103_ = data;
			_tmp103__length1 = data_length1;
			_tmp104_ = i;
			_tmp105_ = _tmp103_[_tmp104_];
			_tmp106_ = data;
			_tmp106__length1 = data_length1;
			_tmp107_ = i;
			_tmp108_ = _tmp106_[_tmp107_ + 1];
			_tmp109_ = data;
			_tmp109__length1 = data_length1;
			_tmp110_ = i;
			_tmp111_ = _tmp109_[_tmp110_ + 2];
			_tmp112_ = data;
			_tmp112__length1 = data_length1;
			_tmp113_ = i;
			_tmp114_ = _tmp112_[_tmp113_ + 3];
			self->priv->m_workarea.height = (gint) (((_tmp105_ | (_tmp108_ << 8)) | (_tmp111_ << 16)) | (_tmp114_ << 24));
			data = (g_free (data), NULL);
			_g_object_unref0 (root);
		}
	}
	self->priv->m_move_begined = TRUE;
	_tmp115_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	_tmp116_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp115_, GTK_TYPE_WINDOW, GtkWindow));
	toplevel = _tmp116_;
	_tmp117_ = toplevel;
	gtk_window_get_position (_tmp117_, &_tmp118_, &_tmp119_);
	x = _tmp118_;
	y = _tmp119_;
	_tmp120_ = *event;
	_tmp121_ = _tmp120_.x_root;
	_tmp122_ = x;
	self->priv->m_press_pos.x = ((gint) _tmp121_) - _tmp122_;
	_tmp123_ = *event;
	_tmp124_ = _tmp123_.y_root;
	_tmp125_ = y;
	self->priv->m_press_pos.y = ((gint) _tmp124_) - _tmp125_;
	g_signal_emit_by_name (self, "move-begin");
	result = TRUE;
	_g_object_unref0 (toplevel);
	return result;
}


static gboolean handle_real_button_release_event (GtkWidget* base, GdkEventButton* event) {
	Handle * self;
	gboolean result = FALSE;
	GdkEventButton _tmp0_;
	guint _tmp1_;
	GdkWindow* _tmp2_ = NULL;
	GdkCursor* _tmp3_;
	GdkCursor* _tmp4_;
	self = (Handle*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = *event;
	_tmp1_ = _tmp0_.button;
	if (_tmp1_ != ((guint) 1)) {
		result = FALSE;
		return result;
	}
	self->priv->m_move_begined = FALSE;
	self->priv->m_press_pos.x = 0;
	self->priv->m_press_pos.y = 0;
	_tmp2_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp3_ = gdk_cursor_new (GDK_LEFT_PTR);
	_tmp4_ = _tmp3_;
	gdk_window_set_cursor (_tmp2_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	g_signal_emit_by_name (self, "move-end");
	result = TRUE;
	return result;
}


static gboolean handle_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
	Handle * self;
	gboolean result = FALSE;
	gboolean _tmp0_;
	GtkWidget* _tmp1_ = NULL;
	GtkWindow* _tmp2_;
	GtkWindow* toplevel;
	GdkEventMotion _tmp3_;
	gdouble _tmp4_;
	GdkPoint _tmp5_;
	gint _tmp6_;
	gint x;
	GdkEventMotion _tmp7_;
	gdouble _tmp8_;
	GdkPoint _tmp9_;
	gint _tmp10_;
	gint y;
	gboolean _tmp11_ = FALSE;
	gint _tmp12_;
	GdkRectangle _tmp13_;
	gint _tmp14_;
	gboolean _tmp18_;
	gboolean _tmp21_ = FALSE;
	gint _tmp22_;
	GdkRectangle _tmp23_;
	gint _tmp24_;
	gboolean _tmp28_;
	gint w = 0;
	gint h = 0;
	GtkWindow* _tmp31_;
	gint _tmp32_ = 0;
	gint _tmp33_ = 0;
	gboolean _tmp34_ = FALSE;
	gint _tmp35_;
	gint _tmp36_;
	GdkRectangle _tmp37_;
	gint _tmp38_;
	GdkRectangle _tmp39_;
	gint _tmp40_;
	gboolean _tmp47_;
	gboolean _tmp53_ = FALSE;
	gint _tmp54_;
	gint _tmp55_;
	GdkRectangle _tmp56_;
	gint _tmp57_;
	GdkRectangle _tmp58_;
	gint _tmp59_;
	gboolean _tmp66_;
	GtkWindow* _tmp72_;
	gint _tmp73_;
	gint _tmp74_;
	self = (Handle*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->m_move_begined;
	if (!_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp1_ = gtk_widget_get_toplevel ((GtkWidget*) self);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GTK_TYPE_WINDOW, GtkWindow));
	toplevel = _tmp2_;
	_tmp3_ = *event;
	_tmp4_ = _tmp3_.x_root;
	_tmp5_ = self->priv->m_press_pos;
	_tmp6_ = _tmp5_.x;
	x = (gint) (_tmp4_ - _tmp6_);
	_tmp7_ = *event;
	_tmp8_ = _tmp7_.y_root;
	_tmp9_ = self->priv->m_press_pos;
	_tmp10_ = _tmp9_.y;
	y = (gint) (_tmp8_ - _tmp10_);
	_tmp12_ = x;
	_tmp13_ = self->priv->m_workarea;
	_tmp14_ = _tmp13_.x;
	if (_tmp12_ < _tmp14_) {
		gint _tmp15_;
		GdkRectangle _tmp16_;
		gint _tmp17_;
		_tmp15_ = x;
		_tmp16_ = self->priv->m_workarea;
		_tmp17_ = _tmp16_.x;
		_tmp11_ = _tmp15_ > (_tmp17_ - 16);
	} else {
		_tmp11_ = FALSE;
	}
	_tmp18_ = _tmp11_;
	if (_tmp18_) {
		GdkRectangle _tmp19_;
		gint _tmp20_;
		_tmp19_ = self->priv->m_workarea;
		_tmp20_ = _tmp19_.x;
		x = _tmp20_;
	}
	_tmp22_ = y;
	_tmp23_ = self->priv->m_workarea;
	_tmp24_ = _tmp23_.y;
	if (_tmp22_ < _tmp24_) {
		gint _tmp25_;
		GdkRectangle _tmp26_;
		gint _tmp27_;
		_tmp25_ = y;
		_tmp26_ = self->priv->m_workarea;
		_tmp27_ = _tmp26_.y;
		_tmp21_ = _tmp25_ > (_tmp27_ - 16);
	} else {
		_tmp21_ = FALSE;
	}
	_tmp28_ = _tmp21_;
	if (_tmp28_) {
		GdkRectangle _tmp29_;
		gint _tmp30_;
		_tmp29_ = self->priv->m_workarea;
		_tmp30_ = _tmp29_.y;
		y = _tmp30_;
	}
	_tmp31_ = toplevel;
	gtk_window_get_size (_tmp31_, &_tmp32_, &_tmp33_);
	w = _tmp32_;
	h = _tmp33_;
	_tmp35_ = x;
	_tmp36_ = w;
	_tmp37_ = self->priv->m_workarea;
	_tmp38_ = _tmp37_.x;
	_tmp39_ = self->priv->m_workarea;
	_tmp40_ = _tmp39_.width;
	if ((_tmp35_ + _tmp36_) > (_tmp38_ + _tmp40_)) {
		gint _tmp41_;
		gint _tmp42_;
		GdkRectangle _tmp43_;
		gint _tmp44_;
		GdkRectangle _tmp45_;
		gint _tmp46_;
		_tmp41_ = x;
		_tmp42_ = w;
		_tmp43_ = self->priv->m_workarea;
		_tmp44_ = _tmp43_.x;
		_tmp45_ = self->priv->m_workarea;
		_tmp46_ = _tmp45_.width;
		_tmp34_ = (_tmp41_ + _tmp42_) < ((_tmp44_ + _tmp46_) + 16);
	} else {
		_tmp34_ = FALSE;
	}
	_tmp47_ = _tmp34_;
	if (_tmp47_) {
		GdkRectangle _tmp48_;
		gint _tmp49_;
		GdkRectangle _tmp50_;
		gint _tmp51_;
		gint _tmp52_;
		_tmp48_ = self->priv->m_workarea;
		_tmp49_ = _tmp48_.x;
		_tmp50_ = self->priv->m_workarea;
		_tmp51_ = _tmp50_.width;
		_tmp52_ = w;
		x = (_tmp49_ + _tmp51_) - _tmp52_;
	}
	_tmp54_ = y;
	_tmp55_ = h;
	_tmp56_ = self->priv->m_workarea;
	_tmp57_ = _tmp56_.y;
	_tmp58_ = self->priv->m_workarea;
	_tmp59_ = _tmp58_.height;
	if ((_tmp54_ + _tmp55_) > (_tmp57_ + _tmp59_)) {
		gint _tmp60_;
		gint _tmp61_;
		GdkRectangle _tmp62_;
		gint _tmp63_;
		GdkRectangle _tmp64_;
		gint _tmp65_;
		_tmp60_ = y;
		_tmp61_ = h;
		_tmp62_ = self->priv->m_workarea;
		_tmp63_ = _tmp62_.y;
		_tmp64_ = self->priv->m_workarea;
		_tmp65_ = _tmp64_.height;
		_tmp53_ = (_tmp60_ + _tmp61_) < ((_tmp63_ + _tmp65_) + 16);
	} else {
		_tmp53_ = FALSE;
	}
	_tmp66_ = _tmp53_;
	if (_tmp66_) {
		GdkRectangle _tmp67_;
		gint _tmp68_;
		GdkRectangle _tmp69_;
		gint _tmp70_;
		gint _tmp71_;
		_tmp67_ = self->priv->m_workarea;
		_tmp68_ = _tmp67_.y;
		_tmp69_ = self->priv->m_workarea;
		_tmp70_ = _tmp69_.height;
		_tmp71_ = w;
		y = (_tmp68_ + _tmp70_) - _tmp71_;
	}
	_tmp72_ = toplevel;
	_tmp73_ = x;
	_tmp74_ = y;
	gtk_window_move (_tmp72_, _tmp73_, _tmp74_);
	result = TRUE;
	_g_object_unref0 (toplevel);
	return result;
}


static gboolean handle_real_draw (GtkWidget* base, cairo_t* cr) {
	Handle * self;
	gboolean result = FALSE;
	cairo_t* _tmp0_;
	GdkWindow* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	self = (Handle*) base;
	g_return_val_if_fail (cr != NULL, FALSE);
	_tmp0_ = cr;
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp2_ = gtk_cairo_should_draw_window (_tmp0_, _tmp1_);
	if (_tmp2_) {
		GtkStyleContext* _tmp3_ = NULL;
		GtkStyleContext* _tmp4_;
		GtkStyleContext* context;
		GtkAllocation allocation = {0};
		GtkAllocation _tmp5_ = {0};
		GtkStyleContext* _tmp6_;
		cairo_t* _tmp7_;
		GtkAllocation _tmp8_;
		gint _tmp9_;
		GtkAllocation _tmp10_;
		gint _tmp11_;
		GtkAllocation _tmp12_;
		gint _tmp13_;
		GtkAllocation _tmp14_;
		gint _tmp15_;
		_tmp3_ = gtk_widget_get_style_context ((GtkWidget*) self);
		_tmp4_ = _g_object_ref0 (_tmp3_);
		context = _tmp4_;
		gtk_widget_get_allocation ((GtkWidget*) self, &_tmp5_);
		allocation = _tmp5_;
		_tmp6_ = context;
		_tmp7_ = cr;
		_tmp8_ = allocation;
		_tmp9_ = _tmp8_.x;
		_tmp10_ = allocation;
		_tmp11_ = _tmp10_.y;
		_tmp12_ = allocation;
		_tmp13_ = _tmp12_.height;
		_tmp14_ = allocation;
		_tmp15_ = _tmp14_.width;
		gtk_render_handle (_tmp6_, _tmp7_, (gdouble) _tmp9_, (gdouble) (_tmp11_ + ((_tmp13_ - 40) / 2)), (gdouble) _tmp15_, 40.0);
		_g_object_unref0 (context);
	}
	result = FALSE;
	return result;
}


static void handle_class_init (HandleClass * klass) {
	handle_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (HandlePrivate));
	GTK_WIDGET_CLASS (klass)->realize = handle_real_realize;
	GTK_WIDGET_CLASS (klass)->button_press_event = handle_real_button_press_event;
	GTK_WIDGET_CLASS (klass)->button_release_event = handle_real_button_release_event;
	GTK_WIDGET_CLASS (klass)->motion_notify_event = handle_real_motion_notify_event;
	GTK_WIDGET_CLASS (klass)->draw = handle_real_draw;
	G_OBJECT_CLASS (klass)->finalize = handle_finalize;
	g_signal_new ("move_begin", TYPE_HANDLE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	g_signal_new ("move_end", TYPE_HANDLE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void handle_instance_init (Handle * self) {
	self->priv = HANDLE_GET_PRIVATE (self);
}


static void handle_finalize (GObject* obj) {
	Handle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_HANDLE, Handle);
	G_OBJECT_CLASS (handle_parent_class)->finalize (obj);
}


GType handle_get_type (void) {
	static volatile gsize handle_type_id__volatile = 0;
	if (g_once_init_enter (&handle_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (HandleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) handle_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Handle), 0, (GInstanceInitFunc) handle_instance_init, NULL };
		GType handle_type_id;
		handle_type_id = g_type_register_static (GTK_TYPE_EVENT_BOX, "Handle", &g_define_type_info, 0);
		g_once_init_leave (&handle_type_id__volatile, handle_type_id);
	}
	return handle_type_id__volatile;
}



