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

/*
 * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel)
 *
 * 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 2 of the License, or (at your option) 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, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 */

#include "wingpanel-interface.h"
#include <meta/workspace.h>
#include <meta/window.h>
#include <glib.h>
#include <glib-object.h>
#include <meta/meta-workspace-manager.h>
#include <meta/display.h>
#include <meta/common.h>
#include <meta/boxes.h>

enum  {
	WINGPANEL_INTERFACE_FOCUS_MANAGER_0_PROPERTY,
	WINGPANEL_INTERFACE_FOCUS_MANAGER_NUM_PROPERTIES
};
static GParamSpec* wingpanel_interface_focus_manager_properties[WINGPANEL_INTERFACE_FOCUS_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block2Data Block2Data;

struct _WingpanelInterfaceFocusManagerPrivate {
	MetaWorkspace* current_workspace;
	MetaWindow* last_focused_window;
	MetaWindow* last_focused_dialog_window;
};

struct _Block2Data {
	int _ref_count_;
	WingpanelInterfaceFocusManager* self;
	MetaWindow* window;
	gint x;
	gint y;
};

static gint WingpanelInterfaceFocusManager_private_offset;
static gpointer wingpanel_interface_focus_manager_parent_class = NULL;
static WingpanelInterfaceFocusManager* wingpanel_interface_focus_manager_instance;
static WingpanelInterfaceFocusManager* wingpanel_interface_focus_manager_instance = NULL;

static void __lambda15_ (WingpanelInterfaceFocusManager* self);
static void wingpanel_interface_focus_manager_update_current_workspace (WingpanelInterfaceFocusManager* self);
static void ___lambda15__meta_workspace_manager_workspace_switched (MetaWorkspaceManager* _sender,
                                                             gint object,
                                                             gint p0,
                                                             MetaMotionDirection p1,
                                                             gpointer self);
static void wingpanel_interface_focus_manager_window_created (WingpanelInterfaceFocusManager* self,
                                                       MetaWindow* window);
static void _wingpanel_interface_focus_manager_window_created_meta_display_window_created (MetaDisplay* _sender,
                                                                                    MetaWindow* object,
                                                                                    gpointer self);
static void ___lambda16_ (WingpanelInterfaceFocusManager* self);
static void ____lambda16__meta_window_unmanaged (MetaWindow* _sender,
                                          gpointer self);
static void wingpanel_interface_focus_manager_window_focused (WingpanelInterfaceFocusManager* self,
                                                       MetaWindow* window);
static void _wingpanel_interface_focus_manager_window_focused_meta_window_focus (MetaWindow* _sender,
                                                                          gpointer self);
static void wingpanel_interface_focus_manager_window_unmanaged (WingpanelInterfaceFocusManager* self,
                                                         MetaWindow* window);
static void _wingpanel_interface_focus_manager_window_unmanaged_meta_window_unmanaged (MetaWindow* _sender,
                                                                                gpointer self);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static gboolean wingpanel_interface_focus_manager_get_can_grab_window (MetaWindow* window,
                                                                gint x,
                                                                gint y);
static void ___lambda17_ (Block2Data* _data2_,
                   MetaWindow* win);
static void ____lambda17__gfunc (gconstpointer data,
                          gpointer self);
static void wingpanel_interface_focus_manager_finalize (GObject * obj);
static GType wingpanel_interface_focus_manager_get_type_once (void);

static inline gpointer
wingpanel_interface_focus_manager_get_instance_private (WingpanelInterfaceFocusManager* self)
{
	return G_STRUCT_MEMBER_P (self, WingpanelInterfaceFocusManager_private_offset);
}

static void
__lambda15_ (WingpanelInterfaceFocusManager* self)
{
	wingpanel_interface_focus_manager_update_current_workspace (self);
}

static void
___lambda15__meta_workspace_manager_workspace_switched (MetaWorkspaceManager* _sender,
                                                        gint object,
                                                        gint p0,
                                                        MetaMotionDirection p1,
                                                        gpointer self)
{
	__lambda15_ ((WingpanelInterfaceFocusManager*) self);
}

WingpanelInterfaceFocusManager*
wingpanel_interface_focus_manager_construct (GType object_type)
{
	WingpanelInterfaceFocusManager * self = NULL;
	MetaWorkspaceManager* manager = NULL;
	MetaDisplay* _tmp0_;
	MetaWorkspaceManager* _tmp1_;
	self = (WingpanelInterfaceFocusManager*) g_object_new (object_type, NULL);
	_tmp0_ = wingpanel_interface_main_display;
	_tmp1_ = meta_display_get_workspace_manager (_tmp0_);
	manager = _tmp1_;
	g_signal_connect_object (manager, "workspace-switched", (GCallback) ___lambda15__meta_workspace_manager_workspace_switched, self, 0);
	wingpanel_interface_focus_manager_update_current_workspace (self);
	return self;
}

WingpanelInterfaceFocusManager*
wingpanel_interface_focus_manager_new (void)
{
	return wingpanel_interface_focus_manager_construct (WINGPANEL_INTERFACE_TYPE_FOCUS_MANAGER);
}

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

static void
_wingpanel_interface_focus_manager_window_created_meta_display_window_created (MetaDisplay* _sender,
                                                                               MetaWindow* object,
                                                                               gpointer self)
{
	wingpanel_interface_focus_manager_window_created ((WingpanelInterfaceFocusManager*) self, object);
}

void
wingpanel_interface_focus_manager_remember_focused_window (WingpanelInterfaceFocusManager* self)
{
	GList* windows = NULL;
	MetaWorkspace* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	MetaDisplay* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_workspace;
	_tmp1_ = meta_workspace_list_windows (_tmp0_);
	windows = _tmp1_;
	_tmp2_ = windows;
	{
		GList* window_collection = NULL;
		GList* window_it = NULL;
		window_collection = _tmp2_;
		for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
			MetaWindow* _tmp3_;
			MetaWindow* window = NULL;
			_tmp3_ = _g_object_ref0 ((MetaWindow*) window_it->data);
			window = _tmp3_;
			{
				MetaWindow* _tmp4_;
				MetaWindow* _tmp5_;
				_tmp4_ = window;
				wingpanel_interface_focus_manager_window_created (self, _tmp4_);
				_tmp5_ = window;
				if (meta_window_has_focus (_tmp5_)) {
					MetaWindow* _tmp6_;
					MetaWindow* _tmp7_;
					_tmp6_ = window;
					_tmp7_ = _g_object_ref0 (_tmp6_);
					_g_object_unref0 (self->priv->last_focused_window);
					self->priv->last_focused_window = _tmp7_;
				}
				_g_object_unref0 (window);
			}
		}
	}
	_tmp8_ = wingpanel_interface_main_display;
	g_signal_connect_object (_tmp8_, "window-created", (GCallback) _wingpanel_interface_focus_manager_window_created_meta_display_window_created, self, 0);
	(windows == NULL) ? NULL : (windows = (g_list_free (windows), NULL));
}

static void
___lambda16_ (WingpanelInterfaceFocusManager* self)
{
	_g_object_unref0 (self->priv->last_focused_dialog_window);
	self->priv->last_focused_dialog_window = NULL;
	wingpanel_interface_focus_manager_restore_focused_window (self);
}

static void
____lambda16__meta_window_unmanaged (MetaWindow* _sender,
                                     gpointer self)
{
	___lambda16_ ((WingpanelInterfaceFocusManager*) self);
}

static void
_wingpanel_interface_focus_manager_window_focused_meta_window_focus (MetaWindow* _sender,
                                                                     gpointer self)
{
	wingpanel_interface_focus_manager_window_focused ((WingpanelInterfaceFocusManager*) self, _sender);
}

static void
_wingpanel_interface_focus_manager_window_unmanaged_meta_window_unmanaged (MetaWindow* _sender,
                                                                           gpointer self)
{
	wingpanel_interface_focus_manager_window_unmanaged ((WingpanelInterfaceFocusManager*) self, _sender);
}

void
wingpanel_interface_focus_manager_restore_focused_window (WingpanelInterfaceFocusManager* self)
{
	MetaDisplay* display = NULL;
	MetaDisplay* _tmp0_;
	MetaDisplay* _tmp1_;
	MetaWindow* _tmp2_;
	GList* windows = NULL;
	MetaWorkspace* _tmp9_;
	GList* _tmp10_;
	GList* _tmp11_;
	MetaDisplay* _tmp17_;
	guint _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = wingpanel_interface_main_display;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	display = _tmp1_;
	_tmp2_ = self->priv->last_focused_dialog_window;
	if (_tmp2_ != NULL) {
		MetaWindow* _tmp3_;
		MetaDisplay* _tmp4_;
		MetaWindow* _tmp5_;
		_tmp3_ = self->priv->last_focused_dialog_window;
		_tmp4_ = display;
		meta_window_focus (_tmp3_, meta_display_get_current_time (_tmp4_));
		_tmp5_ = self->priv->last_focused_dialog_window;
		g_signal_connect_object (_tmp5_, "unmanaged", (GCallback) ____lambda16__meta_window_unmanaged, self, 0);
	} else {
		MetaWindow* _tmp6_;
		_tmp6_ = self->priv->last_focused_window;
		if (_tmp6_ != NULL) {
			MetaWindow* _tmp7_;
			MetaDisplay* _tmp8_;
			_tmp7_ = self->priv->last_focused_window;
			_tmp8_ = display;
			meta_window_focus (_tmp7_, meta_display_get_current_time (_tmp8_));
		}
	}
	_tmp9_ = self->priv->current_workspace;
	_tmp10_ = meta_workspace_list_windows (_tmp9_);
	windows = _tmp10_;
	_tmp11_ = windows;
	{
		GList* window_collection = NULL;
		GList* window_it = NULL;
		window_collection = _tmp11_;
		for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
			MetaWindow* _tmp12_;
			MetaWindow* window = NULL;
			_tmp12_ = _g_object_ref0 ((MetaWindow*) window_it->data);
			window = _tmp12_;
			{
				MetaWindow* _tmp13_;
				guint _tmp14_;
				MetaWindow* _tmp15_;
				guint _tmp16_;
				_tmp13_ = window;
				g_signal_parse_name ("focus", meta_window_get_type (), &_tmp14_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp13_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp14_, 0, NULL, (GCallback) _wingpanel_interface_focus_manager_window_focused_meta_window_focus, self);
				_tmp15_ = window;
				g_signal_parse_name ("unmanaged", meta_window_get_type (), &_tmp16_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp15_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp16_, 0, NULL, (GCallback) _wingpanel_interface_focus_manager_window_unmanaged_meta_window_unmanaged, self);
				_g_object_unref0 (window);
			}
		}
	}
	_tmp17_ = wingpanel_interface_main_display;
	g_signal_parse_name ("window-created", meta_display_get_type (), &_tmp18_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp17_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp18_, 0, NULL, (GCallback) _wingpanel_interface_focus_manager_window_created_meta_display_window_created, self);
	(windows == NULL) ? NULL : (windows = (g_list_free (windows), NULL));
	_g_object_unref0 (display);
}

static void
wingpanel_interface_focus_manager_window_created (WingpanelInterfaceFocusManager* self,
                                                  MetaWindow* window)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	g_signal_connect_object (window, "focus", (GCallback) _wingpanel_interface_focus_manager_window_focused_meta_window_focus, self, 0);
	g_signal_connect_object (window, "unmanaged", (GCallback) _wingpanel_interface_focus_manager_window_unmanaged_meta_window_unmanaged, self, 0);
}

static void
wingpanel_interface_focus_manager_window_focused (WingpanelInterfaceFocusManager* self,
                                                  MetaWindow* window)
{
	MetaWindowType _tmp0_;
	MetaWindowType _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	_tmp0_ = meta_window_get_window_type (window);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == META_WINDOW_DIALOG) {
		MetaWindow* _tmp2_;
		_tmp2_ = _g_object_ref0 (window);
		_g_object_unref0 (self->priv->last_focused_dialog_window);
		self->priv->last_focused_dialog_window = _tmp2_;
	} else {
		MetaWindowType _tmp3_;
		MetaWindowType _tmp4_;
		_tmp3_ = meta_window_get_window_type (window);
		_tmp4_ = _tmp3_;
		if (_tmp4_ != META_WINDOW_DOCK) {
			MetaWindow* _tmp5_;
			_tmp5_ = _g_object_ref0 (window);
			_g_object_unref0 (self->priv->last_focused_window);
			self->priv->last_focused_window = _tmp5_;
		}
	}
}

static void
wingpanel_interface_focus_manager_window_unmanaged (WingpanelInterfaceFocusManager* self,
                                                    MetaWindow* window)
{
	guint _tmp0_;
	guint _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (window != NULL);
	g_signal_parse_name ("focus", meta_window_get_type (), &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (window, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _wingpanel_interface_focus_manager_window_focused_meta_window_focus, self);
	g_signal_parse_name ("unmanaged", meta_window_get_type (), &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (window, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _wingpanel_interface_focus_manager_window_unmanaged_meta_window_unmanaged, self);
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		WingpanelInterfaceFocusManager* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->window);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static void
___lambda17_ (Block2Data* _data2_,
              MetaWindow* win)
{
	WingpanelInterfaceFocusManager* self;
	MetaWindow* _tmp0_;
	self = _data2_->self;
	g_return_if_fail (win != NULL);
	_tmp0_ = _data2_->window;
	if (_tmp0_ != NULL) {
		return;
	}
	if (wingpanel_interface_focus_manager_get_can_grab_window (win, _data2_->x, _data2_->y)) {
		MetaWindow* _tmp1_;
		_tmp1_ = _g_object_ref0 (win);
		_g_object_unref0 (_data2_->window);
		_data2_->window = _tmp1_;
	}
}

static void
____lambda17__gfunc (gconstpointer data,
                     gpointer self)
{
	___lambda17_ (self, (MetaWindow*) data);
}

gboolean
wingpanel_interface_focus_manager_begin_grab_focused_window (WingpanelInterfaceFocusManager* self,
                                                             gint x,
                                                             gint y,
                                                             gint button,
                                                             guint time,
                                                             guint state)
{
	Block2Data* _data2_;
	MetaDisplay* display = NULL;
	MetaDisplay* _tmp0_;
	MetaDisplay* _tmp1_;
	MetaDisplay* _tmp2_;
	MetaWindow* _tmp3_;
	MetaWindow* _tmp4_;
	gboolean _tmp5_ = FALSE;
	MetaWindow* _tmp6_;
	MetaWindow* _tmp17_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	_data2_->x = x;
	_data2_->y = y;
	_tmp0_ = wingpanel_interface_main_display;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	display = _tmp1_;
	_tmp2_ = display;
	_tmp3_ = meta_display_get_focus_window (_tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_data2_->window = _tmp4_;
	_tmp6_ = _data2_->window;
	if (_tmp6_ == NULL) {
		_tmp5_ = TRUE;
	} else {
		MetaWindow* _tmp7_;
		_tmp7_ = _data2_->window;
		_tmp5_ = !wingpanel_interface_focus_manager_get_can_grab_window (_tmp7_, _data2_->x, _data2_->y);
	}
	if (_tmp5_) {
		MetaWorkspace* workspace = NULL;
		MetaDisplay* _tmp8_;
		MetaWorkspaceManager* _tmp9_;
		MetaWorkspace* _tmp10_;
		GList* windows = NULL;
		MetaWorkspace* _tmp11_;
		GList* _tmp12_;
		GList* _tmp13_;
		GList* copy = NULL;
		GList* _tmp14_;
		GList* _tmp15_;
		GList* _tmp16_;
		_tmp8_ = display;
		_tmp9_ = meta_display_get_workspace_manager (_tmp8_);
		_tmp10_ = meta_workspace_manager_get_active_workspace (_tmp9_);
		workspace = _tmp10_;
		_tmp11_ = workspace;
		_tmp12_ = meta_workspace_list_windows (_tmp11_);
		windows = _tmp12_;
		_tmp13_ = windows;
		if (_tmp13_ == NULL) {
			result = FALSE;
			(windows == NULL) ? NULL : (windows = (g_list_free (windows), NULL));
			_g_object_unref0 (display);
			block2_data_unref (_data2_);
			_data2_ = NULL;
			return result;
		}
		_g_object_unref0 (_data2_->window);
		_data2_->window = NULL;
		_tmp14_ = windows;
		_tmp15_ = g_list_copy (_tmp14_);
		copy = _tmp15_;
		copy = g_list_reverse (copy);
		_tmp16_ = copy;
		g_list_foreach (_tmp16_, ____lambda17__gfunc, _data2_);
		(copy == NULL) ? NULL : (copy = (g_list_free (copy), NULL));
		(windows == NULL) ? NULL : (windows = (g_list_free (windows), NULL));
	}
	_tmp17_ = _data2_->window;
	if (_tmp17_ != NULL) {
		MetaDisplay* _tmp18_;
		MetaWindow* _tmp19_;
		_tmp18_ = display;
		_tmp19_ = _data2_->window;
		meta_display_begin_grab_op (_tmp18_, _tmp19_, META_GRAB_OP_MOVING, FALSE, TRUE, button, (gulong) state, (guint32) time, _data2_->x, _data2_->y);
		result = TRUE;
		_g_object_unref0 (display);
		block2_data_unref (_data2_);
		_data2_ = NULL;
		return result;
	}
	result = FALSE;
	_g_object_unref0 (display);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return result;
}

static gboolean
wingpanel_interface_focus_manager_get_can_grab_window (MetaWindow* window,
                                                       gint x,
                                                       gint y)
{
	MetaRectangle frame = {0};
	MetaRectangle _tmp0_ = {0};
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_;
	gboolean _tmp5_;
	gboolean result;
	g_return_val_if_fail (window != NULL, FALSE);
	meta_window_get_frame_rect (window, &_tmp0_);
	frame = _tmp0_;
	g_object_get (window, "minimized", &_tmp4_, NULL);
	_tmp5_ = _tmp4_;
	if (!_tmp5_) {
		gboolean _tmp6_;
		gboolean _tmp7_;
		g_object_get (window, "maximized-vertically", &_tmp6_, NULL);
		_tmp7_ = _tmp6_;
		_tmp3_ = _tmp7_;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		MetaRectangle _tmp8_;
		_tmp8_ = frame;
		_tmp2_ = x >= _tmp8_.x;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		MetaRectangle _tmp9_;
		MetaRectangle _tmp10_;
		_tmp9_ = frame;
		_tmp10_ = frame;
		_tmp1_ = x <= (_tmp9_.x + _tmp10_.width);
	} else {
		_tmp1_ = FALSE;
	}
	result = _tmp1_;
	return result;
}

static void
wingpanel_interface_focus_manager_update_current_workspace (WingpanelInterfaceFocusManager* self)
{
	MetaWorkspaceManager* manager = NULL;
	MetaDisplay* _tmp0_;
	MetaWorkspaceManager* _tmp1_;
	MetaWorkspace* workspace = NULL;
	MetaWorkspaceManager* _tmp2_;
	MetaWorkspaceManager* _tmp3_;
	MetaWorkspace* _tmp4_;
	MetaWorkspace* _tmp5_;
	MetaWorkspace* _tmp6_;
	MetaWorkspace* _tmp7_;
	MetaWorkspace* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = wingpanel_interface_main_display;
	_tmp1_ = meta_display_get_workspace_manager (_tmp0_);
	manager = _tmp1_;
	_tmp2_ = manager;
	_tmp3_ = manager;
	_tmp4_ = meta_workspace_manager_get_workspace_by_index (_tmp2_, meta_workspace_manager_get_active_workspace_index (_tmp3_));
	_tmp5_ = _g_object_ref0 (_tmp4_);
	workspace = _tmp5_;
	_tmp6_ = workspace;
	if (_tmp6_ == NULL) {
		g_warning ("FocusManager.vala:132: Cannot get active workspace");
		_g_object_unref0 (workspace);
		return;
	}
	_tmp7_ = workspace;
	_tmp8_ = _g_object_ref0 (_tmp7_);
	_g_object_unref0 (self->priv->current_workspace);
	self->priv->current_workspace = _tmp8_;
	_g_object_unref0 (workspace);
}

WingpanelInterfaceFocusManager*
wingpanel_interface_focus_manager_get_default (void)
{
	WingpanelInterfaceFocusManager* _tmp0_;
	WingpanelInterfaceFocusManager* _tmp2_;
	WingpanelInterfaceFocusManager* _tmp3_;
	WingpanelInterfaceFocusManager* result;
	_tmp0_ = wingpanel_interface_focus_manager_instance;
	if (_tmp0_ == NULL) {
		WingpanelInterfaceFocusManager* _tmp1_;
		_tmp1_ = wingpanel_interface_focus_manager_new ();
		_g_object_unref0 (wingpanel_interface_focus_manager_instance);
		wingpanel_interface_focus_manager_instance = _tmp1_;
	}
	_tmp2_ = wingpanel_interface_focus_manager_instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static void
wingpanel_interface_focus_manager_class_init (WingpanelInterfaceFocusManagerClass * klass,
                                              gpointer klass_data)
{
	wingpanel_interface_focus_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WingpanelInterfaceFocusManager_private_offset);
	G_OBJECT_CLASS (klass)->finalize = wingpanel_interface_focus_manager_finalize;
}

static void
wingpanel_interface_focus_manager_instance_init (WingpanelInterfaceFocusManager * self,
                                                 gpointer klass)
{
	self->priv = wingpanel_interface_focus_manager_get_instance_private (self);
	self->priv->current_workspace = NULL;
	self->priv->last_focused_window = NULL;
	self->priv->last_focused_dialog_window = NULL;
}

static void
wingpanel_interface_focus_manager_finalize (GObject * obj)
{
	WingpanelInterfaceFocusManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WINGPANEL_INTERFACE_TYPE_FOCUS_MANAGER, WingpanelInterfaceFocusManager);
	_g_object_unref0 (self->priv->current_workspace);
	_g_object_unref0 (self->priv->last_focused_window);
	_g_object_unref0 (self->priv->last_focused_dialog_window);
	G_OBJECT_CLASS (wingpanel_interface_focus_manager_parent_class)->finalize (obj);
}

static GType
wingpanel_interface_focus_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WingpanelInterfaceFocusManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wingpanel_interface_focus_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WingpanelInterfaceFocusManager), 0, (GInstanceInitFunc) wingpanel_interface_focus_manager_instance_init, NULL };
	GType wingpanel_interface_focus_manager_type_id;
	wingpanel_interface_focus_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "WingpanelInterfaceFocusManager", &g_define_type_info, 0);
	WingpanelInterfaceFocusManager_private_offset = g_type_add_instance_private (wingpanel_interface_focus_manager_type_id, sizeof (WingpanelInterfaceFocusManagerPrivate));
	return wingpanel_interface_focus_manager_type_id;
}

GType
wingpanel_interface_focus_manager_get_type (void)
{
	static volatile gsize wingpanel_interface_focus_manager_type_id__once = 0;
	if (g_once_init_enter (&wingpanel_interface_focus_manager_type_id__once)) {
		GType wingpanel_interface_focus_manager_type_id;
		wingpanel_interface_focus_manager_type_id = wingpanel_interface_focus_manager_get_type_once ();
		g_once_init_leave (&wingpanel_interface_focus_manager_type_id__once, wingpanel_interface_focus_manager_type_id);
	}
	return wingpanel_interface_focus_manager_type_id__once;
}

