[clutter/android-enter-leave: 5/29] android: add event source
- From: Lionel Landwerlin <llandwerlin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/android-enter-leave: 5/29] android: add event source
- Date: Wed, 11 Jul 2012 17:07:29 +0000 (UTC)
commit bf829a56cee03942a6aecda1687fd0f3f23b845d
Author: Lionel Landwerlin <llandwerlin gmail com>
Date: Sat May 26 17:15:47 2012 +0100
android: add event source
clutter/Makefile.am | 2 +
clutter/android/clutter-android-application.c | 4 +-
clutter/android/clutter-backend-android.c | 18 ++++
clutter/android/clutter-backend-android.h | 2 +
clutter/android/clutter-event-android.c | 112 +++++++++++++++++++++++++
clutter/android/clutter-event-android.h | 34 ++++++++
6 files changed, 170 insertions(+), 2 deletions(-)
---
diff --git a/clutter/Makefile.am b/clutter/Makefile.am
index a9cc4d2..08aca25 100644
--- a/clutter/Makefile.am
+++ b/clutter/Makefile.am
@@ -513,6 +513,7 @@ android_source_c_priv = \
$(srcdir)/android/android_native_app_glue.c \
$(srcdir)/android/clutter-device-manager-android.c \
$(srcdir)/android/clutter-backend-android.c \
+ $(srcdir)/android/clutter-event-android.c \
$(srcdir)/android/clutter-stage-android.c \
$(NULL)
@@ -525,6 +526,7 @@ android_source_h_priv = \
$(srcdir)/android/android_native_app_glue.h \
$(srcdir)/android/clutter-device-manager-android.h \
$(srcdir)/android/clutter-backend-android.h \
+ $(srcdir)/android/clutter-event-android.h \
$(srcdir)/android/clutter-stage-android.h \
$(NULL)
diff --git a/clutter/android/clutter-android-application.c b/clutter/android/clutter-android-application.c
index a12fc28..8357b3e 100644
--- a/clutter/android/clutter-android-application.c
+++ b/clutter/android/clutter-android-application.c
@@ -36,6 +36,7 @@
#include "clutter-marshal.h"
#include "clutter-private.h"
#include "clutter-device-manager-private.h"
+#include "clutter-event-private.h"
#include "clutter-stage-private.h"
#include "clutter-android-application-private.h"
@@ -339,8 +340,7 @@ clutter_android_handle_input (struct android_app *app,
}
if (process)
- clutter_do_event (event);
- clutter_event_free (event);
+ _clutter_event_push (event, FALSE);
return (int32_t) process;
}
diff --git a/clutter/android/clutter-backend-android.c b/clutter/android/clutter-backend-android.c
index 54ce221..ca9c90b 100644
--- a/clutter/android/clutter-backend-android.c
+++ b/clutter/android/clutter-backend-android.c
@@ -23,6 +23,7 @@
#include "clutter-backend-android.h"
#include "clutter-device-manager-android.h"
+#include "clutter-event-android.h"
#include "clutter-debug.h"
#include "clutter-private.h"
@@ -66,6 +67,21 @@ clutter_backend_android_dispose (GObject *object)
G_OBJECT_CLASS (clutter_backend_android_parent_class)->dispose (object);
}
+static gboolean
+clutter_backend_android_post_parse (ClutterBackend *backend,
+ GError **error)
+{
+ ClutterBackendAndroid *backend_android = CLUTTER_BACKEND_ANDROID (backend);
+
+ backend_android->android_source = _clutter_event_source_android_new ();
+ g_source_attach (backend_android->android_source, NULL);
+
+ /* TODO: Maybe move the device manager initialization here...
+ IDUNNOLOL */
+
+ return TRUE;
+}
+
static void
clutter_backend_android_class_init (ClutterBackendAndroidClass *klass)
{
@@ -75,4 +91,6 @@ clutter_backend_android_class_init (ClutterBackendAndroidClass *klass)
object_class->dispose = clutter_backend_android_dispose;
backend_class->stage_window_type = CLUTTER_TYPE_STAGE_ANDROID;
+
+ backend_class->post_parse = clutter_backend_android_post_parse;
}
diff --git a/clutter/android/clutter-backend-android.h b/clutter/android/clutter-backend-android.h
index 1a5bfff..61af1c4 100644
--- a/clutter/android/clutter-backend-android.h
+++ b/clutter/android/clutter-backend-android.h
@@ -45,6 +45,8 @@ typedef struct _ClutterBackendAndroidClass ClutterBackendAndroidClass;
struct _ClutterBackendAndroid
{
ClutterBackend parent_instance;
+
+ GSource *android_source;
};
struct _ClutterBackendAndroidClass
diff --git a/clutter/android/clutter-event-android.c b/clutter/android/clutter-event-android.c
new file mode 100644
index 0000000..a68eccb
--- /dev/null
+++ b/clutter/android/clutter-event-android.c
@@ -0,0 +1,112 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * 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/>.
+
+ * Authors:
+ * Lionel Landwerlin <lionel g landwerlin linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "clutter-event.h"
+#include "clutter-main.h"
+
+#include "clutter-event-android.h"
+
+typedef struct _ClutterEventSourceAndroid
+{
+ GSource source;
+} ClutterEventSourceAndroid;
+
+static gboolean
+clutter_event_source_android_prepare (GSource *base, gint *timeout)
+{
+ gboolean retval;
+
+ clutter_threads_enter ();
+
+ *timeout = -1;
+
+ retval = clutter_events_pending ();
+
+ clutter_threads_leave ();
+
+ return retval;
+}
+
+static gboolean
+clutter_event_source_android_check (GSource *base)
+{
+ gboolean retval;
+
+ clutter_threads_enter ();
+
+ retval = clutter_events_pending ();
+
+ clutter_threads_leave ();
+
+ return retval;
+}
+
+static gboolean
+clutter_event_source_android_dispatch (GSource *base,
+ GSourceFunc callback,
+ gpointer data)
+{
+ ClutterEvent *event;
+
+ clutter_threads_enter ();
+
+ event = clutter_event_get ();
+
+ if (event)
+ {
+ /* forward the event into clutter for emission etc. */
+ clutter_do_event (event);
+ clutter_event_free (event);
+ }
+
+ clutter_threads_leave ();
+
+ return TRUE;
+}
+
+static GSourceFuncs clutter_event_source_android_funcs = {
+ clutter_event_source_android_prepare,
+ clutter_event_source_android_check,
+ clutter_event_source_android_dispatch,
+ NULL
+};
+
+GSource *
+_clutter_event_source_android_new (void)
+{
+ ClutterEventSourceAndroid *source;
+
+ source = (ClutterEventSourceAndroid *)
+ g_source_new (&clutter_event_source_android_funcs,
+ sizeof (ClutterEventSourceAndroid));
+
+ return &source->source;
+}
diff --git a/clutter/android/clutter-event-android.h b/clutter/android/clutter-event-android.h
new file mode 100644
index 0000000..2265071
--- /dev/null
+++ b/clutter/android/clutter-event-android.h
@@ -0,0 +1,34 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * 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/>.
+
+ * Authors:
+ * Lionel Landwerlin <lionel g landwerlin linux intel com>
+ */
+
+#ifndef __CLUTTER_EVENT_ANDROID_H__
+#define __CLUTTER_EVENT_ANDROID_H__
+
+#include <glib-object.h>
+#include <clutter/clutter-event.h>
+
+GSource * _clutter_event_source_android_new (void);
+
+#endif /* __CLUTTER_EVENT_ANDROID_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]