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

/* SimpleFocusManager.vala
 *
 * Copyright 2020 Dylan McCall <dylan@dylanmccall.ca>
 *
 * 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/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "daemon.h"
#include <glib.h>
#include <glib-object.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

#define BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST (break_timer_daemon_util_simple_focus_manager_request_get_type ())
#define BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST, BreakTimerDaemonUtilSimpleFocusManagerRequest))
#define BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST, BreakTimerDaemonUtilSimpleFocusManagerRequestClass))
#define BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_IS_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST))
#define BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_IS_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST))
#define BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST, BreakTimerDaemonUtilSimpleFocusManagerRequestClass))

typedef struct _BreakTimerDaemonUtilSimpleFocusManagerRequest BreakTimerDaemonUtilSimpleFocusManagerRequest;
typedef struct _BreakTimerDaemonUtilSimpleFocusManagerRequestClass BreakTimerDaemonUtilSimpleFocusManagerRequestClass;
enum  {
	BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_0_PROPERTY,
	BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_NUM_PROPERTIES
};
static GParamSpec* break_timer_daemon_util_simple_focus_manager_properties[BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _BreakTimerDaemonUtilSimpleFocusManagerRequestPrivate BreakTimerDaemonUtilSimpleFocusManagerRequestPrivate;
enum  {
	BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_REQUEST_0_PROPERTY,
	BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_REQUEST_NUM_PROPERTIES
};
static GParamSpec* break_timer_daemon_util_simple_focus_manager_request_properties[BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_REQUEST_NUM_PROPERTIES];

struct _BreakTimerDaemonUtilSimpleFocusManagerPrivate {
	GSList* focus_requests;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* current_focus;
};

struct _BreakTimerDaemonUtilSimpleFocusManagerRequest {
	GObject parent_instance;
	BreakTimerDaemonUtilSimpleFocusManagerRequestPrivate * priv;
	BreakTimerDaemonUtilIFocusable* owner;
	BreakTimerDaemonUtilFocusPriority priority;
};

struct _BreakTimerDaemonUtilSimpleFocusManagerRequestClass {
	GObjectClass parent_class;
};

static gint BreakTimerDaemonUtilSimpleFocusManager_private_offset;
static gpointer break_timer_daemon_util_simple_focus_manager_parent_class = NULL;
static gpointer break_timer_daemon_util_simple_focus_manager_request_parent_class = NULL;

static GType break_timer_daemon_util_ifocusable_get_type_once (void);
static GType break_timer_daemon_util_simple_focus_manager_request_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static void _g_object_unref0_ (gpointer var);
static inline void _g_slist_free__g_object_unref0_ (GSList* self);
static void break_timer_daemon_util_simple_focus_manager_set_focus (BreakTimerDaemonUtilSimpleFocusManager* self,
                                                             BreakTimerDaemonUtilSimpleFocusManagerRequest* new_focus);
static void break_timer_daemon_util_simple_focus_manager_update_focus (BreakTimerDaemonUtilSimpleFocusManager* self);
static gboolean break_timer_daemon_util_simple_focus_manager_focus_requested (BreakTimerDaemonUtilSimpleFocusManager* self,
                                                                       BreakTimerDaemonUtilIFocusable* focusable);
static BreakTimerDaemonUtilSimpleFocusManagerRequest* break_timer_daemon_util_simple_focus_manager_request_new (void);
static BreakTimerDaemonUtilSimpleFocusManagerRequest* break_timer_daemon_util_simple_focus_manager_request_construct (GType object_type);
static gint break_timer_daemon_util_simple_focus_manager_request_priority_compare_func (BreakTimerDaemonUtilSimpleFocusManagerRequest* a,
                                                                                 BreakTimerDaemonUtilSimpleFocusManagerRequest* b);
static gint _break_timer_daemon_util_simple_focus_manager_request_priority_compare_func_gcompare_func (gconstpointer a,
                                                                                                gconstpointer b);
static void _break_timer_daemon_util_simple_focus_manager_update_focus_gsource_once_func (gpointer self);
static void break_timer_daemon_util_simple_focus_manager_request_finalize (GObject * obj);
static GType break_timer_daemon_util_simple_focus_manager_request_get_type_once (void);
static void break_timer_daemon_util_simple_focus_manager_finalize (GObject * obj);
static GType break_timer_daemon_util_simple_focus_manager_get_type_once (void);

void
break_timer_daemon_util_ifocusable_focus_started (BreakTimerDaemonUtilIFocusable* self)
{
	BreakTimerDaemonUtilIFocusableIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = BREAK_TIMER_DAEMON_UTIL_IFOCUSABLE_GET_INTERFACE (self);
	if (_iface_->focus_started) {
		_iface_->focus_started (self);
	}
}

void
break_timer_daemon_util_ifocusable_focus_stopped (BreakTimerDaemonUtilIFocusable* self)
{
	BreakTimerDaemonUtilIFocusableIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = BREAK_TIMER_DAEMON_UTIL_IFOCUSABLE_GET_INTERFACE (self);
	if (_iface_->focus_stopped) {
		_iface_->focus_stopped (self);
	}
}

static void
break_timer_daemon_util_ifocusable_default_init (BreakTimerDaemonUtilIFocusableIface * iface,
                                                 gpointer iface_data)
{
}

static GType
break_timer_daemon_util_ifocusable_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerDaemonUtilIFocusableIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_daemon_util_ifocusable_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType break_timer_daemon_util_ifocusable_type_id;
	break_timer_daemon_util_ifocusable_type_id = g_type_register_static (G_TYPE_INTERFACE, "BreakTimerDaemonUtilIFocusable", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (break_timer_daemon_util_ifocusable_type_id, G_TYPE_OBJECT);
	return break_timer_daemon_util_ifocusable_type_id;
}

GType
break_timer_daemon_util_ifocusable_get_type (void)
{
	static volatile gsize break_timer_daemon_util_ifocusable_type_id__once = 0;
	if (g_once_init_enter (&break_timer_daemon_util_ifocusable_type_id__once)) {
		GType break_timer_daemon_util_ifocusable_type_id;
		break_timer_daemon_util_ifocusable_type_id = break_timer_daemon_util_ifocusable_get_type_once ();
		g_once_init_leave (&break_timer_daemon_util_ifocusable_type_id__once, break_timer_daemon_util_ifocusable_type_id);
	}
	return break_timer_daemon_util_ifocusable_type_id__once;
}

static GType
break_timer_daemon_util_focus_priority_get_type_once (void)
{
	static const GEnumValue values[] = {{BREAK_TIMER_DAEMON_UTIL_FOCUS_PRIORITY_NONE, "BREAK_TIMER_DAEMON_UTIL_FOCUS_PRIORITY_NONE", "none"}, {BREAK_TIMER_DAEMON_UTIL_FOCUS_PRIORITY_LOW, "BREAK_TIMER_DAEMON_UTIL_FOCUS_PRIORITY_LOW", "low"}, {BREAK_TIMER_DAEMON_UTIL_FOCUS_PRIORITY_HIGH, "BREAK_TIMER_DAEMON_UTIL_FOCUS_PRIORITY_HIGH", "high"}, {0, NULL, NULL}};
	GType break_timer_daemon_util_focus_priority_type_id;
	break_timer_daemon_util_focus_priority_type_id = g_enum_register_static ("BreakTimerDaemonUtilFocusPriority", values);
	return break_timer_daemon_util_focus_priority_type_id;
}

GType
break_timer_daemon_util_focus_priority_get_type (void)
{
	static volatile gsize break_timer_daemon_util_focus_priority_type_id__once = 0;
	if (g_once_init_enter (&break_timer_daemon_util_focus_priority_type_id__once)) {
		GType break_timer_daemon_util_focus_priority_type_id;
		break_timer_daemon_util_focus_priority_type_id = break_timer_daemon_util_focus_priority_get_type_once ();
		g_once_init_leave (&break_timer_daemon_util_focus_priority_type_id__once, break_timer_daemon_util_focus_priority_type_id);
	}
	return break_timer_daemon_util_focus_priority_type_id__once;
}

static inline gpointer
break_timer_daemon_util_simple_focus_manager_get_instance_private (BreakTimerDaemonUtilSimpleFocusManager* self)
{
	return G_STRUCT_MEMBER_P (self, BreakTimerDaemonUtilSimpleFocusManager_private_offset);
}

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

static inline void
_g_slist_free__g_object_unref0_ (GSList* self)
{
	g_slist_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

BreakTimerDaemonUtilSimpleFocusManager*
break_timer_daemon_util_simple_focus_manager_construct (GType object_type)
{
	BreakTimerDaemonUtilSimpleFocusManager * self = NULL;
	self = (BreakTimerDaemonUtilSimpleFocusManager*) g_object_new (object_type, NULL);
	(self->priv->focus_requests == NULL) ? NULL : (self->priv->focus_requests = (_g_slist_free__g_object_unref0_ (self->priv->focus_requests), NULL));
	self->priv->focus_requests = NULL;
	_g_object_unref0 (self->priv->current_focus);
	self->priv->current_focus = NULL;
	return self;
}

BreakTimerDaemonUtilSimpleFocusManager*
break_timer_daemon_util_simple_focus_manager_new (void)
{
	return break_timer_daemon_util_simple_focus_manager_construct (BREAK_TIMER_DAEMON_UTIL_TYPE_SIMPLE_FOCUS_MANAGER);
}

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

static void
break_timer_daemon_util_simple_focus_manager_set_focus (BreakTimerDaemonUtilSimpleFocusManager* self,
                                                        BreakTimerDaemonUtilSimpleFocusManagerRequest* new_focus)
{
	BreakTimerDaemonUtilSimpleFocusManagerRequest* old_focus = NULL;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp0_;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp1_;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->current_focus;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	old_focus = _tmp1_;
	_tmp2_ = old_focus;
	if (new_focus != _tmp2_) {
		BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp3_;
		BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp5_;
		_tmp3_ = _g_object_ref0 (new_focus);
		_g_object_unref0 (self->priv->current_focus);
		self->priv->current_focus = _tmp3_;
		if (new_focus != NULL) {
			BreakTimerDaemonUtilIFocusable* _tmp4_;
			_tmp4_ = new_focus->owner;
			break_timer_daemon_util_ifocusable_focus_started (_tmp4_);
		}
		_tmp5_ = old_focus;
		if (_tmp5_ != NULL) {
			BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp6_;
			BreakTimerDaemonUtilIFocusable* _tmp7_;
			_tmp6_ = old_focus;
			_tmp7_ = _tmp6_->owner;
			break_timer_daemon_util_ifocusable_focus_stopped (_tmp7_);
		}
	}
	_g_object_unref0 (old_focus);
}

static void
break_timer_daemon_util_simple_focus_manager_update_focus (BreakTimerDaemonUtilSimpleFocusManager* self)
{
	BreakTimerDaemonUtilSimpleFocusManagerRequest* new_focus = NULL;
	GSList* _tmp0_;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp5_;
	g_return_if_fail (self != NULL);
	new_focus = NULL;
	_tmp0_ = self->priv->focus_requests;
	if (g_slist_length (_tmp0_) > ((guint) 0)) {
		GSList* _tmp1_;
		GSList* _tmp2_;
		gconstpointer _tmp3_;
		BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp4_;
		_tmp1_ = self->priv->focus_requests;
		_tmp2_ = g_slist_last (_tmp1_);
		_tmp3_ = _tmp2_->data;
		_tmp4_ = _g_object_ref0 ((BreakTimerDaemonUtilSimpleFocusManagerRequest*) _tmp3_);
		_g_object_unref0 (new_focus);
		new_focus = _tmp4_;
	}
	_tmp5_ = new_focus;
	break_timer_daemon_util_simple_focus_manager_set_focus (self, _tmp5_);
	_g_object_unref0 (new_focus);
}

static gboolean
break_timer_daemon_util_simple_focus_manager_focus_requested (BreakTimerDaemonUtilSimpleFocusManager* self,
                                                              BreakTimerDaemonUtilIFocusable* focusable)
{
	GSList* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (focusable != NULL, FALSE);
	_tmp0_ = self->priv->focus_requests;
	{
		GSList* request_collection = NULL;
		GSList* request_it = NULL;
		request_collection = _tmp0_;
		for (request_it = request_collection; request_it != NULL; request_it = request_it->next) {
			BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp1_;
			BreakTimerDaemonUtilSimpleFocusManagerRequest* request = NULL;
			_tmp1_ = _g_object_ref0 ((BreakTimerDaemonUtilSimpleFocusManagerRequest*) request_it->data);
			request = _tmp1_;
			{
				BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp2_;
				BreakTimerDaemonUtilIFocusable* _tmp3_;
				_tmp2_ = request;
				_tmp3_ = _tmp2_->owner;
				if (_tmp3_ == focusable) {
					result = TRUE;
					_g_object_unref0 (request);
					return result;
				}
				_g_object_unref0 (request);
			}
		}
	}
	result = FALSE;
	return result;
}

static gint
_break_timer_daemon_util_simple_focus_manager_request_priority_compare_func_gcompare_func (gconstpointer a,
                                                                                           gconstpointer b)
{
	gint result;
	result = break_timer_daemon_util_simple_focus_manager_request_priority_compare_func ((BreakTimerDaemonUtilSimpleFocusManagerRequest*) a, (BreakTimerDaemonUtilSimpleFocusManagerRequest*) b);
	return result;
}

static void
_break_timer_daemon_util_simple_focus_manager_update_focus_gsource_once_func (gpointer self)
{
	break_timer_daemon_util_simple_focus_manager_update_focus ((BreakTimerDaemonUtilSimpleFocusManager*) self);
	g_object_unref (self);
}

void
break_timer_daemon_util_simple_focus_manager_request_focus (BreakTimerDaemonUtilSimpleFocusManager* self,
                                                            BreakTimerDaemonUtilIFocusable* focusable,
                                                            BreakTimerDaemonUtilFocusPriority priority)
{
	BreakTimerDaemonUtilSimpleFocusManagerRequest* request = NULL;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp0_;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp1_;
	BreakTimerDaemonUtilIFocusable* _tmp2_;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp3_;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp4_;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (focusable != NULL);
	if (break_timer_daemon_util_simple_focus_manager_focus_requested (self, focusable)) {
		return;
	}
	_tmp0_ = break_timer_daemon_util_simple_focus_manager_request_new ();
	request = _tmp0_;
	_tmp1_ = request;
	_tmp2_ = _g_object_ref0 (focusable);
	_g_object_unref0 (_tmp1_->owner);
	_tmp1_->owner = _tmp2_;
	_tmp3_ = request;
	_tmp3_->priority = priority;
	_tmp4_ = request;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	self->priv->focus_requests = g_slist_insert_sorted (self->priv->focus_requests, _tmp5_, _break_timer_daemon_util_simple_focus_manager_request_priority_compare_func_gcompare_func);
	g_idle_add_once (_break_timer_daemon_util_simple_focus_manager_update_focus_gsource_once_func, g_object_ref (self));
	_g_object_unref0 (request);
}

static GSList*
vala_g_slist_remove_full (GSList* self,
                          gconstpointer data,
                          GFreeFunc func)
{
	GSList* l = NULL;
	GSList* result;
	l = self;
	while (TRUE) {
		GSList* _tmp0_;
		GSList* _tmp1_;
		gconstpointer _tmp2_;
		_tmp0_ = l;
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = l;
		_tmp2_ = ((GSList*) _tmp1_)->data;
		if (_tmp2_ != data) {
			GSList* _tmp3_;
			GSList* _tmp4_;
			_tmp3_ = l;
			_tmp4_ = ((GSList*) _tmp3_)->next;
			l = _tmp4_;
		} else {
			GSList* _tmp5_;
			gconstpointer _tmp6_;
			GSList* _tmp7_;
			_tmp5_ = l;
			_tmp6_ = ((GSList*) _tmp5_)->data;
			func (_tmp6_);
			_tmp7_ = l;
			self = g_slist_delete_link (self, (GSList*) _tmp7_);
			break;
		}
	}
	result = self;
	return result;
}

void
break_timer_daemon_util_simple_focus_manager_release_focus (BreakTimerDaemonUtilSimpleFocusManager* self,
                                                            BreakTimerDaemonUtilIFocusable* focusable)
{
	GSList* _tmp0_;
	GSList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (focusable != NULL);
	_tmp0_ = self->priv->focus_requests;
	_tmp1_ = g_slist_copy (_tmp0_);
	{
		GSList* request_collection = NULL;
		GSList* request_it = NULL;
		request_collection = _tmp1_;
		for (request_it = request_collection; request_it != NULL; request_it = request_it->next) {
			BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp2_;
			BreakTimerDaemonUtilSimpleFocusManagerRequest* request = NULL;
			_tmp2_ = _g_object_ref0 ((BreakTimerDaemonUtilSimpleFocusManagerRequest*) request_it->data);
			request = _tmp2_;
			{
				BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp3_;
				BreakTimerDaemonUtilIFocusable* _tmp4_;
				_tmp3_ = request;
				_tmp4_ = _tmp3_->owner;
				if (_tmp4_ == focusable) {
					BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp5_;
					_tmp5_ = request;
					self->priv->focus_requests = vala_g_slist_remove_full (self->priv->focus_requests, _tmp5_, _g_object_unref0_);
				}
				_g_object_unref0 (request);
			}
		}
		(request_collection == NULL) ? NULL : (request_collection = (g_slist_free (request_collection), NULL));
	}
	g_idle_add_once (_break_timer_daemon_util_simple_focus_manager_update_focus_gsource_once_func, g_object_ref (self));
}

gboolean
break_timer_daemon_util_simple_focus_manager_is_focusing (BreakTimerDaemonUtilSimpleFocusManager* self,
                                                          BreakTimerDaemonUtilIFocusable* focusable)
{
	gboolean _tmp0_ = FALSE;
	BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (focusable != NULL, FALSE);
	_tmp1_ = self->priv->current_focus;
	if (_tmp1_ != NULL) {
		BreakTimerDaemonUtilSimpleFocusManagerRequest* _tmp2_;
		BreakTimerDaemonUtilIFocusable* _tmp3_;
		_tmp2_ = self->priv->current_focus;
		_tmp3_ = _tmp2_->owner;
		_tmp0_ = _tmp3_ == focusable;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gint
break_timer_daemon_util_simple_focus_manager_request_priority_compare_func (BreakTimerDaemonUtilSimpleFocusManagerRequest* a,
                                                                            BreakTimerDaemonUtilSimpleFocusManagerRequest* b)
{
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	if (a->priority < b->priority) {
		result = -1;
		return result;
	} else {
		if (a->priority == b->priority) {
			result = 0;
			return result;
		} else {
			result = 1;
			return result;
		}
	}
}

static BreakTimerDaemonUtilSimpleFocusManagerRequest*
break_timer_daemon_util_simple_focus_manager_request_construct (GType object_type)
{
	BreakTimerDaemonUtilSimpleFocusManagerRequest * self = NULL;
	self = (BreakTimerDaemonUtilSimpleFocusManagerRequest*) g_object_new (object_type, NULL);
	return self;
}

static BreakTimerDaemonUtilSimpleFocusManagerRequest*
break_timer_daemon_util_simple_focus_manager_request_new (void)
{
	return break_timer_daemon_util_simple_focus_manager_request_construct (BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST);
}

static void
break_timer_daemon_util_simple_focus_manager_request_class_init (BreakTimerDaemonUtilSimpleFocusManagerRequestClass * klass,
                                                                 gpointer klass_data)
{
	break_timer_daemon_util_simple_focus_manager_request_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = break_timer_daemon_util_simple_focus_manager_request_finalize;
}

static void
break_timer_daemon_util_simple_focus_manager_request_instance_init (BreakTimerDaemonUtilSimpleFocusManagerRequest * self,
                                                                    gpointer klass)
{
}

static void
break_timer_daemon_util_simple_focus_manager_request_finalize (GObject * obj)
{
	BreakTimerDaemonUtilSimpleFocusManagerRequest * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BREAK_TIMER_DAEMON_UTIL_SIMPLE_FOCUS_MANAGER_TYPE_REQUEST, BreakTimerDaemonUtilSimpleFocusManagerRequest);
	_g_object_unref0 (self->owner);
	G_OBJECT_CLASS (break_timer_daemon_util_simple_focus_manager_request_parent_class)->finalize (obj);
}

static GType
break_timer_daemon_util_simple_focus_manager_request_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerDaemonUtilSimpleFocusManagerRequestClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_daemon_util_simple_focus_manager_request_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BreakTimerDaemonUtilSimpleFocusManagerRequest), 0, (GInstanceInitFunc) break_timer_daemon_util_simple_focus_manager_request_instance_init, NULL };
	GType break_timer_daemon_util_simple_focus_manager_request_type_id;
	break_timer_daemon_util_simple_focus_manager_request_type_id = g_type_register_static (G_TYPE_OBJECT, "BreakTimerDaemonUtilSimpleFocusManagerRequest", &g_define_type_info, 0);
	return break_timer_daemon_util_simple_focus_manager_request_type_id;
}

static GType
break_timer_daemon_util_simple_focus_manager_request_get_type (void)
{
	static volatile gsize break_timer_daemon_util_simple_focus_manager_request_type_id__once = 0;
	if (g_once_init_enter (&break_timer_daemon_util_simple_focus_manager_request_type_id__once)) {
		GType break_timer_daemon_util_simple_focus_manager_request_type_id;
		break_timer_daemon_util_simple_focus_manager_request_type_id = break_timer_daemon_util_simple_focus_manager_request_get_type_once ();
		g_once_init_leave (&break_timer_daemon_util_simple_focus_manager_request_type_id__once, break_timer_daemon_util_simple_focus_manager_request_type_id);
	}
	return break_timer_daemon_util_simple_focus_manager_request_type_id__once;
}

static void
break_timer_daemon_util_simple_focus_manager_class_init (BreakTimerDaemonUtilSimpleFocusManagerClass * klass,
                                                         gpointer klass_data)
{
	break_timer_daemon_util_simple_focus_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BreakTimerDaemonUtilSimpleFocusManager_private_offset);
	G_OBJECT_CLASS (klass)->finalize = break_timer_daemon_util_simple_focus_manager_finalize;
}

static void
break_timer_daemon_util_simple_focus_manager_instance_init (BreakTimerDaemonUtilSimpleFocusManager * self,
                                                            gpointer klass)
{
	self->priv = break_timer_daemon_util_simple_focus_manager_get_instance_private (self);
}

static void
break_timer_daemon_util_simple_focus_manager_finalize (GObject * obj)
{
	BreakTimerDaemonUtilSimpleFocusManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BREAK_TIMER_DAEMON_UTIL_TYPE_SIMPLE_FOCUS_MANAGER, BreakTimerDaemonUtilSimpleFocusManager);
	(self->priv->focus_requests == NULL) ? NULL : (self->priv->focus_requests = (_g_slist_free__g_object_unref0_ (self->priv->focus_requests), NULL));
	_g_object_unref0 (self->priv->current_focus);
	G_OBJECT_CLASS (break_timer_daemon_util_simple_focus_manager_parent_class)->finalize (obj);
}

/**
 * Keeps track of focus requests, ensuring that only a single Focusable object
 * will have focus at a given time. Any object that implements the IFocusable
 * interface may request focus, and the most recent request with the highest
 * priority will be given focus. Focus can change at any time as other objects
 * request or release focus.
 */
static GType
break_timer_daemon_util_simple_focus_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerDaemonUtilSimpleFocusManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_daemon_util_simple_focus_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BreakTimerDaemonUtilSimpleFocusManager), 0, (GInstanceInitFunc) break_timer_daemon_util_simple_focus_manager_instance_init, NULL };
	GType break_timer_daemon_util_simple_focus_manager_type_id;
	break_timer_daemon_util_simple_focus_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "BreakTimerDaemonUtilSimpleFocusManager", &g_define_type_info, 0);
	BreakTimerDaemonUtilSimpleFocusManager_private_offset = g_type_add_instance_private (break_timer_daemon_util_simple_focus_manager_type_id, sizeof (BreakTimerDaemonUtilSimpleFocusManagerPrivate));
	return break_timer_daemon_util_simple_focus_manager_type_id;
}

GType
break_timer_daemon_util_simple_focus_manager_get_type (void)
{
	static volatile gsize break_timer_daemon_util_simple_focus_manager_type_id__once = 0;
	if (g_once_init_enter (&break_timer_daemon_util_simple_focus_manager_type_id__once)) {
		GType break_timer_daemon_util_simple_focus_manager_type_id;
		break_timer_daemon_util_simple_focus_manager_type_id = break_timer_daemon_util_simple_focus_manager_get_type_once ();
		g_once_init_leave (&break_timer_daemon_util_simple_focus_manager_type_id__once, break_timer_daemon_util_simple_focus_manager_type_id);
	}
	return break_timer_daemon_util_simple_focus_manager_type_id__once;
}

