summaryrefslogtreecommitdiff
path: root/unity-private
diff options
authornjpatel <>2010-08-10 09:58:37 +0100
committernjpatel <>2010-08-10 09:58:37 +0100
commite8a0784c9284a3bf9a28e61184f0884fb51de05b (patch)
tree950b0a1d175a98c776718154ac59e4024e926179 /unity-private
parent5d9431f3527e2618870d20bb704ac7f65917fc5e (diff)
Do some clean up, add support for choosing which events to receive
(bzr r424.1.6)
Diffstat (limited to 'unity-private')
-rw-r--r--unity-private/Makefile.am3
-rw-r--r--unity-private/gesture/gesture-dispatcher-xcb-glu.vala2
-rw-r--r--unity-private/gesture/gesture-dispatcher-xcb-glue.c28
-rw-r--r--unity-private/gesture/gesture-dispatcher-xcb.vala2
-rw-r--r--unity-private/gesture/gesture-dispatcher.vala4
-rw-r--r--unity-private/gesture/gesture-event.vala51
6 files changed, 80 insertions, 10 deletions
diff --git a/unity-private/Makefile.am b/unity-private/Makefile.am
index 96a635205..5083477c5 100644
--- a/unity-private/Makefile.am
+++ b/unity-private/Makefile.am
@@ -126,7 +126,8 @@ launcher_sources = \
gesture_sources = \
gesture/gesture-dispatcher.vala \
gesture/gesture-dispatcher-xcb.vala \
- gesture/gesture-dispatcher-xcb-glu.vala
+ gesture/gesture-dispatcher-xcb-glu.vala \
+ gesture/gesture-event.vala
testing_sources = \
testing/background.vala \
diff --git a/unity-private/gesture/gesture-dispatcher-xcb-glu.vala b/unity-private/gesture/gesture-dispatcher-xcb-glu.vala
index 3dfe4d641..5ac04e43d 100644
--- a/unity-private/gesture/gesture-dispatcher-xcb-glu.vala
+++ b/unity-private/gesture/gesture-dispatcher-xcb-glu.vala
@@ -20,7 +20,7 @@
namespace Unity.Gesture.XCBDispatcherGlue
{
//[CCode (lower_case_prefix = "gesture_dispatcher_xcb_glue_")]
- public extern void init ();
+ public extern void init (GLib.Object obj);
//[CCode (lower_case_prefix = "gesture_dispatcher_xcb_glue_")]
public extern void finish ();
diff --git a/unity-private/gesture/gesture-dispatcher-xcb-glue.c b/unity-private/gesture/gesture-dispatcher-xcb-glue.c
index de473f56d..30bf51a64 100644
--- a/unity-private/gesture/gesture-dispatcher-xcb-glue.c
+++ b/unity-private/gesture/gesture-dispatcher-xcb-glue.c
@@ -26,12 +26,13 @@
#include <X11/X.h>
#include <glib.h>
+#include <glib-object.h>
-#include <grail-types.h>
+#include <grail.h>
#include "gesture.h"
-#define XCB_DISPATCHER_TIMEOUT 500
+#define XCB_DISPATCHER_TIMEOUT 100
typedef struct
{
@@ -41,6 +42,8 @@ typedef struct
xcb_connection_t *connection;
xcb_generic_event_t *event;
+ GObject *dispatcher;
+
} XCBSource;
static gboolean source_prepare (GSource *source, gint *timeout);
@@ -66,19 +69,20 @@ static GSourceFuncs XCBFuncs = {
};
void
-unity_gesture_xcb_dispatcher_glue_init ()
+unity_gesture_xcb_dispatcher_glue_init (GObject *object)
{
g_debug ("%s", G_STRFUNC);
xcb_connection_t *connection;
XCBSource *source;
uint16_t mask_len = 1;
- uint32_t *mask;
+ grail_mask_t *mask;
connection = xcb_connect (NULL, NULL);
- mask = malloc(sizeof(uint32_t) * mask_len);
- *mask = 0xeeee;
- if (set_mask (connection, 0, 0, mask_len, mask))
+ mask = calloc(1, sizeof(grail_mask_t) * mask_len);
+ grail_mask_set(mask, GRAIL_TYPE_TAP4);
+
+ if (set_mask (connection, 0, 0, mask_len, (uint32_t*)mask))
{
g_warning ("Unable to initialize gesture dispatcher xcb");
return;
@@ -86,6 +90,7 @@ unity_gesture_xcb_dispatcher_glue_init ()
source = (XCBSource*)g_source_new (&XCBFuncs, sizeof(XCBSource));
source->connection = connection;
+ source->dispatcher = object;
g_source_attach (&source->source, NULL);
}
@@ -235,6 +240,15 @@ unity_gesture_xcb_dispatcher_glue_main_iteration (XCBSource *source)
printf("\t\tProperty %u:\t%f\n", i, properties[i]);
}
+ if (gesture_event->gesture_type == GRAIL_TYPE_TAP4)
+ {
+ g_signal_emit_by_name (source->dispatcher,
+ "tap",
+ 4,
+ properties[0],
+ gesture_event->time);
+ }
+
printf("\n");
}
}
diff --git a/unity-private/gesture/gesture-dispatcher-xcb.vala b/unity-private/gesture/gesture-dispatcher-xcb.vala
index 30ddcdb64..15f07f49f 100644
--- a/unity-private/gesture/gesture-dispatcher-xcb.vala
+++ b/unity-private/gesture/gesture-dispatcher-xcb.vala
@@ -23,7 +23,7 @@ namespace Unity.Gesture
{
public XCBDispatcher ()
{
- XCBDispatcherGlue.init ();
+ XCBDispatcherGlue.init (this as GLib.Object);
}
~XCBDispatcher ()
diff --git a/unity-private/gesture/gesture-dispatcher.vala b/unity-private/gesture/gesture-dispatcher.vala
index d318deb83..e9f310bfb 100644
--- a/unity-private/gesture/gesture-dispatcher.vala
+++ b/unity-private/gesture/gesture-dispatcher.vala
@@ -22,5 +22,9 @@ namespace Unity.Gesture
public abstract class Dispatcher : GLib.Object
{
public signal void gesture ();
+
+ public signal void tap (int n_fingers,
+ uint32 duration,
+ uint32 timestamp);
}
}
diff --git a/unity-private/gesture/gesture-event.vala b/unity-private/gesture/gesture-event.vala
new file mode 100644
index 000000000..613f419a3
--- /dev/null
+++ b/unity-private/gesture/gesture-event.vala
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Canonical Ltd
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * 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/>.
+ *
+ * Authored by Neil Jagdish Patel <neil.patel@canonical.com>
+ *
+ */
+
+namespace Unity.Gesture
+{
+ enum Type
+ {
+ POINTER,
+ PAN,
+ PINCH,
+ ROTATE,
+ COMBO2,
+
+ SWIPE,
+ SCALE,
+ TURN,
+ COMBO3,
+
+ BRUSH,
+ PICK,
+ WHIRL,
+ COMBO4,
+
+ HAND,
+ GRAB,
+ REVOLVE,
+ COMBO5,
+
+ TAP1,
+ TAP2,
+ TAP3,
+ TAP4,
+ TAP5
+ }
+}