/* Utils.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from Utils.vala, do not modify */

/**/
/*  Copyright (C) 2012 Tom Beckmann, Rico Tzschichholz*/
/**/
/*  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*/
/*  (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, see <http://www.gnu.org/licenses/>.*/
/**/

#include "gala.h"
#include <gee.h>
#include <glib-object.h>
#include <meta/window.h>
#include <gio/gdesktopappinfo.h>
#include <glib.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xregion.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <meta/group.h>
#include <float.h>
#include <math.h>
#include <meta/workspace.h>
#include <meta/meta-window-actor.h>
#include <mtk/mtk.h>
#include <clutter/clutter.h>
#include <meta/meta-x11-display.h>
#include <meta/display.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/Xfixes.h>
#include <meta/prefs.h>
#include <gobject/gvaluecollector.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

typedef struct _Block5Data Block5Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _GalaParamSpecUtils GalaParamSpecUtils;

struct _Block5Data {
	int _ref_count_;
	GDesktopAppInfo* desktop_app;
};

struct _GalaParamSpecUtils {
	GParamSpec parent_instance;
};

static gpointer gala_utils_parent_class = NULL;
static GeeHashMap* gala_utils_window_to_desktop_cache;
static GeeHashMap* gala_utils_window_to_desktop_cache = NULL;
static GalaAppCache* gala_utils_app_cache;
static GalaAppCache* gala_utils_app_cache = NULL;
static GHashTable* gala_utils_regions;
static GHashTable* gala_utils_regions = NULL;
static gboolean* gala_utils_framebuffer_is_logical;
static gboolean* gala_utils_framebuffer_is_logical = NULL;

static void _g_object_unref0_ (gpointer var);
static void _g_free0_ (gpointer var);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static gboolean gala_utils_check_app_prefix (GDesktopAppInfo* app,
                                      const gchar* sandbox_id);
static GDesktopAppInfo* gala_utils_lookup_desktop_wmclass (const gchar* wm_class);
static GDesktopAppInfo* gala_utils_get_app_from_id (const gchar* id);
static void ____lambda10_ (Block5Data* _data5_,
                    MetaWindow* window);
static void _____lambda10__gfunc (gconstpointer data,
                           gpointer self);
static RECTANGLE* _rectangle_dup (RECTANGLE* self);
static gboolean* _bool_dup (gboolean* self);
static void _gala_utils___lambda11_ (void);
static void __gala_utils___lambda11__gala_app_cache_changed (GalaAppCache* _sender,
                                                      gpointer self);
static void gala_utils_finalize (GalaUtils * obj);
static GType gala_utils_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static void
_g_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_free (var), NULL));
}

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

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

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

static void
____lambda10_ (Block5Data* _data5_,
               MetaWindow* window)
{
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GDesktopAppInfo* _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (window != NULL);
	if (meta_window_get_window_type (window) != META_WINDOW_NORMAL) {
		return;
	}
	_tmp0_ = gala_utils_window_to_desktop_cache;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, window);
	_tmp2_ = (GDesktopAppInfo*) _tmp1_;
	_tmp3_ = _tmp2_ != NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		GeeHashMap* _tmp4_;
		gpointer _tmp5_;
		_tmp4_ = gala_utils_window_to_desktop_cache;
		_tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp4_, window);
		_g_object_unref0 (_data5_->desktop_app);
		_data5_->desktop_app = (GDesktopAppInfo*) _tmp5_;
	}
}

static void
_____lambda10__gfunc (gconstpointer data,
                      gpointer self)
{
	____lambda10_ (self, (MetaWindow*) data);
}

GIcon*
gala_utils_get_icon_for_window (MetaWindow* window)
{
	Block5Data* _data5_;
	MetaWindow* transient_for = NULL;
	MetaWindow* _tmp0_;
	MetaWindow* _tmp1_;
	MetaWindow* _tmp2_;
	GeeHashMap* _tmp5_;
	gpointer _tmp6_;
	GDesktopAppInfo* _tmp7_;
	gchar* sandbox_id = NULL;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* wm_instance = NULL;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	GalaAppCache* _tmp16_;
	const gchar* _tmp17_;
	GDesktopAppInfo* _tmp18_;
	gboolean _tmp19_ = FALSE;
	GDesktopAppInfo* _tmp20_;
	gchar* wm_class = NULL;
	const gchar* _tmp29_;
	gchar* _tmp30_;
	GalaAppCache* _tmp31_;
	const gchar* _tmp32_;
	GDesktopAppInfo* _tmp33_;
	gboolean _tmp34_ = FALSE;
	GDesktopAppInfo* _tmp35_;
	const gchar* _tmp44_;
	GDesktopAppInfo* _tmp45_;
	gboolean _tmp46_ = FALSE;
	GDesktopAppInfo* _tmp47_;
	const gchar* _tmp56_;
	GDesktopAppInfo* _tmp57_;
	gboolean _tmp58_ = FALSE;
	GDesktopAppInfo* _tmp59_;
	const gchar* _tmp68_;
	GDesktopAppInfo* _tmp69_;
	GDesktopAppInfo* _tmp70_;
	gchar* gapplication_id = NULL;
	const gchar* _tmp77_;
	gchar* _tmp78_;
	const gchar* _tmp79_;
	GDesktopAppInfo* _tmp80_;
	GDesktopAppInfo* _tmp81_;
	GThemedIcon* _tmp100_;
	GIcon* result;
	g_return_val_if_fail (window != NULL, NULL);
	_data5_ = g_slice_new0 (Block5Data);
	_data5_->_ref_count_ = 1;
	_tmp0_ = meta_window_get_transient_for (window);
	_tmp1_ = _g_object_ref0 (_tmp0_);
	transient_for = _tmp1_;
	_tmp2_ = transient_for;
	if (_tmp2_ != NULL) {
		MetaWindow* _tmp3_;
		GIcon* _tmp4_;
		_tmp3_ = transient_for;
		_tmp4_ = gala_utils_get_icon_for_window (_tmp3_);
		result = _tmp4_;
		_g_object_unref0 (transient_for);
		block5_data_unref (_data5_);
		_data5_ = NULL;
		return result;
	}
	_data5_->desktop_app = NULL;
	_tmp5_ = gala_utils_window_to_desktop_cache;
	_tmp6_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, window);
	_g_object_unref0 (_data5_->desktop_app);
	_data5_->desktop_app = (GDesktopAppInfo*) _tmp6_;
	_tmp7_ = _data5_->desktop_app;
	if (_tmp7_ != NULL) {
		GIcon* icon = NULL;
		GDesktopAppInfo* _tmp8_;
		GIcon* _tmp9_;
		GIcon* _tmp10_;
		GIcon* _tmp11_;
		_tmp8_ = _data5_->desktop_app;
		_tmp9_ = g_app_info_get_icon ((GAppInfo*) _tmp8_);
		_tmp10_ = _g_object_ref0 (_tmp9_);
		icon = _tmp10_;
		_tmp11_ = icon;
		if (_tmp11_ != NULL) {
			result = icon;
			_g_object_unref0 (transient_for);
			block5_data_unref (_data5_);
			_data5_ = NULL;
			return result;
		}
		_g_object_unref0 (icon);
	}
	_tmp12_ = meta_window_get_sandboxed_app_id (window);
	_tmp13_ = g_strdup (_tmp12_);
	sandbox_id = _tmp13_;
	_tmp14_ = meta_window_get_wm_class_instance (window);
	_tmp15_ = g_strdup (_tmp14_);
	wm_instance = _tmp15_;
	_tmp16_ = gala_utils_app_cache;
	_tmp17_ = wm_instance;
	_tmp18_ = gala_app_cache_lookup_startup_wmclass (_tmp16_, _tmp17_);
	_g_object_unref0 (_data5_->desktop_app);
	_data5_->desktop_app = _tmp18_;
	_tmp20_ = _data5_->desktop_app;
	if (_tmp20_ != NULL) {
		GDesktopAppInfo* _tmp21_;
		const gchar* _tmp22_;
		_tmp21_ = _data5_->desktop_app;
		_tmp22_ = sandbox_id;
		_tmp19_ = gala_utils_check_app_prefix (_tmp21_, _tmp22_);
	} else {
		_tmp19_ = FALSE;
	}
	if (_tmp19_) {
		GIcon* icon = NULL;
		GDesktopAppInfo* _tmp23_;
		GIcon* _tmp24_;
		GIcon* _tmp25_;
		GIcon* _tmp26_;
		_tmp23_ = _data5_->desktop_app;
		_tmp24_ = g_app_info_get_icon ((GAppInfo*) _tmp23_);
		_tmp25_ = _g_object_ref0 (_tmp24_);
		icon = _tmp25_;
		_tmp26_ = icon;
		if (_tmp26_ != NULL) {
			GeeHashMap* _tmp27_;
			GDesktopAppInfo* _tmp28_;
			_tmp27_ = gala_utils_window_to_desktop_cache;
			_tmp28_ = _data5_->desktop_app;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp27_, window, _tmp28_);
			result = icon;
			_g_free0 (wm_instance);
			_g_free0 (sandbox_id);
			_g_object_unref0 (transient_for);
			block5_data_unref (_data5_);
			_data5_ = NULL;
			return result;
		}
		_g_object_unref0 (icon);
	}
	_tmp29_ = meta_window_get_wm_class (window);
	_tmp30_ = g_strdup (_tmp29_);
	wm_class = _tmp30_;
	_tmp31_ = gala_utils_app_cache;
	_tmp32_ = wm_class;
	_tmp33_ = gala_app_cache_lookup_startup_wmclass (_tmp31_, _tmp32_);
	_g_object_unref0 (_data5_->desktop_app);
	_data5_->desktop_app = _tmp33_;
	_tmp35_ = _data5_->desktop_app;
	if (_tmp35_ != NULL) {
		GDesktopAppInfo* _tmp36_;
		const gchar* _tmp37_;
		_tmp36_ = _data5_->desktop_app;
		_tmp37_ = sandbox_id;
		_tmp34_ = gala_utils_check_app_prefix (_tmp36_, _tmp37_);
	} else {
		_tmp34_ = FALSE;
	}
	if (_tmp34_) {
		GIcon* icon = NULL;
		GDesktopAppInfo* _tmp38_;
		GIcon* _tmp39_;
		GIcon* _tmp40_;
		GIcon* _tmp41_;
		_tmp38_ = _data5_->desktop_app;
		_tmp39_ = g_app_info_get_icon ((GAppInfo*) _tmp38_);
		_tmp40_ = _g_object_ref0 (_tmp39_);
		icon = _tmp40_;
		_tmp41_ = icon;
		if (_tmp41_ != NULL) {
			GeeHashMap* _tmp42_;
			GDesktopAppInfo* _tmp43_;
			_tmp42_ = gala_utils_window_to_desktop_cache;
			_tmp43_ = _data5_->desktop_app;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp42_, window, _tmp43_);
			result = icon;
			_g_free0 (wm_class);
			_g_free0 (wm_instance);
			_g_free0 (sandbox_id);
			_g_object_unref0 (transient_for);
			block5_data_unref (_data5_);
			_data5_ = NULL;
			return result;
		}
		_g_object_unref0 (icon);
	}
	_tmp44_ = wm_instance;
	_tmp45_ = gala_utils_lookup_desktop_wmclass (_tmp44_);
	_g_object_unref0 (_data5_->desktop_app);
	_data5_->desktop_app = _tmp45_;
	_tmp47_ = _data5_->desktop_app;
	if (_tmp47_ != NULL) {
		GDesktopAppInfo* _tmp48_;
		const gchar* _tmp49_;
		_tmp48_ = _data5_->desktop_app;
		_tmp49_ = sandbox_id;
		_tmp46_ = gala_utils_check_app_prefix (_tmp48_, _tmp49_);
	} else {
		_tmp46_ = FALSE;
	}
	if (_tmp46_) {
		GIcon* icon = NULL;
		GDesktopAppInfo* _tmp50_;
		GIcon* _tmp51_;
		GIcon* _tmp52_;
		GIcon* _tmp53_;
		_tmp50_ = _data5_->desktop_app;
		_tmp51_ = g_app_info_get_icon ((GAppInfo*) _tmp50_);
		_tmp52_ = _g_object_ref0 (_tmp51_);
		icon = _tmp52_;
		_tmp53_ = icon;
		if (_tmp53_ != NULL) {
			GeeHashMap* _tmp54_;
			GDesktopAppInfo* _tmp55_;
			_tmp54_ = gala_utils_window_to_desktop_cache;
			_tmp55_ = _data5_->desktop_app;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp54_, window, _tmp55_);
			result = icon;
			_g_free0 (wm_class);
			_g_free0 (wm_instance);
			_g_free0 (sandbox_id);
			_g_object_unref0 (transient_for);
			block5_data_unref (_data5_);
			_data5_ = NULL;
			return result;
		}
		_g_object_unref0 (icon);
	}
	_tmp56_ = wm_class;
	_tmp57_ = gala_utils_lookup_desktop_wmclass (_tmp56_);
	_g_object_unref0 (_data5_->desktop_app);
	_data5_->desktop_app = _tmp57_;
	_tmp59_ = _data5_->desktop_app;
	if (_tmp59_ != NULL) {
		GDesktopAppInfo* _tmp60_;
		const gchar* _tmp61_;
		_tmp60_ = _data5_->desktop_app;
		_tmp61_ = sandbox_id;
		_tmp58_ = gala_utils_check_app_prefix (_tmp60_, _tmp61_);
	} else {
		_tmp58_ = FALSE;
	}
	if (_tmp58_) {
		GIcon* icon = NULL;
		GDesktopAppInfo* _tmp62_;
		GIcon* _tmp63_;
		GIcon* _tmp64_;
		GIcon* _tmp65_;
		_tmp62_ = _data5_->desktop_app;
		_tmp63_ = g_app_info_get_icon ((GAppInfo*) _tmp62_);
		_tmp64_ = _g_object_ref0 (_tmp63_);
		icon = _tmp64_;
		_tmp65_ = icon;
		if (_tmp65_ != NULL) {
			GeeHashMap* _tmp66_;
			GDesktopAppInfo* _tmp67_;
			_tmp66_ = gala_utils_window_to_desktop_cache;
			_tmp67_ = _data5_->desktop_app;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp66_, window, _tmp67_);
			result = icon;
			_g_free0 (wm_class);
			_g_free0 (wm_instance);
			_g_free0 (sandbox_id);
			_g_object_unref0 (transient_for);
			block5_data_unref (_data5_);
			_data5_ = NULL;
			return result;
		}
		_g_object_unref0 (icon);
	}
	_tmp68_ = sandbox_id;
	_tmp69_ = gala_utils_get_app_from_id (_tmp68_);
	_g_object_unref0 (_data5_->desktop_app);
	_data5_->desktop_app = _tmp69_;
	_tmp70_ = _data5_->desktop_app;
	if (_tmp70_ != NULL) {
		GIcon* icon = NULL;
		GDesktopAppInfo* _tmp71_;
		GIcon* _tmp72_;
		GIcon* _tmp73_;
		GIcon* _tmp74_;
		_tmp71_ = _data5_->desktop_app;
		_tmp72_ = g_app_info_get_icon ((GAppInfo*) _tmp71_);
		_tmp73_ = _g_object_ref0 (_tmp72_);
		icon = _tmp73_;
		_tmp74_ = icon;
		if (_tmp74_ != NULL) {
			GeeHashMap* _tmp75_;
			GDesktopAppInfo* _tmp76_;
			_tmp75_ = gala_utils_window_to_desktop_cache;
			_tmp76_ = _data5_->desktop_app;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp75_, window, _tmp76_);
			result = icon;
			_g_free0 (wm_class);
			_g_free0 (wm_instance);
			_g_free0 (sandbox_id);
			_g_object_unref0 (transient_for);
			block5_data_unref (_data5_);
			_data5_ = NULL;
			return result;
		}
		_g_object_unref0 (icon);
	}
	_tmp77_ = meta_window_get_gtk_application_id (window);
	_tmp78_ = g_strdup (_tmp77_);
	gapplication_id = _tmp78_;
	_tmp79_ = gapplication_id;
	_tmp80_ = gala_utils_get_app_from_id (_tmp79_);
	_g_object_unref0 (_data5_->desktop_app);
	_data5_->desktop_app = _tmp80_;
	_tmp81_ = _data5_->desktop_app;
	if (_tmp81_ != NULL) {
		GIcon* icon = NULL;
		GDesktopAppInfo* _tmp82_;
		GIcon* _tmp83_;
		GIcon* _tmp84_;
		GIcon* _tmp85_;
		_tmp82_ = _data5_->desktop_app;
		_tmp83_ = g_app_info_get_icon ((GAppInfo*) _tmp82_);
		_tmp84_ = _g_object_ref0 (_tmp83_);
		icon = _tmp84_;
		_tmp85_ = icon;
		if (_tmp85_ != NULL) {
			GeeHashMap* _tmp86_;
			GDesktopAppInfo* _tmp87_;
			_tmp86_ = gala_utils_window_to_desktop_cache;
			_tmp87_ = _data5_->desktop_app;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp86_, window, _tmp87_);
			result = icon;
			_g_free0 (gapplication_id);
			_g_free0 (wm_class);
			_g_free0 (wm_instance);
			_g_free0 (sandbox_id);
			_g_object_unref0 (transient_for);
			block5_data_unref (_data5_);
			_data5_ = NULL;
			return result;
		}
		_g_object_unref0 (icon);
	}
	if (meta_window_get_client_type (window) == META_WINDOW_CLIENT_TYPE_X11) {
		MetaGroup* group = NULL;
		MetaGroup* _tmp88_;
		MetaGroup* _tmp89_;
		_tmp88_ = meta_window_x11_get_group (window);
		group = _tmp88_;
		_tmp89_ = group;
		if (_tmp89_ != NULL) {
			GSList* group_windows = NULL;
			MetaGroup* _tmp90_;
			GSList* _tmp91_;
			GSList* _tmp92_;
			GDesktopAppInfo* _tmp93_;
			_tmp90_ = group;
			_tmp91_ = meta_group_list_windows (_tmp90_);
			group_windows = _tmp91_;
			_tmp92_ = group_windows;
			g_slist_foreach (_tmp92_, _____lambda10__gfunc, _data5_);
			_tmp93_ = _data5_->desktop_app;
			if (_tmp93_ != NULL) {
				GIcon* icon = NULL;
				GDesktopAppInfo* _tmp94_;
				GIcon* _tmp95_;
				GIcon* _tmp96_;
				GIcon* _tmp97_;
				_tmp94_ = _data5_->desktop_app;
				_tmp95_ = g_app_info_get_icon ((GAppInfo*) _tmp94_);
				_tmp96_ = _g_object_ref0 (_tmp95_);
				icon = _tmp96_;
				_tmp97_ = icon;
				if (_tmp97_ != NULL) {
					GeeHashMap* _tmp98_;
					GDesktopAppInfo* _tmp99_;
					_tmp98_ = gala_utils_window_to_desktop_cache;
					_tmp99_ = _data5_->desktop_app;
					gee_abstract_map_set ((GeeAbstractMap*) _tmp98_, window, _tmp99_);
					result = icon;
					(group_windows == NULL) ? NULL : (group_windows = (g_slist_free (group_windows), NULL));
					_g_free0 (gapplication_id);
					_g_free0 (wm_class);
					_g_free0 (wm_instance);
					_g_free0 (sandbox_id);
					_g_object_unref0 (transient_for);
					block5_data_unref (_data5_);
					_data5_ = NULL;
					return result;
				}
				_g_object_unref0 (icon);
			}
			(group_windows == NULL) ? NULL : (group_windows = (g_slist_free (group_windows), NULL));
		}
	}
	_tmp100_ = (GThemedIcon*) g_themed_icon_new ("application-default-icon");
	result = (GIcon*) _tmp100_;
	_g_free0 (gapplication_id);
	_g_free0 (wm_class);
	_g_free0 (wm_instance);
	_g_free0 (sandbox_id);
	_g_object_unref0 (transient_for);
	block5_data_unref (_data5_);
	_data5_ = NULL;
	return result;
}

static gboolean
gala_utils_check_app_prefix (GDesktopAppInfo* app,
                             const gchar* sandbox_id)
{
	gchar* prefix = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (app != NULL, FALSE);
	if (sandbox_id == NULL) {
		result = TRUE;
		return result;
	}
	_tmp0_ = g_strdup_printf ("%s.", sandbox_id);
	prefix = _tmp0_;
	_tmp1_ = g_app_info_get_id ((GAppInfo*) app);
	_tmp2_ = prefix;
	if (g_str_has_prefix (_tmp1_, _tmp2_)) {
		result = TRUE;
		_g_free0 (prefix);
		return result;
	}
	result = FALSE;
	_g_free0 (prefix);
	return result;
}

void
gala_utils_clear_window_cache (MetaWindow* window)
{
	GDesktopAppInfo* desktop = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GDesktopAppInfo* _tmp2_;
	g_return_if_fail (window != NULL);
	_tmp0_ = gala_utils_window_to_desktop_cache;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, window);
	desktop = (GDesktopAppInfo*) _tmp1_;
	_tmp2_ = desktop;
	if (_tmp2_ != NULL) {
		GeeHashMap* _tmp3_;
		_tmp3_ = gala_utils_window_to_desktop_cache;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp3_, window, NULL);
	}
	_g_object_unref0 (desktop);
}

static GDesktopAppInfo*
gala_utils_get_app_from_id (const gchar* id)
{
	gchar* desktop_file = NULL;
	gchar* _tmp0_;
	GalaAppCache* _tmp1_;
	const gchar* _tmp2_;
	GDesktopAppInfo* _tmp3_;
	GDesktopAppInfo* _tmp4_;
	GDesktopAppInfo* result;
	if (id == NULL) {
		result = NULL;
		return result;
	}
	_tmp0_ = g_strdup_printf ("%s.desktop", id);
	desktop_file = _tmp0_;
	_tmp1_ = gala_utils_app_cache;
	_tmp2_ = desktop_file;
	_tmp3_ = gala_app_cache_lookup_id (_tmp1_, _tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	result = _tmp4_;
	_g_free0 (desktop_file);
	return result;
}

static gchar*
string_delimit (const gchar* self,
                const gchar* delimiters,
                gchar new_delimiter)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (delimiters != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strdelimit (_result_, delimiters, new_delimiter);
	result = _result_;
	return result;
}

static GDesktopAppInfo*
gala_utils_lookup_desktop_wmclass (const gchar* wm_class)
{
	GDesktopAppInfo* desktop_info = NULL;
	GDesktopAppInfo* _tmp0_;
	GDesktopAppInfo* _tmp1_;
	gchar* canonicalized = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	GDesktopAppInfo* _tmp7_;
	GDesktopAppInfo* result;
	if (wm_class == NULL) {
		result = NULL;
		return result;
	}
	_tmp0_ = gala_utils_get_app_from_id (wm_class);
	desktop_info = _tmp0_;
	_tmp1_ = desktop_info;
	if (_tmp1_ != NULL) {
		result = desktop_info;
		return result;
	}
	_tmp2_ = g_ascii_strdown (wm_class, (gssize) -1);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_delimit (_tmp3_, " ", '-');
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	canonicalized = _tmp5_;
	_tmp6_ = canonicalized;
	_tmp7_ = gala_utils_get_app_from_id (_tmp6_);
	result = _tmp7_;
	_g_free0 (canonicalized);
	_g_object_unref0 (desktop_info);
	return result;
}

/**
         * Multiplies an integer by a floating scaling factor, and then
         * returns the result rounded to the nearest integer
         */
gint
gala_utils_scale_to_int (gint value,
                         gfloat scale_factor)
{
	gint result;
	result = (gint) round ((gdouble) (((gfloat) value) * scale_factor));
	return result;
}

/**
         * Get the number of toplevel windows on a workspace excluding those that are
         * on all workspaces.
         *
         * We need `exclude` here because on Meta.Workspace.window_removed
         * the windows gets removed from workspace's internal window list but not display's window list
         * which Meta.Workspace uses for Meta.Workspace.list_windows ().
         *
         * @param workspace The workspace on which to count the windows
         * @param exclude a window to not count
         *
         */
guint
gala_utils_get_n_windows (MetaWorkspace* workspace,
                          gboolean on_primary,
                          MetaWindow* exclude)
{
	gint n = 0;
	GList* _tmp0_;
	guint result;
	g_return_val_if_fail (workspace != NULL, 0U);
	n = 0;
	_tmp0_ = meta_workspace_list_windows (workspace);
	{
		GList* window_collection = NULL;
		GList* window_it = NULL;
		window_collection = _tmp0_;
		for (window_it = window_collection; window_it != NULL; window_it = window_it->next) {
			MetaWindow* window = NULL;
			window = (MetaWindow*) window_it->data;
			{
				gboolean _tmp1_ = FALSE;
				MetaWindow* _tmp2_;
				gboolean _tmp3_;
				gboolean _tmp4_;
				gboolean _tmp6_ = FALSE;
				MetaWindow* _tmp7_;
				_tmp2_ = window;
				g_object_get (_tmp2_, "on-all-workspaces", &_tmp3_, NULL);
				_tmp4_ = _tmp3_;
				if (_tmp4_) {
					_tmp1_ = TRUE;
				} else {
					MetaWindow* _tmp5_;
					_tmp5_ = window;
					_tmp1_ = _tmp5_ == exclude;
				}
				if (_tmp1_) {
					continue;
				}
				_tmp7_ = window;
				if (gala_utils_get_window_is_normal (_tmp7_)) {
					gboolean _tmp8_ = FALSE;
					if (!on_primary) {
						_tmp8_ = TRUE;
					} else {
						gboolean _tmp9_ = FALSE;
						if (on_primary) {
							MetaWindow* _tmp10_;
							_tmp10_ = window;
							_tmp9_ = meta_window_is_on_primary_monitor (_tmp10_);
						} else {
							_tmp9_ = FALSE;
						}
						_tmp8_ = _tmp9_;
					}
					_tmp6_ = _tmp8_;
				} else {
					_tmp6_ = FALSE;
				}
				if (_tmp6_) {
					gint _tmp11_;
					_tmp11_ = n;
					n = _tmp11_ + 1;
				}
			}
		}
		(window_collection == NULL) ? NULL : (window_collection = (g_list_free (window_collection), NULL));
	}
	result = (guint) n;
	return result;
}

/**
         * Creates an actor showing the current contents of the given WindowActor.
         *
         * @param actor      The actor from which to create a snapshot
         * @param inner_rect The inner (actually visible) rectangle of the window
         *
         * @return           A copy of the actor at that time or %NULL
         */
ClutterActor*
gala_utils_get_window_actor_snapshot (MetaWindowActor* actor,
                                      MtkRectangle* inner_rect)
{
	ClutterContent* content = NULL;
	ClutterContent* _tmp6_;
	ClutterActor* container = NULL;
	ClutterContent* _tmp7_;
	ClutterContent* _tmp8_;
	MtkRectangle _tmp9_;
	MtkRectangle _tmp10_;
	MtkRectangle _tmp11_;
	MtkRectangle _tmp12_;
	ClutterActor* _tmp13_ = NULL;
	GError* _inner_error0_ = NULL;
	ClutterActor* result;
	g_return_val_if_fail (actor != NULL, NULL);
	g_return_val_if_fail (inner_rect != NULL, NULL);
	{
		ClutterContent* _tmp0_ = NULL;
		MtkRectangle _tmp1_;
		ClutterContent* _tmp2_;
		ClutterContent* _tmp3_;
		_tmp1_ = *inner_rect;
		_tmp2_ = meta_window_actor_paint_to_content (actor, &_tmp1_, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (content);
		content = _tmp3_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		g_warning ("Utils.vala:241: Could not create window snapshot: %s", _tmp5_);
		result = NULL;
		_g_error_free0 (e);
		_g_object_unref0 (content);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (content);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp6_ = content;
	if (_tmp6_ == NULL) {
		g_warning ("Utils.vala:246: Could not create window snapshot");
		result = NULL;
		_g_object_unref0 (content);
		return result;
	}
	_tmp7_ = content;
	_tmp8_ = _g_object_ref0 (_tmp7_);
	_tmp9_ = *inner_rect;
	_tmp10_ = *inner_rect;
	_tmp11_ = *inner_rect;
	_tmp12_ = *inner_rect;
	_tmp13_ = clutter_actor_new ();
	clutter_actor_set_content (_tmp13_, _tmp8_);
	_g_object_unref0 (_tmp8_);
	clutter_actor_set_offscreen_redirect (_tmp13_, CLUTTER_OFFSCREEN_REDIRECT_ALWAYS);
	clutter_actor_set_x (_tmp13_, (gfloat) _tmp9_.x);
	clutter_actor_set_y (_tmp13_, (gfloat) _tmp10_.y);
	clutter_actor_set_width (_tmp13_, (gfloat) _tmp11_.width);
	clutter_actor_set_height (_tmp13_, (gfloat) _tmp12_.height);
	g_object_ref_sink (_tmp13_);
	container = _tmp13_;
	result = container;
	_g_object_unref0 (content);
	return result;
}

/**
         * Creates a new reactive ClutterActor at 36px with the resize pixbuf
         *
         * @return The resize button actor
         */
ClutterActor*
gala_utils_create_resize_button (gfloat monitor_scale)
{
	GalaIcon* _tmp0_;
	ClutterActor* result;
	_tmp0_ = gala_icon_new_from_resource (GALA_UTILS_BUTTON_SIZE, monitor_scale, "/org/pantheon/desktop/gala/buttons/resize.svg");
	g_object_ref_sink (_tmp0_);
	result = (ClutterActor*) _tmp0_;
	return result;
}

static RECTANGLE*
_rectangle_dup (RECTANGLE* self)
{
	RECTANGLE* dup;
	dup = g_new0 (RECTANGLE, 1);
	memcpy (dup, self, sizeof (RECTANGLE));
	return dup;
}

static gpointer
__rectangle_dup0 (gpointer self)
{
	return self ? _rectangle_dup (self) : NULL;
}

void
gala_utils_x11_set_window_pass_through (MetaWindow* window)
{
	MetaX11Display* x11_display = NULL;
	MetaDisplay* _tmp0_;
	MetaDisplay* _tmp1_;
	MetaX11Display* _tmp2_;
	Window x_window = 0;
	Display* xdisplay = NULL;
	Display* _tmp3_;
	gint count = 0;
	gint ordering = 0;
	GHashTable* _tmp4_;
	MetaWindow* _tmp5_;
	gint _tmp6_ = 0;
	gint _tmp7_ = 0;
	RECTANGLE* _tmp8_;
	RECTANGLE _tmp9_;
	RECTANGLE* _tmp10_;
	XRectangle rect = {0};
	XRectangle _tmp11_ = {0};
	XserverRegion region = {0};
	XRectangle* _tmp12_;
	XRectangle* _tmp13_;
	gint _tmp13__length1;
	XserverRegion _tmp14_;
	g_return_if_fail (window != NULL);
	_tmp0_ = meta_window_get_display (window);
	_tmp1_ = _tmp0_;
	_tmp2_ = meta_display_get_x11_display (_tmp1_);
	x11_display = _tmp2_;
	x_window = meta_x11_display_lookup_xwindow (x11_display, window);
	_tmp3_ = meta_x11_display_get_xdisplay (x11_display);
	xdisplay = _tmp3_;
	_tmp4_ = gala_utils_regions;
	_tmp5_ = _g_object_ref0 (window);
	_tmp8_ = XShapeGetRectangles (xdisplay, x_window, 2, &_tmp6_, &_tmp7_);
	count = _tmp6_;
	ordering = _tmp7_;
	_tmp9_ = _tmp8_[0];
	_tmp10_ = __rectangle_dup0 (&_tmp9_);
	g_hash_table_insert (_tmp4_, _tmp5_, _tmp10_);
	rect = _tmp11_;
	_tmp12_ = g_new0 (XRectangle, 1);
	_tmp12_[0] = rect;
	_tmp13_ = _tmp12_;
	_tmp13__length1 = 1;
	_tmp14_ = XFixesCreateRegion (xdisplay, _tmp13_, (gint) 1);
	_tmp13_ = (g_free (_tmp13_), NULL);
	region = _tmp14_;
	XFixesSetWindowShapeRegion (xdisplay, x_window, 2, 0, 0, region);
	XFixesDestroyRegion (xdisplay, region);
}

void
gala_utils_x11_unset_window_pass_through (MetaWindow* window,
                                          gboolean restore_previous_region)
{
	MetaX11Display* x11_display = NULL;
	MetaDisplay* _tmp0_;
	MetaDisplay* _tmp1_;
	MetaX11Display* _tmp2_;
	Window x_window = 0;
	MetaX11Display* _tmp3_;
	Display* xdisplay = NULL;
	MetaX11Display* _tmp4_;
	Display* _tmp5_;
	GHashTable* _tmp15_;
	g_return_if_fail (window != NULL);
	_tmp0_ = meta_window_get_display (window);
	_tmp1_ = _tmp0_;
	_tmp2_ = meta_display_get_x11_display (_tmp1_);
	x11_display = _tmp2_;
	_tmp3_ = x11_display;
	x_window = meta_x11_display_lookup_xwindow (_tmp3_, window);
	_tmp4_ = x11_display;
	_tmp5_ = meta_x11_display_get_xdisplay (_tmp4_);
	xdisplay = _tmp5_;
	if (restore_previous_region) {
		RECTANGLE* region = NULL;
		GHashTable* _tmp6_;
		gconstpointer _tmp7_;
		RECTANGLE* _tmp8_;
		RECTANGLE* _tmp9_;
		Display* _tmp10_;
		RECTANGLE* _tmp11_;
		RECTANGLE* _tmp12_;
		RECTANGLE* _tmp13_;
		gint _tmp13__length1;
		_tmp6_ = gala_utils_regions;
		_tmp7_ = g_hash_table_lookup (_tmp6_, window);
		_tmp8_ = __rectangle_dup0 ((RECTANGLE*) _tmp7_);
		region = _tmp8_;
		_tmp9_ = region;
		if (_tmp9_ == NULL) {
			g_debug ("Utils.vala:311: Cannot unset pass through: window not found.");
			_g_free0 (region);
			return;
		}
		_tmp10_ = xdisplay;
		_tmp11_ = region;
		_tmp12_ = g_new0 (RECTANGLE, 1);
		_tmp12_[0] = *_tmp11_;
		_tmp13_ = _tmp12_;
		_tmp13__length1 = 1;
		XShapeCombineRectangles (_tmp10_, x_window, 2, 0, 0, (XRectangle*) _tmp13_, (gint) 1, 0, 3);
		_tmp13_ = (g_free (_tmp13_), NULL);
		_g_free0 (region);
	} else {
		Display* _tmp14_;
		_tmp14_ = xdisplay;
		XFixesSetWindowShapeRegion (_tmp14_, x_window, 2, 0, 0, (XserverRegion) 0);
	}
	_tmp15_ = gala_utils_regions;
	g_hash_table_remove (_tmp15_, window);
}

/**
         * Utility that returns the given duration or 0 if animations are disabled.
         */
guint
gala_utils_get_animation_duration (guint duration)
{
	guint _tmp0_ = 0U;
	guint result;
	if (meta_prefs_get_gnome_animations ()) {
		_tmp0_ = duration;
	} else {
		_tmp0_ = (guint) 0;
	}
	result = _tmp0_;
	return result;
}

inline gboolean
gala_utils_get_window_is_normal (MetaWindow* window)
{
	MetaWindowType _tmp0_;
	MetaWindowType _tmp1_;
	gboolean result;
	g_return_val_if_fail (window != NULL, FALSE);
	_tmp0_ = meta_window_get_window_type (window);
	_tmp1_ = _tmp0_;
	switch (_tmp1_) {
		case META_WINDOW_NORMAL:
		case META_WINDOW_DIALOG:
		case META_WINDOW_MODAL_DIALOG:
		{
			result = TRUE;
			return result;
		}
		default:
		{
			result = FALSE;
			return result;
		}
	}
}

gint
gala_utils_calculate_button_size (gfloat monitor_scale)
{
	gint result;
	result = gala_utils_scale_to_int (GALA_UTILS_BUTTON_SIZE, monitor_scale);
	return result;
}

static gboolean*
_bool_dup (gboolean* self)
{
	gboolean* dup;
	dup = g_new0 (gboolean, 1);
	memcpy (dup, self, sizeof (gboolean));
	return dup;
}

static gpointer
__bool_dup0 (gpointer self)
{
	return self ? _bool_dup (self) : NULL;
}

gboolean
gala_utils_get_framebuffer_is_logical (void)
{
	gboolean* _tmp0_;
	gboolean _tmp2_;
	gboolean* _tmp3_;
	gchar** experimental_features = NULL;
	GSettings* _tmp4_;
	GSettings* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gint experimental_features_length1;
	gint _experimental_features_size_;
	gboolean* _tmp16_;
	gboolean result;
	_tmp0_ = gala_utils_framebuffer_is_logical;
	if (_tmp0_ != NULL) {
		gboolean* _tmp1_;
		_tmp1_ = gala_utils_framebuffer_is_logical;
		result = *_tmp1_;
		return result;
	}
	_tmp2_ = FALSE;
	_tmp3_ = __bool_dup0 (&_tmp2_);
	_g_free0 (gala_utils_framebuffer_is_logical);
	gala_utils_framebuffer_is_logical = _tmp3_;
	_tmp4_ = g_settings_new ("org.gnome.mutter");
	_tmp5_ = _tmp4_;
	_tmp7_ = _tmp6_ = g_settings_get_strv (_tmp5_, "experimental-features");
	_tmp8_ = _tmp7_;
	_tmp8__length1 = _vala_array_length (_tmp6_);
	_g_object_unref0 (_tmp5_);
	experimental_features = _tmp8_;
	experimental_features_length1 = _tmp8__length1;
	_experimental_features_size_ = experimental_features_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				gchar** _tmp11_;
				gint _tmp11__length1;
				gchar** _tmp12_;
				gint _tmp12__length1;
				const gchar* _tmp13_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = experimental_features;
				_tmp11__length1 = experimental_features_length1;
				if (!(i < _tmp11__length1)) {
					break;
				}
				_tmp12_ = experimental_features;
				_tmp12__length1 = experimental_features_length1;
				_tmp13_ = _tmp12_[i];
				if (g_strcmp0 (_tmp13_, "scale-monitor-framebuffer") == 0) {
					gboolean _tmp14_;
					gboolean* _tmp15_;
					_tmp14_ = TRUE;
					_tmp15_ = __bool_dup0 (&_tmp14_);
					_g_free0 (gala_utils_framebuffer_is_logical);
					gala_utils_framebuffer_is_logical = _tmp15_;
					break;
				}
			}
		}
	}
	_tmp16_ = gala_utils_framebuffer_is_logical;
	result = *_tmp16_;
	experimental_features = (_vala_array_free (experimental_features, experimental_features_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

gfloat
gala_utils_get_ui_scaling_factor (MetaDisplay* display,
                                  gint monitor_index)
{
	gfloat result;
	g_return_val_if_fail (display != NULL, 0.0F);
	if (gala_utils_get_framebuffer_is_logical ()) {
		result = 1.0f;
		return result;
	} else {
		result = meta_display_get_monitor_scale (display, monitor_index);
		return result;
	}
}

GalaUtils*
gala_utils_construct (GType object_type)
{
	GalaUtils* self = NULL;
	self = (GalaUtils*) g_type_create_instance (object_type);
	return self;
}

GalaUtils*
gala_utils_new (void)
{
	return gala_utils_construct (GALA_TYPE_UTILS);
}

static void
_gala_utils___lambda11_ (void)
{
	GeeHashMap* _tmp0_;
	_tmp0_ = gala_utils_window_to_desktop_cache;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp0_);
}

static void
__gala_utils___lambda11__gala_app_cache_changed (GalaAppCache* _sender,
                                                 gpointer self)
{
	_gala_utils___lambda11_ ();
}

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

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

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

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

static gchar*
gala_value_utils_collect_value (GValue* value,
                                guint n_collect_values,
                                GTypeCValue* collect_values,
                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		GalaUtils * 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 = gala_utils_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
gala_value_utils_lcopy_value (const GValue* value,
                              guint n_collect_values,
                              GTypeCValue* collect_values,
                              guint collect_flags)
{
	GalaUtils ** 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 = gala_utils_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
gala_param_spec_utils (const gchar* name,
                       const gchar* nick,
                       const gchar* blurb,
                       GType object_type,
                       GParamFlags flags)
{
	GalaParamSpecUtils* spec;
	g_return_val_if_fail (g_type_is_a (object_type, GALA_TYPE_UTILS), 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);
}

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

void
gala_value_set_utils (GValue* value,
                      gpointer v_object)
{
	GalaUtils * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GALA_TYPE_UTILS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GALA_TYPE_UTILS));
		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;
		gala_utils_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		gala_utils_unref (old);
	}
}

void
gala_value_take_utils (GValue* value,
                       gpointer v_object)
{
	GalaUtils * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GALA_TYPE_UTILS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GALA_TYPE_UTILS));
		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) {
		gala_utils_unref (old);
	}
}

static void
gala_utils_class_init (GalaUtilsClass * klass,
                       gpointer klass_data)
{
	GHashTable* _tmp0_;
	GeeHashMap* _tmp1_;
	GalaAppCache* _tmp2_;
	GalaAppCache* _tmp3_;
	gala_utils_parent_class = g_type_class_peek_parent (klass);
	((GalaUtilsClass *) klass)->finalize = gala_utils_finalize;
	_tmp0_ = g_hash_table_new_full (NULL, NULL, _g_object_unref0_, _g_free0_);
	gala_utils_regions = _tmp0_;
	_tmp1_ = gee_hash_map_new (meta_window_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_DESKTOP_APP_INFO, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (gala_utils_window_to_desktop_cache);
	gala_utils_window_to_desktop_cache = _tmp1_;
	_tmp2_ = gala_app_cache_new ();
	_g_object_unref0 (gala_utils_app_cache);
	gala_utils_app_cache = _tmp2_;
	_tmp3_ = gala_utils_app_cache;
	g_signal_connect (_tmp3_, "changed", (GCallback) __gala_utils___lambda11__gala_app_cache_changed, NULL);
}

static void
gala_utils_instance_init (GalaUtils * self,
                          gpointer klass)
{
	self->ref_count = 1;
}

static void
gala_utils_finalize (GalaUtils * obj)
{
	GalaUtils * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_UTILS, GalaUtils);
	g_signal_handlers_destroy (self);
}

 G_GNUC_NO_INLINE static GType
gala_utils_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { gala_value_utils_init, gala_value_utils_free_value, gala_value_utils_copy_value, gala_value_utils_peek_pointer, "p", gala_value_utils_collect_value, "p", gala_value_utils_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (GalaUtilsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_utils_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaUtils), 0, (GInstanceInitFunc) gala_utils_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 gala_utils_type_id;
	gala_utils_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GalaUtils", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return gala_utils_type_id;
}

GType
gala_utils_get_type (void)
{
	static gsize gala_utils_type_id__once = 0;
	if (g_once_init_enter (&gala_utils_type_id__once)) {
		GType gala_utils_type_id;
		gala_utils_type_id = gala_utils_get_type_once ();
		g_once_init_leave (&gala_utils_type_id__once, gala_utils_type_id);
	}
	return gala_utils_type_id__once;
}

gpointer
gala_utils_ref (gpointer instance)
{
	GalaUtils * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
gala_utils_unref (gpointer instance)
{
	GalaUtils * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		GALA_UTILS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

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

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

