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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2011 ~ 2018 Deepin, Inc.
 *               2011 ~ 2018 Wang Yong
 *               2019 ~ 2020 Gary Wang
 *
 * Author:     Wang Yong <wangyong@deepin.com>
 *             Gary Wang <wzc782970009@gmail.com>
 * Maintainer: Wang Yong <wangyong@deepin.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
#include <cairo-gobject.h>
#include <string.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 WIDGETS_TYPE_WINDOW_EVENT_AREA (widgets_window_event_area_get_type ())
#define WIDGETS_WINDOW_EVENT_AREA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_WINDOW_EVENT_AREA, WidgetsWindowEventArea))
#define WIDGETS_WINDOW_EVENT_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_WINDOW_EVENT_AREA, WidgetsWindowEventAreaClass))
#define WIDGETS_IS_WINDOW_EVENT_AREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_WINDOW_EVENT_AREA))
#define WIDGETS_IS_WINDOW_EVENT_AREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_WINDOW_EVENT_AREA))
#define WIDGETS_WINDOW_EVENT_AREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_WINDOW_EVENT_AREA, WidgetsWindowEventAreaClass))

typedef struct _WidgetsWindowEventArea WidgetsWindowEventArea;
typedef struct _WidgetsWindowEventAreaClass WidgetsWindowEventAreaClass;
typedef struct _WidgetsWindowEventAreaPrivate WidgetsWindowEventAreaPrivate;
typedef gboolean (*WidgetsWindowEventAreaFilterDoubleClick) (gint x, gint y, gpointer user_data);
enum  {
	WIDGETS_WINDOW_EVENT_AREA_0_PROPERTY,
	WIDGETS_WINDOW_EVENT_AREA_NUM_PROPERTIES
};
static GParamSpec* widgets_window_event_area_properties[WIDGETS_WINDOW_EVENT_AREA_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __vala_GdkEvent_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEvent_free (var), NULL)))
#define __vala_GdkEventButton_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEventButton_free (var), NULL)))
typedef struct _Block52Data Block52Data;

#define WIDGETS_TYPE_CONFIG_WINDOW (widgets_config_window_get_type ())
#define WIDGETS_CONFIG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_CONFIG_WINDOW, WidgetsConfigWindow))
#define WIDGETS_CONFIG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_CONFIG_WINDOW, WidgetsConfigWindowClass))
#define WIDGETS_IS_CONFIG_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_CONFIG_WINDOW))
#define WIDGETS_IS_CONFIG_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_CONFIG_WINDOW))
#define WIDGETS_CONFIG_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_CONFIG_WINDOW, WidgetsConfigWindowClass))

typedef struct _WidgetsConfigWindow WidgetsConfigWindow;
typedef struct _WidgetsConfigWindowClass WidgetsConfigWindowClass;

#define WIDGETS_TYPE_WINDOW (widgets_window_get_type ())
#define WIDGETS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_WINDOW, WidgetsWindow))
#define WIDGETS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_WINDOW, WidgetsWindowClass))
#define WIDGETS_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_WINDOW))
#define WIDGETS_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_WINDOW))
#define WIDGETS_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_WINDOW, WidgetsWindowClass))

typedef struct _WidgetsWindow WidgetsWindow;
typedef struct _WidgetsWindowClass WidgetsWindowClass;

struct _WidgetsWindowEventArea {
	GtkEventBox parent_instance;
	WidgetsWindowEventAreaPrivate * priv;
	WidgetsWindowEventAreaFilterDoubleClick filter_double_click_callback;
	gpointer filter_double_click_callback_target;
	GDestroyNotify filter_double_click_callback_target_destroy_notify;
	GtkContainer* drawing_area;
	GtkWidget* child_before_leave;
	gboolean is_double_clicked;
	gboolean is_press;
	gdouble press_x;
	gdouble press_y;
	gint double_clicked_max_delay;
};

struct _WidgetsWindowEventAreaClass {
	GtkEventBoxClass parent_class;
};

struct _Block52Data {
	int _ref_count_;
	WidgetsWindowEventArea* self;
	GdkEventButton* e;
};

static gpointer widgets_window_event_area_parent_class = NULL;

VALA_EXTERN GType widgets_window_event_area_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsWindowEventArea, g_object_unref)
VALA_EXTERN WidgetsWindowEventArea* widgets_window_event_area_new (GtkContainer* area);
VALA_EXTERN WidgetsWindowEventArea* widgets_window_event_area_construct (GType object_type,
                                                             GtkContainer* area);
static gboolean __lambda56_ (WidgetsWindowEventArea* self,
                      GtkWidget* w,
                      GdkEventCrossing* e);
static void _vala_GdkEvent_free (GdkEvent* self);
static gboolean ___lambda56__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                                     GdkEventCrossing* event,
                                                     gpointer self);
static gboolean __lambda57_ (WidgetsWindowEventArea* self,
                      GtkWidget* w,
                      GdkEventMotion* e);
VALA_EXTERN GtkWidget* widgets_window_event_area_get_child_at_pos (WidgetsWindowEventArea* self,
                                                       GtkContainer* container,
                                                       gint x,
                                                       gint y);
static gboolean ___lambda57__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                                      GdkEventMotion* event,
                                                      gpointer self);
static gboolean __lambda58_ (WidgetsWindowEventArea* self,
                      GtkWidget* w,
                      GdkEventButton* e);
static GdkEventButton* _vala_GdkEventButton_copy (GdkEventButton* self);
static void _vala_GdkEventButton_free (GdkEventButton* self);
static Block52Data* block52_data_ref (Block52Data* _data52_);
static void block52_data_unref (void * _userdata_);
static gboolean __lambda59_ (Block52Data* _data52_);
VALA_EXTERN gboolean utils_move_window (GtkWidget* widget,
                            GdkEventButton* event);
static gboolean ___lambda59__gsource_func (gpointer self);
static gboolean ___lambda60_ (WidgetsWindowEventArea* self);
static gboolean ____lambda60__gsource_func (gpointer self);
VALA_EXTERN gboolean utils_is_left_button (GdkEventButton* event);
VALA_EXTERN GType widgets_config_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsConfigWindow, g_object_unref)
VALA_EXTERN GType widgets_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsWindow, g_object_unref)
VALA_EXTERN void widgets_window_toggle_max (WidgetsWindow* self);
static gboolean ___lambda58__gtk_widget_button_press_event (GtkWidget* _sender,
                                                     GdkEventButton* event,
                                                     gpointer self);
static gboolean __lambda225_ (WidgetsWindowEventArea* self,
                       GtkWidget* w,
                       GdkEventButton* e);
static gboolean ___lambda225__gtk_widget_button_release_event (GtkWidget* _sender,
                                                        GdkEventButton* event,
                                                        gpointer self);
static void widgets_window_event_area_finalize (GObject * obj);
static GType widgets_window_event_area_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

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

static void
_vala_GdkEvent_free (GdkEvent* self)
{
	g_boxed_free (gdk_event_get_type (), self);
}

static gboolean
__lambda56_ (WidgetsWindowEventArea* self,
             GtkWidget* w,
             GdkEventCrossing* e)
{
	GtkWidget* _tmp0_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = self->child_before_leave;
	if (_tmp0_ != NULL) {
		GdkEvent* e2 = NULL;
		GdkEvent* _tmp1_;
		GdkEvent* _tmp2_;
		GdkEventCrossing* _tmp3_;
		GdkEventCrossing* _tmp4_;
		GtkWidget* _tmp5_;
		GdkWindow* _tmp6_;
		GtkWidget* _tmp7_;
		GdkWindow* _tmp8_;
		GdkEvent* _tmp9_;
		_tmp1_ = gdk_event_copy ((GdkEvent*) e);
		e2 = _tmp1_;
		_tmp2_ = e2;
		_tmp3_ = (GdkEventCrossing *) (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = self->child_before_leave;
		_tmp6_ = gtk_widget_get_window (_tmp5_);
		_tmp4_->window = _tmp6_;
		_tmp7_ = self->child_before_leave;
		_tmp8_ = gtk_widget_get_window (_tmp7_);
		g_object_ref ((GObject*) _tmp8_);
		_tmp9_ = e2;
		gdk_event_put ((GdkEvent*) _tmp9_);
		_g_object_unref0 (self->child_before_leave);
		self->child_before_leave = NULL;
		__vala_GdkEvent_free0 (e2);
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda56__gtk_widget_leave_notify_event (GtkWidget* _sender,
                                            GdkEventCrossing* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda56_ ((WidgetsWindowEventArea*) self, _sender, event);
	return result;
}

static gboolean
__lambda57_ (WidgetsWindowEventArea* self,
             GtkWidget* w,
             GdkEventMotion* e)
{
	GtkWidget* child = NULL;
	GtkContainer* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = self->drawing_area;
	_tmp1_ = widgets_window_event_area_get_child_at_pos (self, _tmp0_, (gint) e->x, (gint) e->y);
	child = _tmp1_;
	_tmp2_ = child;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (self->child_before_leave);
	self->child_before_leave = _tmp3_;
	_tmp4_ = child;
	if (_tmp4_ != NULL) {
		gint x = 0;
		gint y = 0;
		GtkContainer* _tmp5_;
		GtkWidget* _tmp6_;
		gint _tmp7_ = 0;
		gint _tmp8_ = 0;
		GdkEventMotion* event = NULL;
		GdkEvent* _tmp9_;
		GdkEventMotion* _tmp10_;
		GtkWidget* _tmp11_;
		GdkWindow* _tmp12_;
		GdkEventMotion* _tmp13_;
		GdkEventMotion* _tmp14_;
		GdkEventMotion* _tmp15_;
		GdkEventMotion* _tmp16_;
		GdkEventMotion* _tmp17_;
		GdkEventMotion* _tmp18_;
		GdkEventMotion* _tmp19_;
		GdkEventMotion* _tmp20_;
		GdkEventMotion* _tmp21_;
		GdkDevice* _tmp22_;
		GdkEventMotion* _tmp23_;
		gdouble* _tmp24_;
		gint _tmp24__length1;
		GdkEventMotion* _tmp25_;
		_tmp5_ = self->drawing_area;
		_tmp6_ = child;
		gtk_widget_translate_coordinates ((GtkWidget*) _tmp5_, _tmp6_, (gint) e->x, (gint) e->y, &_tmp7_, &_tmp8_);
		x = _tmp7_;
		y = _tmp8_;
		_tmp9_ = gdk_event_new (GDK_MOTION_NOTIFY);
		event = (GdkEventMotion*) _tmp9_;
		_tmp10_ = event;
		_tmp11_ = child;
		_tmp12_ = gtk_widget_get_window (_tmp11_);
		_tmp10_->window = _tmp12_;
		_tmp13_ = event;
		_tmp13_->send_event = (gint8) 1;
		_tmp14_ = event;
		_tmp14_->time = e->time;
		_tmp15_ = event;
		_tmp15_->x = (gdouble) x;
		_tmp16_ = event;
		_tmp16_->y = (gdouble) y;
		_tmp17_ = event;
		_tmp17_->x_root = e->x_root;
		_tmp18_ = event;
		_tmp18_->y_root = e->y_root;
		_tmp19_ = event;
		_tmp19_->state = e->state;
		_tmp20_ = event;
		_tmp20_->is_hint = e->is_hint;
		_tmp21_ = event;
		_tmp22_ = e->device;
		_tmp21_->device = _tmp22_;
		_tmp23_ = event;
		_tmp24_ = e->axes;
		_tmp24__length1 = -1;
		_tmp23_->axes = _tmp24_;
		_tmp25_ = event;
		gdk_event_put ((GdkEvent*) _tmp25_);
	}
	result = TRUE;
	_g_object_unref0 (child);
	return result;
}

static gboolean
___lambda57__gtk_widget_motion_notify_event (GtkWidget* _sender,
                                             GdkEventMotion* event,
                                             gpointer self)
{
	gboolean result;
	result = __lambda57_ ((WidgetsWindowEventArea*) self, _sender, event);
	return result;
}

static GdkEventButton*
_vala_GdkEventButton_copy (GdkEventButton* self)
{
	return g_boxed_copy (gdk_event_get_type (), self);
}

static gpointer
__vala_GdkEventButton_copy0 (gpointer self)
{
	return self ? _vala_GdkEventButton_copy (self) : NULL;
}

static void
_vala_GdkEventButton_free (GdkEventButton* self)
{
	g_boxed_free (gdk_event_get_type (), self);
}

static Block52Data*
block52_data_ref (Block52Data* _data52_)
{
	g_atomic_int_inc (&_data52_->_ref_count_);
	return _data52_;
}

static void
block52_data_unref (void * _userdata_)
{
	Block52Data* _data52_;
	_data52_ = (Block52Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data52_->_ref_count_)) {
		WidgetsWindowEventArea* self;
		self = _data52_->self;
		__vala_GdkEventButton_free0 (_data52_->e);
		_g_object_unref0 (self);
		g_slice_free (Block52Data, _data52_);
	}
}

static gboolean
__lambda59_ (Block52Data* _data52_)
{
	WidgetsWindowEventArea* self;
	gboolean result;
	self = _data52_->self;
	if (self->is_press) {
		gint pointer_x = 0;
		gint pointer_y = 0;
		GdkDevice* _tmp0_;
		gint _tmp1_ = 0;
		gint _tmp2_ = 0;
		gboolean _tmp3_ = FALSE;
		_tmp0_ = _data52_->e->device;
		gdk_device_get_position (_tmp0_, NULL, &_tmp1_, &_tmp2_);
		pointer_x = _tmp1_;
		pointer_y = _tmp2_;
		if (((gdouble) pointer_x) != self->press_x) {
			_tmp3_ = TRUE;
		} else {
			_tmp3_ = ((gdouble) pointer_y) != self->press_y;
		}
		if (_tmp3_) {
			utils_move_window ((GtkWidget*) self, _data52_->e);
			result = FALSE;
			return result;
		} else {
			result = TRUE;
			return result;
		}
	} else {
		result = FALSE;
		return result;
	}
}

static gboolean
___lambda59__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda59_ (self);
	return result;
}

static gboolean
___lambda60_ (WidgetsWindowEventArea* self)
{
	gboolean result;
	self->is_double_clicked = FALSE;
	result = FALSE;
	return result;
}

static gboolean
____lambda60__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda60_ ((WidgetsWindowEventArea*) self);
	return result;
}

static gboolean
__lambda58_ (WidgetsWindowEventArea* self,
             GtkWidget* w,
             GdkEventButton* e)
{
	Block52Data* _data52_;
	GdkEventButton* _tmp0_;
	GdkDevice* _tmp1_;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	GtkWidget* child = NULL;
	GtkContainer* _tmp4_;
	GtkWidget* _tmp5_;
	GtkWidget* _tmp6_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	_data52_ = g_slice_new0 (Block52Data);
	_data52_->_ref_count_ = 1;
	_data52_->self = g_object_ref (self);
	_tmp0_ = __vala_GdkEventButton_copy0 (e);
	__vala_GdkEventButton_free0 (_data52_->e);
	_data52_->e = _tmp0_;
	self->is_press = TRUE;
	_tmp1_ = _data52_->e->device;
	gdk_device_get_position (_tmp1_, NULL, &_tmp2_, &_tmp3_);
	self->press_x = (gdouble) _tmp2_;
	self->press_y = (gdouble) _tmp3_;
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 10, ___lambda59__gsource_func, block52_data_ref (_data52_), block52_data_unref);
	_tmp4_ = self->drawing_area;
	_tmp5_ = widgets_window_event_area_get_child_at_pos (self, _tmp4_, (gint) _data52_->e->x, (gint) _data52_->e->y);
	child = _tmp5_;
	_tmp6_ = child;
	if (_tmp6_ != NULL) {
		gint x = 0;
		gint y = 0;
		GtkContainer* _tmp7_;
		GtkWidget* _tmp8_;
		gint _tmp9_ = 0;
		gint _tmp10_ = 0;
		GdkEventButton* event = NULL;
		GdkEvent* _tmp11_;
		GdkEventButton* _tmp12_;
		GtkWidget* _tmp13_;
		GdkWindow* _tmp14_;
		GdkEventButton* _tmp15_;
		GdkEventButton* _tmp16_;
		GdkEventButton* _tmp17_;
		GdkEventButton* _tmp18_;
		GdkEventButton* _tmp19_;
		GdkEventButton* _tmp20_;
		GdkEventButton* _tmp21_;
		GdkEventButton* _tmp22_;
		GdkDevice* _tmp23_;
		GdkEventButton* _tmp24_;
		GdkEventButton* _tmp25_;
		_tmp7_ = self->drawing_area;
		_tmp8_ = child;
		gtk_widget_translate_coordinates ((GtkWidget*) _tmp7_, _tmp8_, (gint) _data52_->e->x, (gint) _data52_->e->y, &_tmp9_, &_tmp10_);
		x = _tmp9_;
		y = _tmp10_;
		_tmp11_ = gdk_event_new (GDK_BUTTON_PRESS);
		event = (GdkEventButton*) _tmp11_;
		_tmp12_ = event;
		_tmp13_ = child;
		_tmp14_ = gtk_widget_get_window (_tmp13_);
		_tmp12_->window = _tmp14_;
		_tmp15_ = event;
		_tmp15_->send_event = (gint8) 1;
		_tmp16_ = event;
		_tmp16_->time = _data52_->e->time;
		_tmp17_ = event;
		_tmp17_->x = (gdouble) x;
		_tmp18_ = event;
		_tmp18_->y = (gdouble) y;
		_tmp19_ = event;
		_tmp19_->x_root = _data52_->e->x_root;
		_tmp20_ = event;
		_tmp20_->y_root = _data52_->e->y_root;
		_tmp21_ = event;
		_tmp21_->state = _data52_->e->state;
		_tmp22_ = event;
		_tmp23_ = _data52_->e->device;
		_tmp22_->device = _tmp23_;
		_tmp24_ = event;
		_tmp24_->button = _data52_->e->button;
		_tmp25_ = event;
		gdk_event_put ((GdkEvent*) _tmp25_);
	}
	if (_data52_->e->type == GDK_BUTTON_PRESS) {
		self->is_double_clicked = TRUE;
		g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) self->double_clicked_max_delay, ____lambda60__gsource_func, g_object_ref (self), g_object_unref);
	} else {
		if (_data52_->e->type == GDK_2BUTTON_PRESS) {
			gboolean _tmp26_ = FALSE;
			if (self->is_double_clicked) {
				_tmp26_ = utils_is_left_button (_data52_->e);
			} else {
				_tmp26_ = FALSE;
			}
			if (_tmp26_) {
				gboolean _tmp27_ = FALSE;
				WidgetsWindowEventAreaFilterDoubleClick _tmp28_;
				gpointer _tmp28__target;
				_tmp28_ = self->filter_double_click_callback;
				_tmp28__target = self->filter_double_click_callback_target;
				if (_tmp28_ == NULL) {
					_tmp27_ = TRUE;
				} else {
					WidgetsWindowEventAreaFilterDoubleClick _tmp29_;
					gpointer _tmp29__target;
					_tmp29_ = self->filter_double_click_callback;
					_tmp29__target = self->filter_double_click_callback_target;
					_tmp27_ = !_tmp29_ ((gint) _data52_->e->x, (gint) _data52_->e->y, _tmp29__target);
				}
				if (_tmp27_) {
					GtkWidget* _tmp30_;
					_tmp30_ = gtk_widget_get_toplevel ((GtkWidget*) self);
					if (g_type_is_a (G_TYPE_FROM_INSTANCE ((GObject*) _tmp30_), WIDGETS_TYPE_WINDOW)) {
						GtkWidget* _tmp31_;
						_tmp31_ = gtk_widget_get_toplevel ((GtkWidget*) self);
						widgets_window_toggle_max (G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, WIDGETS_TYPE_WINDOW, WidgetsWindow));
					}
				}
			}
		}
	}
	result = TRUE;
	_g_object_unref0 (child);
	block52_data_unref (_data52_);
	_data52_ = NULL;
	return result;
}

static gboolean
___lambda58__gtk_widget_button_press_event (GtkWidget* _sender,
                                            GdkEventButton* event,
                                            gpointer self)
{
	gboolean result;
	result = __lambda58_ ((WidgetsWindowEventArea*) self, _sender, event);
	return result;
}

static gboolean
__lambda225_ (WidgetsWindowEventArea* self,
              GtkWidget* w,
              GdkEventButton* e)
{
	GtkWidget* child = NULL;
	GtkContainer* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gboolean result;
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (e != NULL, FALSE);
	self->is_press = FALSE;
	_tmp0_ = self->drawing_area;
	_tmp1_ = widgets_window_event_area_get_child_at_pos (self, _tmp0_, (gint) e->x, (gint) e->y);
	child = _tmp1_;
	_tmp2_ = child;
	if (_tmp2_ != NULL) {
		gint x = 0;
		gint y = 0;
		GtkContainer* _tmp3_;
		GtkWidget* _tmp4_;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		GdkEventButton* event = NULL;
		GdkEvent* _tmp7_;
		GdkEventButton* _tmp8_;
		GtkWidget* _tmp9_;
		GdkWindow* _tmp10_;
		GdkEventButton* _tmp11_;
		GdkEventButton* _tmp12_;
		GdkEventButton* _tmp13_;
		GdkEventButton* _tmp14_;
		GdkEventButton* _tmp15_;
		GdkEventButton* _tmp16_;
		GdkEventButton* _tmp17_;
		GdkEventButton* _tmp18_;
		GdkDevice* _tmp19_;
		GdkEventButton* _tmp20_;
		GdkEventButton* _tmp21_;
		_tmp3_ = self->drawing_area;
		_tmp4_ = child;
		gtk_widget_translate_coordinates ((GtkWidget*) _tmp3_, _tmp4_, (gint) e->x, (gint) e->y, &_tmp5_, &_tmp6_);
		x = _tmp5_;
		y = _tmp6_;
		_tmp7_ = gdk_event_new (GDK_BUTTON_RELEASE);
		event = (GdkEventButton*) _tmp7_;
		_tmp8_ = event;
		_tmp9_ = child;
		_tmp10_ = gtk_widget_get_window (_tmp9_);
		_tmp8_->window = _tmp10_;
		_tmp11_ = event;
		_tmp11_->send_event = (gint8) 1;
		_tmp12_ = event;
		_tmp12_->time = e->time;
		_tmp13_ = event;
		_tmp13_->x = (gdouble) x;
		_tmp14_ = event;
		_tmp14_->y = (gdouble) y;
		_tmp15_ = event;
		_tmp15_->x_root = e->x_root;
		_tmp16_ = event;
		_tmp16_->y_root = e->y_root;
		_tmp17_ = event;
		_tmp17_->state = e->state;
		_tmp18_ = event;
		_tmp19_ = e->device;
		_tmp18_->device = _tmp19_;
		_tmp20_ = event;
		_tmp20_->button = e->button;
		_tmp21_ = event;
		gdk_event_put ((GdkEvent*) _tmp21_);
	}
	result = TRUE;
	_g_object_unref0 (child);
	return result;
}

static gboolean
___lambda225__gtk_widget_button_release_event (GtkWidget* _sender,
                                               GdkEventButton* event,
                                               gpointer self)
{
	gboolean result;
	result = __lambda225_ ((WidgetsWindowEventArea*) self, _sender, event);
	return result;
}

WidgetsWindowEventArea*
widgets_window_event_area_construct (GType object_type,
                                     GtkContainer* area)
{
	WidgetsWindowEventArea * self = NULL;
	GtkContainer* _tmp0_;
	g_return_val_if_fail (area != NULL, NULL);
	self = (WidgetsWindowEventArea*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (area);
	_g_object_unref0 (self->drawing_area);
	self->drawing_area = _tmp0_;
	gtk_event_box_set_visible_window ((GtkEventBox*) self, FALSE);
	gtk_widget_add_events ((GtkWidget*) self, (gint) (((GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK) | GDK_POINTER_MOTION_MASK) | GDK_LEAVE_NOTIFY_MASK));
	g_signal_connect_object ((GtkWidget*) self, "leave-notify-event", (GCallback) ___lambda56__gtk_widget_leave_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "motion-notify-event", (GCallback) ___lambda57__gtk_widget_motion_notify_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-press-event", (GCallback) ___lambda58__gtk_widget_button_press_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "button-release-event", (GCallback) ___lambda225__gtk_widget_button_release_event, self, 0);
	return self;
}

WidgetsWindowEventArea*
widgets_window_event_area_new (GtkContainer* area)
{
	return widgets_window_event_area_construct (WIDGETS_TYPE_WINDOW_EVENT_AREA, area);
}

GtkWidget*
widgets_window_event_area_get_child_at_pos (WidgetsWindowEventArea* self,
                                            GtkContainer* container,
                                            gint x,
                                            gint y)
{
	GList* _tmp0_;
	GList* _tmp1_;
	gboolean _tmp2_;
	GtkWidget* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (container != NULL, NULL);
	_tmp0_ = gtk_container_get_children (container);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_list_length (_tmp1_) > ((guint) 0);
	(_tmp1_ == NULL) ? NULL : (_tmp1_ = (g_list_free (_tmp1_), NULL));
	if (_tmp2_) {
		GList* _tmp3_;
		_tmp3_ = gtk_container_get_children (container);
		{
			GList* child_collection = NULL;
			GList* child_it = NULL;
			child_collection = _tmp3_;
			for (child_it = child_collection; child_it != NULL; child_it = child_it->next) {
				GtkWidget* _tmp4_;
				GtkWidget* child = NULL;
				_tmp4_ = _g_object_ref0 ((GtkWidget*) child_it->data);
				child = _tmp4_;
				{
					GtkAllocation child_rect = {0};
					GtkWidget* _tmp5_;
					GtkAllocation _tmp6_ = {0};
					gint child_x = 0;
					gint child_y = 0;
					GtkWidget* _tmp7_;
					gint _tmp8_ = 0;
					gint _tmp9_ = 0;
					gboolean _tmp10_ = FALSE;
					gboolean _tmp11_ = FALSE;
					gboolean _tmp12_ = FALSE;
					_tmp5_ = child;
					gtk_widget_get_allocation (_tmp5_, &_tmp6_);
					child_rect = _tmp6_;
					_tmp7_ = child;
					gtk_widget_translate_coordinates (_tmp7_, (GtkWidget*) container, 0, 0, &_tmp8_, &_tmp9_);
					child_x = _tmp8_;
					child_y = _tmp9_;
					if (x >= child_x) {
						GtkAllocation _tmp13_;
						_tmp13_ = child_rect;
						_tmp12_ = x <= (child_x + _tmp13_.width);
					} else {
						_tmp12_ = FALSE;
					}
					if (_tmp12_) {
						_tmp11_ = y >= child_y;
					} else {
						_tmp11_ = FALSE;
					}
					if (_tmp11_) {
						GtkAllocation _tmp14_;
						_tmp14_ = child_rect;
						_tmp10_ = y <= (child_y + _tmp14_.height);
					} else {
						_tmp10_ = FALSE;
					}
					if (_tmp10_) {
						GtkWidget* _tmp15_;
						_tmp15_ = child;
						if (g_type_is_a (G_TYPE_FROM_INSTANCE ((GObject*) _tmp15_), gtk_container_get_type ())) {
							GtkWidget* _tmp16_;
							GtkWidget* _tmp17_;
							_tmp16_ = child;
							_tmp17_ = widgets_window_event_area_get_child_at_pos (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_container_get_type (), GtkContainer), x - child_x, y - child_y);
							result = _tmp17_;
							_g_object_unref0 (child);
							(child_collection == NULL) ? NULL : (child_collection = (g_list_free (child_collection), NULL));
							return result;
						} else {
							result = child;
							(child_collection == NULL) ? NULL : (child_collection = (g_list_free (child_collection), NULL));
							return result;
						}
					}
					_g_object_unref0 (child);
				}
			}
			(child_collection == NULL) ? NULL : (child_collection = (g_list_free (child_collection), NULL));
		}
	}
	result = NULL;
	return result;
}

static void
widgets_window_event_area_class_init (WidgetsWindowEventAreaClass * klass,
                                      gpointer klass_data)
{
	widgets_window_event_area_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_window_event_area_finalize;
}

static void
widgets_window_event_area_instance_init (WidgetsWindowEventArea * self,
                                         gpointer klass)
{
	self->filter_double_click_callback = NULL;
	self->filter_double_click_callback_target = NULL;
	self->filter_double_click_callback_target_destroy_notify = NULL;
	self->is_double_clicked = FALSE;
	self->is_press = FALSE;
	self->press_x = (gdouble) 0;
	self->press_y = (gdouble) 0;
	self->double_clicked_max_delay = 150;
}

static void
widgets_window_event_area_finalize (GObject * obj)
{
	WidgetsWindowEventArea * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_WINDOW_EVENT_AREA, WidgetsWindowEventArea);
	(self->filter_double_click_callback_target_destroy_notify == NULL) ? NULL : (self->filter_double_click_callback_target_destroy_notify (self->filter_double_click_callback_target), NULL);
	self->filter_double_click_callback = NULL;
	self->filter_double_click_callback_target = NULL;
	self->filter_double_click_callback_target_destroy_notify = NULL;
	_g_object_unref0 (self->drawing_area);
	_g_object_unref0 (self->child_before_leave);
	G_OBJECT_CLASS (widgets_window_event_area_parent_class)->finalize (obj);
}

static GType
widgets_window_event_area_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsWindowEventAreaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_window_event_area_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsWindowEventArea), 0, (GInstanceInitFunc) widgets_window_event_area_instance_init, NULL };
	GType widgets_window_event_area_type_id;
	widgets_window_event_area_type_id = g_type_register_static (gtk_event_box_get_type (), "WidgetsWindowEventArea", &g_define_type_info, 0);
	return widgets_window_event_area_type_id;
}

GType
widgets_window_event_area_get_type (void)
{
	static volatile gsize widgets_window_event_area_type_id__once = 0;
	if (g_once_init_enter (&widgets_window_event_area_type_id__once)) {
		GType widgets_window_event_area_type_id;
		widgets_window_event_area_type_id = widgets_window_event_area_get_type_once ();
		g_once_init_leave (&widgets_window_event_area_type_id__once, widgets_window_event_area_type_id);
	}
	return widgets_window_event_area_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

