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

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
 */

#include <clutter/clutter.h>
#include <glib-object.h>
#include <meta/display.h>
#include <glib.h>
#include <float.h>
#include <math.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GALA_TYPE_SUPER_SCROLL_ACTION (gala_super_scroll_action_get_type ())
#define GALA_SUPER_SCROLL_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SUPER_SCROLL_ACTION, GalaSuperScrollAction))
#define GALA_SUPER_SCROLL_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SUPER_SCROLL_ACTION, GalaSuperScrollActionClass))
#define GALA_IS_SUPER_SCROLL_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SUPER_SCROLL_ACTION))
#define GALA_IS_SUPER_SCROLL_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SUPER_SCROLL_ACTION))
#define GALA_SUPER_SCROLL_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SUPER_SCROLL_ACTION, GalaSuperScrollActionClass))

typedef struct _GalaSuperScrollAction GalaSuperScrollAction;
typedef struct _GalaSuperScrollActionClass GalaSuperScrollActionClass;
typedef struct _GalaSuperScrollActionPrivate GalaSuperScrollActionPrivate;
enum  {
	GALA_SUPER_SCROLL_ACTION_0_PROPERTY,
	GALA_SUPER_SCROLL_ACTION_DISPLAY_PROPERTY,
	GALA_SUPER_SCROLL_ACTION_NUM_PROPERTIES
};
static GParamSpec* gala_super_scroll_action_properties[GALA_SUPER_SCROLL_ACTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	GALA_SUPER_SCROLL_ACTION_TRIGGERED_SIGNAL,
	GALA_SUPER_SCROLL_ACTION_NUM_SIGNALS
};
static guint gala_super_scroll_action_signals[GALA_SUPER_SCROLL_ACTION_NUM_SIGNALS] = {0};

struct _GalaSuperScrollAction {
	ClutterAction parent_instance;
	GalaSuperScrollActionPrivate * priv;
};

struct _GalaSuperScrollActionClass {
	ClutterActionClass parent_class;
};

struct _GalaSuperScrollActionPrivate {
	MetaDisplay* _display;
};

static gint GalaSuperScrollAction_private_offset;
static gpointer gala_super_scroll_action_parent_class = NULL;

VALA_EXTERN GType gala_super_scroll_action_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaSuperScrollAction, g_object_unref)
VALA_EXTERN GalaSuperScrollAction* gala_super_scroll_action_new (MetaDisplay* display);
VALA_EXTERN GalaSuperScrollAction* gala_super_scroll_action_construct (GType object_type,
                                                           MetaDisplay* display);
static gboolean gala_super_scroll_action_real_handle_event (ClutterAction* base,
                                                     ClutterEvent* event);
static MetaDisplay* gala_super_scroll_action_get_display (GalaSuperScrollAction* self);
static void gala_super_scroll_action_set_display (GalaSuperScrollAction* self,
                                           MetaDisplay* value);
static void g_cclosure_user_marshal_BOOLEAN__UINT_DOUBLE_DOUBLE (GClosure * closure,
                                                          GValue * return_value,
                                                          guint n_param_values,
                                                          const GValue * param_values,
                                                          gpointer invocation_hint,
                                                          gpointer marshal_data);
static void gala_super_scroll_action_finalize (GObject * obj);
static GType gala_super_scroll_action_get_type_once (void);
static void _vala_gala_super_scroll_action_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_gala_super_scroll_action_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);

static inline gpointer
gala_super_scroll_action_get_instance_private (GalaSuperScrollAction* self)
{
	return G_STRUCT_MEMBER_P (self, GalaSuperScrollAction_private_offset);
}

GalaSuperScrollAction*
gala_super_scroll_action_construct (GType object_type,
                                    MetaDisplay* display)
{
	GalaSuperScrollAction * self = NULL;
	g_return_val_if_fail (display != NULL, NULL);
	self = (GalaSuperScrollAction*) g_object_new (object_type, "display", display, NULL);
	return self;
}

GalaSuperScrollAction*
gala_super_scroll_action_new (MetaDisplay* display)
{
	return gala_super_scroll_action_construct (GALA_TYPE_SUPER_SCROLL_ACTION, display);
}

static gboolean
gala_super_scroll_action_real_handle_event (ClutterAction* base,
                                            ClutterEvent* event)
{
	GalaSuperScrollAction * self;
	gboolean _tmp0_ = FALSE;
	gboolean result;
	self = (GalaSuperScrollAction*) base;
	g_return_val_if_fail (event != NULL, FALSE);
	if (clutter_event_type (event) == CLUTTER_SCROLL) {
		MetaDisplay* _tmp1_;
		ClutterModifierType _tmp2_;
		ClutterModifierType _tmp3_;
		_tmp1_ = self->priv->_display;
		_tmp2_ = meta_display_get_compositor_modifiers (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp0_ = (clutter_event_get_state (event) & _tmp3_) != 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gdouble dx = 0.0;
		gdouble dy = 0.0;
		gboolean _tmp4_ = FALSE;
		dx = 0.0;
		dy = 0.0;
		switch (clutter_event_get_scroll_direction (event)) {
			case CLUTTER_SCROLL_LEFT:
			{
				dx = -1.0;
				break;
			}
			case CLUTTER_SCROLL_RIGHT:
			{
				dx = 1.0;
				break;
			}
			case CLUTTER_SCROLL_UP:
			{
				dy = 1.0;
				break;
			}
			case CLUTTER_SCROLL_DOWN:
			{
				dy = -1.0;
				break;
			}
			default:
			{
				break;
			}
		}
		g_signal_emit (self, gala_super_scroll_action_signals[GALA_SUPER_SCROLL_ACTION_TRIGGERED_SIGNAL], 0, clutter_event_get_time (event), dx, dy, &_tmp4_);
		result = _tmp4_;
		return result;
	}
	result = CLUTTER_EVENT_PROPAGATE;
	return result;
}

static MetaDisplay*
gala_super_scroll_action_get_display (GalaSuperScrollAction* self)
{
	MetaDisplay* result;
	MetaDisplay* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_display;
	result = _tmp0_;
	return result;
}

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

static void
gala_super_scroll_action_set_display (GalaSuperScrollAction* self,
                                      MetaDisplay* value)
{
	MetaDisplay* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_super_scroll_action_get_display (self);
	if (old_value != value) {
		MetaDisplay* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_display);
		self->priv->_display = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_super_scroll_action_properties[GALA_SUPER_SCROLL_ACTION_DISPLAY_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_BOOLEAN__UINT_DOUBLE_DOUBLE (GClosure * closure,
                                                     GValue * return_value,
                                                     guint n_param_values,
                                                     const GValue * param_values,
                                                     gpointer invocation_hint,
                                                     gpointer marshal_data)
{
	typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_DOUBLE_DOUBLE) (gpointer data1, guint32 arg_1, gdouble arg_2, gdouble arg_3, gpointer data2);
	register GMarshalFunc_BOOLEAN__UINT_DOUBLE_DOUBLE callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	gboolean v_return;
	cc = (GCClosure *) closure;
	g_return_if_fail (return_value != NULL);
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_BOOLEAN__UINT_DOUBLE_DOUBLE) (marshal_data ? marshal_data : cc->callback);
	v_return = callback (data1, g_value_get_uint (param_values + 1), g_value_get_double (param_values + 2), g_value_get_double (param_values + 3), data2);
	g_value_set_boolean (return_value, v_return);
}

static void
gala_super_scroll_action_class_init (GalaSuperScrollActionClass * klass,
                                     gpointer klass_data)
{
	gala_super_scroll_action_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaSuperScrollAction_private_offset);
	((ClutterActionClass *) klass)->handle_event = (gboolean (*) (ClutterAction*, const ClutterEvent *)) gala_super_scroll_action_real_handle_event;
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_super_scroll_action_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_super_scroll_action_set_property;
	G_OBJECT_CLASS (klass)->finalize = gala_super_scroll_action_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_SUPER_SCROLL_ACTION_DISPLAY_PROPERTY, gala_super_scroll_action_properties[GALA_SUPER_SCROLL_ACTION_DISPLAY_PROPERTY] = g_param_spec_object ("display", "display", "display", meta_display_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	gala_super_scroll_action_signals[GALA_SUPER_SCROLL_ACTION_TRIGGERED_SIGNAL] = g_signal_new ("triggered", GALA_TYPE_SUPER_SCROLL_ACTION, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_BOOLEAN__UINT_DOUBLE_DOUBLE, G_TYPE_BOOLEAN, 3, G_TYPE_UINT, G_TYPE_DOUBLE, G_TYPE_DOUBLE);
}

static void
gala_super_scroll_action_instance_init (GalaSuperScrollAction * self,
                                        gpointer klass)
{
	self->priv = gala_super_scroll_action_get_instance_private (self);
}

static void
gala_super_scroll_action_finalize (GObject * obj)
{
	GalaSuperScrollAction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_SUPER_SCROLL_ACTION, GalaSuperScrollAction);
	_g_object_unref0 (self->priv->_display);
	G_OBJECT_CLASS (gala_super_scroll_action_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_super_scroll_action_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaSuperScrollActionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_super_scroll_action_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaSuperScrollAction), 0, (GInstanceInitFunc) gala_super_scroll_action_instance_init, NULL };
	GType gala_super_scroll_action_type_id;
	gala_super_scroll_action_type_id = g_type_register_static (clutter_action_get_type (), "GalaSuperScrollAction", &g_define_type_info, 0);
	GalaSuperScrollAction_private_offset = g_type_add_instance_private (gala_super_scroll_action_type_id, sizeof (GalaSuperScrollActionPrivate));
	return gala_super_scroll_action_type_id;
}

GType
gala_super_scroll_action_get_type (void)
{
	static gsize gala_super_scroll_action_type_id__once = 0;
	if (g_once_init_enter (&gala_super_scroll_action_type_id__once)) {
		GType gala_super_scroll_action_type_id;
		gala_super_scroll_action_type_id = gala_super_scroll_action_get_type_once ();
		g_once_init_leave (&gala_super_scroll_action_type_id__once, gala_super_scroll_action_type_id);
	}
	return gala_super_scroll_action_type_id__once;
}

static void
_vala_gala_super_scroll_action_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GalaSuperScrollAction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SUPER_SCROLL_ACTION, GalaSuperScrollAction);
	switch (property_id) {
		case GALA_SUPER_SCROLL_ACTION_DISPLAY_PROPERTY:
		g_value_set_object (value, gala_super_scroll_action_get_display (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_super_scroll_action_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GalaSuperScrollAction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SUPER_SCROLL_ACTION, GalaSuperScrollAction);
	switch (property_id) {
		case GALA_SUPER_SCROLL_ACTION_DISPLAY_PROPERTY:
		gala_super_scroll_action_set_display (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

