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

/*
 * Copyright 2026 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include "gala.h"
#include <clutter/clutter.h>
#include <glib-object.h>
#include <glib.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

enum  {
	GALA_SWIPE_TRIGGER_0_PROPERTY,
	GALA_SWIPE_TRIGGER_ACTOR_PROPERTY,
	GALA_SWIPE_TRIGGER_ORIENTATION_PROPERTY,
	GALA_SWIPE_TRIGGER_NUM_PROPERTIES
};
static GParamSpec* gala_swipe_trigger_properties[GALA_SWIPE_TRIGGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GALA_TYPE_GESTURE (gala_gesture_get_type ())
#define GALA_GESTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_GESTURE, GalaGesture))
#define GALA_GESTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_GESTURE, GalaGestureClass))
#define GALA_IS_GESTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_GESTURE))
#define GALA_IS_GESTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_GESTURE))
#define GALA_GESTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_GESTURE, GalaGestureClass))

typedef struct _GalaGesture GalaGesture;
typedef struct _GalaGestureClass GalaGestureClass;
typedef struct _GalaGesturePrivate GalaGesturePrivate;
typedef enum  {
	GALA_GESTURE_DIRECTION_UNKNOWN = 0,
	GALA_GESTURE_DIRECTION_UP = 1,
	GALA_GESTURE_DIRECTION_DOWN = 2,
	GALA_GESTURE_DIRECTION_LEFT = 3,
	GALA_GESTURE_DIRECTION_RIGHT = 4,
	GALA_GESTURE_DIRECTION_IN = 5,
	GALA_GESTURE_DIRECTION_OUT = 6
} GalaGestureDirection;

#define GALA_TYPE_GESTURE_DIRECTION (gala_gesture_direction_get_type ())

#define GALA_TYPE_GESTURE_BACKEND (gala_gesture_backend_get_type ())
#define GALA_GESTURE_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_GESTURE_BACKEND, GalaGestureBackend))
#define GALA_IS_GESTURE_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_GESTURE_BACKEND))
#define GALA_GESTURE_BACKEND_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GALA_TYPE_GESTURE_BACKEND, GalaGestureBackendIface))

typedef struct _GalaGestureBackend GalaGestureBackend;
typedef struct _GalaGestureBackendIface GalaGestureBackendIface;

#define GALA_TYPE_GESTURE_SETTINGS (gala_gesture_settings_get_type ())
#define GALA_GESTURE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_GESTURE_SETTINGS, GalaGestureSettings))
#define GALA_GESTURE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_GESTURE_SETTINGS, GalaGestureSettingsClass))
#define GALA_IS_GESTURE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_GESTURE_SETTINGS))
#define GALA_IS_GESTURE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_GESTURE_SETTINGS))
#define GALA_GESTURE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_GESTURE_SETTINGS, GalaGestureSettingsClass))

typedef struct _GalaGestureSettings GalaGestureSettings;
typedef struct _GalaGestureSettingsClass GalaGestureSettingsClass;

#define GALA_TYPE_SCROLL_BACKEND (gala_scroll_backend_get_type ())
#define GALA_SCROLL_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SCROLL_BACKEND, GalaScrollBackend))
#define GALA_SCROLL_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SCROLL_BACKEND, GalaScrollBackendClass))
#define GALA_IS_SCROLL_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SCROLL_BACKEND))
#define GALA_IS_SCROLL_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SCROLL_BACKEND))
#define GALA_SCROLL_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SCROLL_BACKEND, GalaScrollBackendClass))

typedef struct _GalaScrollBackend GalaScrollBackend;
typedef struct _GalaScrollBackendClass GalaScrollBackendClass;

struct _GalaSwipeTriggerPrivate {
	ClutterActor* _actor;
	ClutterOrientation _orientation;
};

struct _GalaGesture {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GalaGesturePrivate * priv;
	ClutterEventType type;
	GalaGestureDirection direction;
	gint fingers;
	ClutterInputDeviceType performed_on_device_type;
};

struct _GalaGestureClass {
	GTypeClass parent_class;
	void (*finalize) (GalaGesture *self);
};

struct _GalaGestureBackendIface {
	GTypeInterface parent_iface;
	void (*cancel_gesture) (GalaGestureBackend* self);
};

static gint GalaSwipeTrigger_private_offset;
static gpointer gala_swipe_trigger_parent_class = NULL;
static GalaGestureTriggerIface * gala_swipe_trigger_gala_gesture_trigger_parent_iface = NULL;

 G_GNUC_INTERNAL gpointer gala_gesture_ref (gpointer instance);
 G_GNUC_INTERNAL void gala_gesture_unref (gpointer instance);
 G_GNUC_INTERNAL GParamSpec* gala_param_spec_gesture (const gchar* name,
                                     const gchar* nick,
                                     const gchar* blurb,
                                     GType object_type,
                                     GParamFlags flags);
 G_GNUC_INTERNAL void gala_value_set_gesture (GValue* value,
                             gpointer v_object) G_GNUC_UNUSED ;
 G_GNUC_INTERNAL void gala_value_take_gesture (GValue* value,
                              gpointer v_object);
 G_GNUC_INTERNAL gpointer gala_value_get_gesture (const GValue* value) G_GNUC_UNUSED ;
 G_GNUC_INTERNAL GType gala_gesture_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static gboolean gala_swipe_trigger_real_triggers (GalaGestureTrigger* base,
                                           GalaGesture* gesture);
 G_GNUC_INTERNAL GType gala_gesture_direction_get_type (void) G_GNUC_CONST ;
static void gala_swipe_trigger_real_enable_backends (GalaGestureTrigger* base,
                                              GalaGestureController* controller);
 G_GNUC_INTERNAL GType gala_gesture_backend_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
 G_GNUC_INTERNAL void gala_gesture_controller_enable_backend (GalaGestureController* self,
                                             GalaGestureBackend* backend);
 G_GNUC_INTERNAL GalaGestureSettings* gala_gesture_settings_new (void);
 G_GNUC_INTERNAL GalaGestureSettings* gala_gesture_settings_construct (GType object_type);
 G_GNUC_INTERNAL GType gala_gesture_settings_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
 G_GNUC_INTERNAL GalaScrollBackend* gala_scroll_backend_new (ClutterActor* actor,
                                            ClutterOrientation orientation,
                                            GalaGestureSettings* settings);
 G_GNUC_INTERNAL GalaScrollBackend* gala_scroll_backend_construct (GType object_type,
                                                  ClutterActor* actor,
                                                  ClutterOrientation orientation,
                                                  GalaGestureSettings* settings);
 G_GNUC_INTERNAL GType gala_scroll_backend_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
 G_GNUC_INTERNAL gboolean gala_gesture_trigger_triggers (GalaGestureTrigger* self,
                                        GalaGesture* gesture);
 G_GNUC_INTERNAL void gala_gesture_trigger_enable_backends (GalaGestureTrigger* self,
                                           GalaGestureController* controller);
static void gala_swipe_trigger_finalize (GObject * obj);
static GType gala_swipe_trigger_get_type_once (void);
static void _vala_gala_swipe_trigger_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_gala_swipe_trigger_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);

static inline gpointer
gala_swipe_trigger_get_instance_private (GalaSwipeTrigger* self)
{
	return G_STRUCT_MEMBER_P (self, GalaSwipeTrigger_private_offset);
}

GalaSwipeTrigger*
gala_swipe_trigger_construct (GType object_type,
                              ClutterActor* actor,
                              ClutterOrientation orientation)
{
	GalaSwipeTrigger * self = NULL;
	g_return_val_if_fail (actor != NULL, NULL);
	self = (GalaSwipeTrigger*) g_object_new (object_type, "actor", actor, "orientation", orientation, NULL);
	return self;
}

GalaSwipeTrigger*
gala_swipe_trigger_new (ClutterActor* actor,
                        ClutterOrientation orientation)
{
	return gala_swipe_trigger_construct (GALA_TYPE_SWIPE_TRIGGER, actor, orientation);
}

static gboolean
gala_swipe_trigger_real_triggers (GalaGestureTrigger* base,
                                  GalaGesture* gesture)
{
	GalaSwipeTrigger * self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	self = (GalaSwipeTrigger*) base;
	g_return_val_if_fail (gesture != NULL, FALSE);
	if (gesture->fingers == 1) {
		_tmp1_ = gesture->performed_on_device_type == CLUTTER_TOUCHSCREEN_DEVICE;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gboolean _tmp2_ = FALSE;
		if (gesture->fingers == 2) {
			_tmp2_ = gesture->performed_on_device_type == CLUTTER_TOUCHPAD_DEVICE;
		} else {
			_tmp2_ = FALSE;
		}
		_tmp0_ = _tmp2_;
	}
	result = _tmp0_;
	return result;
}

static void
gala_swipe_trigger_real_enable_backends (GalaGestureTrigger* base,
                                         GalaGestureController* controller)
{
	GalaSwipeTrigger * self;
	ClutterActor* _tmp0_;
	ClutterOrientation _tmp1_;
	GalaGestureSettings* _tmp2_;
	GalaGestureSettings* _tmp3_;
	GalaScrollBackend* _tmp4_;
	GalaScrollBackend* _tmp5_;
	self = (GalaSwipeTrigger*) base;
	g_return_if_fail (controller != NULL);
	_tmp0_ = self->priv->_actor;
	_tmp1_ = self->priv->_orientation;
	_tmp2_ = gala_gesture_settings_new ();
	_tmp3_ = _tmp2_;
	_tmp4_ = gala_scroll_backend_new (_tmp0_, _tmp1_, _tmp3_);
	_tmp5_ = _tmp4_;
	gala_gesture_controller_enable_backend (controller, (GalaGestureBackend*) _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
}

ClutterActor*
gala_swipe_trigger_get_actor (GalaSwipeTrigger* self)
{
	ClutterActor* result;
	ClutterActor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_actor;
	result = _tmp0_;
	return result;
}

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

static void
gala_swipe_trigger_set_actor (GalaSwipeTrigger* self,
                              ClutterActor* value)
{
	ClutterActor* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_swipe_trigger_get_actor (self);
	if (old_value != value) {
		ClutterActor* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_actor);
		self->priv->_actor = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_swipe_trigger_properties[GALA_SWIPE_TRIGGER_ACTOR_PROPERTY]);
	}
}

ClutterOrientation
gala_swipe_trigger_get_orientation (GalaSwipeTrigger* self)
{
	ClutterOrientation result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_orientation;
	return result;
}

static void
gala_swipe_trigger_set_orientation (GalaSwipeTrigger* self,
                                    ClutterOrientation value)
{
	ClutterOrientation old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_swipe_trigger_get_orientation (self);
	if (old_value != value) {
		self->priv->_orientation = value;
		g_object_notify_by_pspec ((GObject *) self, gala_swipe_trigger_properties[GALA_SWIPE_TRIGGER_ORIENTATION_PROPERTY]);
	}
}

static void
gala_swipe_trigger_class_init (GalaSwipeTriggerClass * klass,
                               gpointer klass_data)
{
	gala_swipe_trigger_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaSwipeTrigger_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_swipe_trigger_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_swipe_trigger_set_property;
	G_OBJECT_CLASS (klass)->finalize = gala_swipe_trigger_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_SWIPE_TRIGGER_ACTOR_PROPERTY, gala_swipe_trigger_properties[GALA_SWIPE_TRIGGER_ACTOR_PROPERTY] = g_param_spec_object ("actor", "actor", "actor", clutter_actor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_SWIPE_TRIGGER_ORIENTATION_PROPERTY, gala_swipe_trigger_properties[GALA_SWIPE_TRIGGER_ORIENTATION_PROPERTY] = g_param_spec_enum ("orientation", "orientation", "orientation", clutter_orientation_get_type (), 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_swipe_trigger_gala_gesture_trigger_interface_init (GalaGestureTriggerIface * iface,
                                                        gpointer iface_data)
{
	gala_swipe_trigger_gala_gesture_trigger_parent_iface = g_type_interface_peek_parent (iface);
	iface->triggers = (gboolean (*) (GalaGestureTrigger*, GalaGesture*)) gala_swipe_trigger_real_triggers;
	iface->enable_backends = (void (*) (GalaGestureTrigger*, GalaGestureController*)) gala_swipe_trigger_real_enable_backends;
}

static void
gala_swipe_trigger_instance_init (GalaSwipeTrigger * self,
                                  gpointer klass)
{
	self->priv = gala_swipe_trigger_get_instance_private (self);
}

static void
gala_swipe_trigger_finalize (GObject * obj)
{
	GalaSwipeTrigger * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_SWIPE_TRIGGER, GalaSwipeTrigger);
	_g_object_unref0 (self->priv->_actor);
	G_OBJECT_CLASS (gala_swipe_trigger_parent_class)->finalize (obj);
}

/**
 * A trigger that triggers when a swipe gesture (2 fingers on touchpad, 1 finger on touchscreen)
 * has been recognized on the given actor with the given orientation.
 * It enables touchpad and (once supported) touchscreen backends for the given actor.
 */
 G_GNUC_NO_INLINE static GType
gala_swipe_trigger_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaSwipeTriggerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_swipe_trigger_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaSwipeTrigger), 0, (GInstanceInitFunc) gala_swipe_trigger_instance_init, NULL };
	static const GInterfaceInfo gala_gesture_trigger_info = { (GInterfaceInitFunc) gala_swipe_trigger_gala_gesture_trigger_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gala_swipe_trigger_type_id;
	gala_swipe_trigger_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaSwipeTrigger", &g_define_type_info, 0);
	g_type_add_interface_static (gala_swipe_trigger_type_id, GALA_TYPE_GESTURE_TRIGGER, &gala_gesture_trigger_info);
	GalaSwipeTrigger_private_offset = g_type_add_instance_private (gala_swipe_trigger_type_id, sizeof (GalaSwipeTriggerPrivate));
	return gala_swipe_trigger_type_id;
}

GType
gala_swipe_trigger_get_type (void)
{
	static gsize gala_swipe_trigger_type_id__once = 0;
	if (g_once_init_enter (&gala_swipe_trigger_type_id__once)) {
		GType gala_swipe_trigger_type_id;
		gala_swipe_trigger_type_id = gala_swipe_trigger_get_type_once ();
		g_once_init_leave (&gala_swipe_trigger_type_id__once, gala_swipe_trigger_type_id);
	}
	return gala_swipe_trigger_type_id__once;
}

static void
_vala_gala_swipe_trigger_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	GalaSwipeTrigger * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SWIPE_TRIGGER, GalaSwipeTrigger);
	switch (property_id) {
		case GALA_SWIPE_TRIGGER_ACTOR_PROPERTY:
		g_value_set_object (value, gala_swipe_trigger_get_actor (self));
		break;
		case GALA_SWIPE_TRIGGER_ORIENTATION_PROPERTY:
		g_value_set_enum (value, gala_swipe_trigger_get_orientation (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_swipe_trigger_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	GalaSwipeTrigger * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SWIPE_TRIGGER, GalaSwipeTrigger);
	switch (property_id) {
		case GALA_SWIPE_TRIGGER_ACTOR_PROPERTY:
		gala_swipe_trigger_set_actor (self, g_value_get_object (value));
		break;
		case GALA_SWIPE_TRIGGER_ORIENTATION_PROPERTY:
		gala_swipe_trigger_set_orientation (self, g_value_get_enum (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

