[clutter/wip/carlosg/touchpad-gestures: 7/13] touchpad-gesture: Add ClutterTouchpadGesture interface
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/carlosg/touchpad-gestures: 7/13] touchpad-gesture: Add ClutterTouchpadGesture interface
- Date: Thu, 4 Jun 2015 19:27:20 +0000 (UTC)
commit bd7d2e7ca1a332a20e37719fa9d09f1bf4e6d04e
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri May 22 18:32:25 2015 +0200
touchpad-gesture: Add ClutterTouchpadGesture interface
This is an internal interface so ClutterGestureAction subclasses are
able to handle touchpad events directly.
clutter/Makefile.am | 2 +
clutter/clutter-touchpad-gesture-private.h | 65 +++++++++++++++++
clutter/clutter-touchpad-gesture.c | 109 ++++++++++++++++++++++++++++
3 files changed, 176 insertions(+), 0 deletions(-)
---
diff --git a/clutter/Makefile.am b/clutter/Makefile.am
index 9eabb9f..d81d46f 100644
--- a/clutter/Makefile.am
+++ b/clutter/Makefile.am
@@ -206,6 +206,7 @@ source_c = \
clutter-test-utils.c \
clutter-text.c \
clutter-text-buffer.c \
+ clutter-touchpad-gesture.c \
clutter-transition-group.c \
clutter-transition.c \
clutter-timeline.c \
@@ -244,6 +245,7 @@ source_h_priv = \
clutter-stage-manager-private.h \
clutter-stage-private.h \
clutter-stage-window.h \
+ clutter-touchpad-gesture-private.h
$(NULL)
# private source code; these should not be introspected
diff --git a/clutter/clutter-touchpad-gesture-private.h b/clutter/clutter-touchpad-gesture-private.h
new file mode 100644
index 0000000..aa89093
--- /dev/null
+++ b/clutter/clutter-touchpad-gesture-private.h
@@ -0,0 +1,65 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2015 Red Hat.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#ifndef __CLUTTER_TOUCHPAD_GESTURE_PRIVATE_H__
+#define __CLUTTER_TOUCHPAD_GESTURE_PRIVATE_H__
+
+#include <clutter/clutter-types.h>
+
+G_BEGIN_DECLS
+
+#define CLUTTER_TYPE_TOUCHPAD_GESTURE (clutter_touchpad_gesture_get_type ())
+#define CLUTTER_TOUCHPAD_GESTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
CLUTTER_TYPE_TOUCHPAD_GESTURE, ClutterTouchpadGesture))
+#define CLUTTER_IS_TOUCHPAD_GESTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
CLUTTER_TYPE_TOUCHPAD_GESTURE))
+#define CLUTTER_TOUCHPAD_GESTURE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj),
CLUTTER_TYPE_TOUCHPAD_GESTURE, ClutterTouchpadGestureIface))
+
+typedef struct _ClutterTouchpadGesture ClutterTouchpadGesture;
+typedef struct _ClutterTouchpadGestureIface ClutterTouchpadGestureIface;
+
+struct _ClutterTouchpadGestureIface
+{
+ /*< private >*/
+ GTypeInterface g_iface;
+
+ gboolean (* handle_event) (ClutterTouchpadGesture *gesture,
+ const ClutterEvent *event);
+
+ gboolean (* over_threshold) (ClutterTouchpadGesture *gesture);
+
+ gboolean (* begin) (ClutterTouchpadGesture *gesture);
+ gboolean (* update) (ClutterTouchpadGesture *gesture);
+ void (* end) (ClutterTouchpadGesture *gesture);
+};
+
+GType clutter_touchpad_gesture_get_type (void) G_GNUC_CONST;
+
+gboolean clutter_touchpad_gesture_handle_event (ClutterTouchpadGesture *gesture,
+ const ClutterEvent *event);
+gboolean clutter_touchpad_gesture_over_threshold (ClutterTouchpadGesture *gesture);
+gboolean clutter_touchpad_gesture_begin (ClutterTouchpadGesture *gesture);
+gboolean clutter_touchpad_gesture_update (ClutterTouchpadGesture *gesture);
+void clutter_touchpad_gesture_end (ClutterTouchpadGesture *gesture);
+
+G_END_DECLS
+
+#endif /* __CLUTTER_TOUCHPAD_GESTURE_PRIVATE_H__ */
diff --git a/clutter/clutter-touchpad-gesture.c b/clutter/clutter-touchpad-gesture.c
new file mode 100644
index 0000000..569c1c0
--- /dev/null
+++ b/clutter/clutter-touchpad-gesture.c
@@ -0,0 +1,109 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2015 Red Hat.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "clutter-touchpad-gesture-private.h"
+#include "clutter-gesture-action.h"
+#include "clutter-marshal.h"
+#include "clutter-private.h"
+
+typedef ClutterTouchpadGestureIface ClutterTouchpadGestureInterface;
+
+G_DEFINE_INTERFACE (ClutterTouchpadGesture, clutter_touchpad_gesture,
+ CLUTTER_TYPE_GESTURE_ACTION)
+
+static void
+clutter_touchpad_gesture_default_init (ClutterTouchpadGestureIface *iface)
+{
+}
+
+gboolean
+clutter_touchpad_gesture_handle_event (ClutterTouchpadGesture *gesture,
+ const ClutterEvent *event)
+{
+ g_return_val_if_fail (CLUTTER_IS_TOUCHPAD_GESTURE (gesture), CLUTTER_EVENT_STOP);
+ g_return_val_if_fail (event != NULL, CLUTTER_EVENT_STOP);
+
+ return CLUTTER_TOUCHPAD_GESTURE_GET_IFACE (gesture)->handle_event (gesture, event);
+}
+
+gboolean
+clutter_touchpad_gesture_over_threshold (ClutterTouchpadGesture *gesture)
+{
+ ClutterTouchpadGestureIface *iface;
+
+ g_return_val_if_fail (CLUTTER_IS_TOUCHPAD_GESTURE (gesture), FALSE);
+
+ iface = CLUTTER_TOUCHPAD_GESTURE_GET_IFACE (gesture);
+
+ if (!iface->over_threshold)
+ return TRUE;
+
+ return iface->over_threshold (gesture);
+}
+
+gboolean
+clutter_touchpad_gesture_begin (ClutterTouchpadGesture *gesture)
+{
+ ClutterTouchpadGestureIface *iface;
+
+ g_return_val_if_fail (CLUTTER_IS_TOUCHPAD_GESTURE (gesture), FALSE);
+
+ iface = CLUTTER_TOUCHPAD_GESTURE_GET_IFACE (gesture);
+
+ if (iface->begin)
+ return iface->begin (gesture);
+ else
+ return TRUE;
+}
+
+gboolean
+clutter_touchpad_gesture_update (ClutterTouchpadGesture *gesture)
+{
+ ClutterTouchpadGestureIface *iface;
+
+ g_return_val_if_fail (CLUTTER_IS_TOUCHPAD_GESTURE (gesture), FALSE);
+
+ iface = CLUTTER_TOUCHPAD_GESTURE_GET_IFACE (gesture);
+
+ if (iface->update)
+ return iface->update (gesture);
+ else
+ return TRUE;
+}
+
+void
+clutter_touchpad_gesture_end (ClutterTouchpadGesture *gesture)
+{
+ ClutterTouchpadGestureIface *iface;
+
+ g_return_val_if_fail (CLUTTER_IS_TOUCHPAD_GESTURE (gesture), FALSE);
+
+ iface = CLUTTER_TOUCHPAD_GESTURE_GET_IFACE (gesture);
+
+ if (iface->end)
+ iface->end (gesture);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]