[clutter/wip/carlosg/touchpad-gestures: 4/7] touchpad-gesture: Add ClutterTouchpadGesture interface



commit 086dd76c77638d31d276697593a0c5f70f8f0051
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 |   58 ++++++++++++++++++
 clutter/clutter-touchpad-gesture.c         |   89 ++++++++++++++++++++++++++++
 3 files changed, 149 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..53a428b
--- /dev/null
+++ b/clutter/clutter-touchpad-gesture-private.h
@@ -0,0 +1,58 @@
+/*
+ * 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 (* begin)  (ClutterTouchpadGesture *gesture,
+                       const ClutterEvent     *event);
+  gboolean (* update) (ClutterTouchpadGesture *gesture,
+                       const ClutterEvent     *event);
+  void     (* end)    (ClutterTouchpadGesture *gesture,
+                       const ClutterEvent     *event);
+  void     (* cancel) (ClutterTouchpadGesture *gesture,
+                       const ClutterEvent     *event);
+};
+
+GType clutter_touchpad_gesture_get_type (void) G_GNUC_CONST;
+
+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..f949872
--- /dev/null
+++ b/clutter/clutter-touchpad-gesture.c
@@ -0,0 +1,89 @@
+/*
+ * 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"
+
+enum {
+  TOUCHPAD_GESTURE_BEGIN,
+  TOUCHPAD_GESTURE_UPDATE,
+  TOUCHPAD_GESTURE_END,
+  TOUCHPAD_GESTURE_CANCEL,
+  N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0 };
+
+typedef ClutterTouchpadGestureIface ClutterTouchpadGestureInterface;
+
+G_DEFINE_INTERFACE (ClutterTouchpadGesture, clutter_touchpad_gesture,
+                    CLUTTER_TYPE_GESTURE_ACTION)
+
+static void
+clutter_touchpad_gesture_default_init (ClutterTouchpadGestureIface *iface)
+{
+  GType iface_type = G_TYPE_FROM_INTERFACE (iface);
+
+  signals[TOUCHPAD_GESTURE_BEGIN] =
+    g_signal_new (I_("touchpad-gesture-begin"),
+                  iface_type,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (ClutterTouchpadGestureIface, begin),
+                  NULL, NULL,
+                  _clutter_marshal_BOOLEAN__BOXED,
+                  G_TYPE_BOOLEAN, 1,
+                  CLUTTER_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  signals[TOUCHPAD_GESTURE_UPDATE] =
+    g_signal_new (I_("touchpad-gesture-update"),
+                  iface_type,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (ClutterTouchpadGestureIface, update),
+                  NULL, NULL,
+                  _clutter_marshal_BOOLEAN__BOXED,
+                  G_TYPE_BOOLEAN, 1,
+                  CLUTTER_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  signals[TOUCHPAD_GESTURE_END] =
+    g_signal_new (I_("touchpad-gesture-end"),
+                  iface_type,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (ClutterTouchpadGestureIface, end),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__BOXED,
+                  G_TYPE_NONE, 1,
+                  CLUTTER_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+  signals[TOUCHPAD_GESTURE_CANCEL] =
+    g_signal_new (I_("touchpad-gesture-cancel"),
+                  iface_type,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (ClutterTouchpadGestureIface, cancel),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__BOXED,
+                  G_TYPE_NONE, 1,
+                  CLUTTER_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]