egl: First attempt at cleaning up the EGL native backend
authorEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 3 Oct 2011 11:25:53 +0000 (12:25 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Thu, 3 Nov 2011 13:45:20 +0000 (13:45 +0000)
At least, let's make it compile when built along with the other
backends. In reality, it still needs to be verified as working.

clutter/Makefile.am
clutter/clutter-main.c
clutter/cogl/clutter-backend-cogl.c
clutter/cogl/clutter-stage-cogl.h
clutter/egl/clutter-backend-eglnative.c
clutter/egl/clutter-backend-eglnative.h
clutter/egl/clutter-egl.h
clutter/evdev/clutter-device-manager-evdev.c
clutter/tslib/clutter-event-tslib.c
clutter/tslib/clutter-event-tslib.h [new file with mode: 0644]
configure.ac

index 195cec5..6ee76e7 100644 (file)
@@ -528,6 +528,11 @@ egl_source_h = \
        $(srcdir)/egl/clutter-egl.h             \
        $(NULL)
 
+egl_source_h_priv = $(srcdir)/egl/clutter-backend-eglnative.h
+egl_source_c = $(srcdir)/egl/clutter-backend-eglnative.c
+egl_source_c_priv =
+
+egl_tslib_h = $(srcdir)/tslib/clutter-event-tslib.h
 egl_tslib_c = $(srcdir)/tslib/clutter-event-tslib.c
 
 evdev_c_priv = \
@@ -546,16 +551,17 @@ BUILT_SOURCES += $(cex_h)
 EXTRA_DIST += $(srcdir)/$(cex_h).in
 
 if USE_TSLIB
-backend_source_c_priv += $(egl_tslib_c)
+egl_source_c_priv += $(egl_tslib_c)
+egl_source_h_priv += $(egl_tslib_h)
 endif # SUPPORT_TSLIB
 
 if USE_EVDEV
-backend_source_c_priv += $(evdev_c_priv)
-backend_source_h_priv += $(evdev_h_priv)
+egl_source_c_priv += $(evdev_c_priv)
+egl_source_h_priv += $(evdev_h_priv)
 endif # SUPPORT_EVDEV
 
 if SUPPORT_CEX100
-backend_source_h += $(cex_h)
+egl_source_h += $(cex_h)
 
 clutter-cex100-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
        $(QUIET_GEN)cp -f $< $(@F)
@@ -567,6 +573,8 @@ endif # SUPPORT_CEX100
 
 if SUPPORT_EGL
 backend_source_h += $(egl_source_h)
+backend_source_c += $(egl_source_c)
+backend_source_h_priv += $(egl_source_h_priv)
 
 clutteregl_includedir = $(clutter_includedir)/egl
 clutteregl_include_HEADERS = $(egl_source_h)
index 888d215..29eda9e 100644 (file)
@@ -1342,7 +1342,7 @@ clutter_context_get_default_unlocked (void)
 #endif
 #ifdef CLUTTER_WINDOWING_EGL
       if (backend == NULL || strcmp (backend, CLUTTER_EGL_NATIVE_BACKEND) == 0)
-        ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_EGLNATIVE, NULL);
+        ctx->backend = g_object_new (CLUTTER_TYPE_BACKEND_EGL_NATIVE, NULL);
       else
 #endif
 #ifdef CLUTTER_WINDOWING_X11
@@ -3649,7 +3649,7 @@ clutter_check_backend (const char *backend_type)
   else
 #endif
 #ifdef CLUTTER_WINDOWING_EGL
-  if (strcmp (backend_type, CLUTTER_EGL_BACKEND) == 0 &&
+  if (strcmp (backend_type, CLUTTER_EGL_NATIVE_BACKEND) == 0 &&
       CLUTTER_IS_BACKEND_EGL_NATIVE (context->backend))
     return TRUE;
   else
index 588c4f9..af0ad14 100644 (file)
@@ -192,44 +192,16 @@ _clutter_backend_cogl_class_init (ClutterBackendCoglClass *klass)
   ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
 
   gobject_class->constructor = clutter_backend_cogl_constructor;
-  gobject_class->dispose     = clutter_backend_cogl_dispose;
-  gobject_class->finalize    = clutter_backend_cogl_finalize;
+  gobject_class->dispose = clutter_backend_cogl_dispose;
+  gobject_class->finalize = clutter_backend_cogl_finalize;
 
-  backend_class->pre_parse          = clutter_backend_cogl_pre_parse;
-  backend_class->post_parse         = clutter_backend_cogl_post_parse;
-  backend_class->get_features       = clutter_backend_cogl_get_features;
-  backend_class->ensure_context     = clutter_backend_cogl_ensure_context;
+  backend_class->pre_parse = clutter_backend_cogl_pre_parse;
+  backend_class->post_parse = clutter_backend_cogl_post_parse;
+  backend_class->get_features = clutter_backend_cogl_get_features;
+  backend_class->ensure_context = clutter_backend_cogl_ensure_context;
 }
 
 static void
 _clutter_backend_cogl_init (ClutterBackendCogl *backend_cogl)
 {
-
-}
-
-#ifdef COGL_HAS_EGL_SUPPORT
-EGLDisplay
-clutter_eglx_display (void)
-{
-  return clutter_egl_get_egl_display ();
-}
-
-EGLDisplay
-clutter_egl_display (void)
-{
-  return clutter_egl_get_egl_display ();
-}
-
-EGLDisplay
-clutter_egl_get_egl_display (void)
-{
-  if (backend_singleton == NULL)
-    {
-      g_critical ("%s has been called before clutter_init()", G_STRFUNC);
-      return 0;
-    }
-
-  return cogl_egl_context_get_egl_display (backend_singleton->cogl_context);
 }
-#endif
-
index b514c9b..d3a9b98 100644 (file)
@@ -1,10 +1,6 @@
 #ifndef __CLUTTER_STAGE_COGL_H__
 #define __CLUTTER_STAGE_COGL_H__
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include <glib-object.h>
 #include <cairo.h>
 #include <clutter/clutter-stage.h>
index 8568490..5735820 100644 (file)
@@ -26,9 +26,7 @@
  *  Neil Roberts
  */
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "clutter-device-manager-evdev.h"
 #endif
 
+#ifdef HAVE_TSLIB
+#include "clutter-event-tslib.h"
+#endif
+
 #include "clutter-debug.h"
 #include "clutter-private.h"
 #include "clutter-main.h"
@@ -54,6 +56,7 @@
 #ifdef COGL_HAS_EGL_SUPPORT
 #include "clutter-egl.h"
 #endif
+
 #ifdef CLUTTER_EGL_BACKEND_CEX100
 #include "clutter-cex100.h"
 #endif
@@ -63,10 +66,9 @@ static gdl_plane_id_t gdl_plane = GDL_PLANE_ID_UPP_C;
 static guint gdl_n_buffers = CLUTTER_CEX100_TRIPLE_BUFFERING;
 #endif
 
-static gboolean gdl_plane_set = FALSE;
-static gboolean gdl_n_buffers_set = FALSE;
+#define clutter_backend_egl_native_get_type     _clutter_backend_egl_native_get_type
 
-G_DEFINE_TYPE (ClutterBackendEglNative, _clutter_backend_egl_native, CLUTTER_TYPE_BACKEND_COGL);
+G_DEFINE_TYPE (ClutterBackendEglNative, clutter_backend_egl_native, CLUTTER_TYPE_BACKEND_COGL);
 
 static ClutterDeviceManager *
 clutter_backend_egl_native_get_device_manager (ClutterBackend *backend)
@@ -89,31 +91,54 @@ clutter_backend_egl_native_get_device_manager (ClutterBackend *backend)
 static void
 clutter_backend_egl_native_init_events (ClutterBackend *backend)
 {
-#ifdef HAVE_TSLIB
-  _clutter_events_tslib_init (CLUTTER_BACKEND_EGL (backend));
-#endif
+  const char *input_backend = NULL;
+
+  input_backend = g_getenv ("CLUTTER_INPUT_BACKEND");
 
 #ifdef HAVE_EVDEV
-  _clutter_events_evdev_init (CLUTTER_BACKEND (backend));
+  if (input_backend != NULL &&
+      strcmp (input_backend, CLUTTER_EVDEV_INPUT_BACKEND) == 0)
+    _clutter_events_evdev_init (CLUTTER_BACKEND (backend));
+  else
 #endif
+#ifdef HAVE_TSLIB
+  if (input_backend != NULL &&
+      strcmp (input_backend, CLUTTER_TSLIB_INPUT_BACKEND) == 0)
+    _clutter_events_tslib_init (CLUTTER_BACKEND (backend));
+  else
+#endif
+  if (input_backend != NULL)
+    g_error ("Unrecognized input backend '%s'", input_backend);
+  else
+    g_error ("Unknown input backend");
 }
 
 static void
-clutter_backend_cogl_dispose (GObject *gobject)
+clutter_backend_egl_native_dispose (GObject *gobject)
 {
-#ifdef HAVE_TSLIB
   ClutterBackendEglNative *backend_egl_native = CLUTTER_BACKEND_EGL_NATIVE (gobject);
 
-  _clutter_events_tslib_uninit (backend_egl_native);
-
   if (backend_egl_native->event_timer != NULL)
     {
       g_timer_destroy (backend_egl_native->event_timer);
       backend_egl_native->event_timer = NULL;
     }
+
+#ifdef HAVE_TSLIB
+  _clutter_events_tslib_uninit (CLUTTER_BACKEND (gobject));
+#endif
+
+#ifdef HAVE_EVDEV
+  _clutter_events_evdev_uninit (CLUTTER_BACKEND (gobject));
+
+  if (backend_egl_native->device_manager != NULL)
+    {
+      g_object_unref (backend_egl_native->device_manager);
+      backend_egl_native->device_manager = NULL;
+    }
 #endif
 
-  G_OBJECT_CLASS (_clutter_backend_cogl_parent_class)->dispose (gobject);
+  G_OBJECT_CLASS (clutter_backend_egl_native_parent_class)->dispose (gobject);
 }
 
 static ClutterStageWindow *
@@ -123,7 +148,6 @@ clutter_backend_egl_native_create_stage (ClutterBackend  *backend,
 {
   ClutterBackendEglNative *backend_egl_native = CLUTTER_BACKEND_EGL_NATIVE (backend);
   ClutterStageWindow *stage;
-  ClutterStageCogl *stage_cogl;
 
   if (G_UNLIKELY (backend_egl_native->stage != NULL))
     {
@@ -159,8 +183,9 @@ clutter_backend_egl_native_create_context (ClutterBackend  *backend,
 
   swap_chain = cogl_swap_chain_new ();
 
-  if (gdl_n_buffers_set)
-    cogl_swap_chain_set_length (swap_chain, gdl_n_buffers);
+#if defined(CLUTTER_EGL_BACKEND_CEX100) && defined(COGL_HAS_GDL_SUPPORT)
+  cogl_swap_chain_set_length (swap_chain, gdl_n_buffers);
+#endif
 
   onscreen_template = cogl_onscreen_template_new (swap_chain);
   cogl_object_unref (swap_chain);
@@ -177,9 +202,8 @@ clutter_backend_egl_native_create_context (ClutterBackend  *backend,
   backend->cogl_display = cogl_display_new (backend->cogl_renderer,
                                             onscreen_template);
 
-#ifdef CLUTTER_EGL_BACKEND_CEX100
-  if (gdl_plane_set)
-    cogl_gdl_display_set_plane (backend->cogl_display, gdl_plane);
+#if defined(CLUTTER_EGL_BACKEND_CEX100) && defined(COGL_HAS_GDL_SUPPORT)
+  cogl_gdl_display_set_plane (backend->cogl_display, gdl_plane);
 #endif /* CLUTTER_EGL_BACKEND_CEX100 */
 
   cogl_object_unref (backend->cogl_renderer);
@@ -203,6 +227,7 @@ error:
 
   if (onscreen_template != NULL)
     cogl_object_unref (onscreen_template);
+
   if (swap_chain != NULL)
     cogl_object_unref (swap_chain);
 
@@ -211,32 +236,31 @@ error:
       cogl_object_unref (backend->cogl_renderer);
       backend->cogl_renderer = NULL;
     }
+
   return FALSE;
 }
 
 static void
-_clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
+clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
 
-  gobject_class->dispose     = clutter_backend_egl_native_dispose;
-  gobject_class->finalize    = clutter_backend_egl_native_finalize;
+  gobject_class->dispose = clutter_backend_egl_native_dispose;
 
   backend_class->get_device_manager = clutter_backend_egl_native_get_device_manager;
-  backend_class->init_events        = clutter_backend_egl_native_init_events;
-  backend_class->create_stage       = clutter_backend_egl_native_create_stage;
-  backend_class->create_context     = clutter_backend_egl_native_create_context;
+  backend_class->init_events = clutter_backend_egl_native_init_events;
+  backend_class->create_stage = clutter_backend_egl_native_create_stage;
+  backend_class->create_context = clutter_backend_egl_native_create_context;
 }
 
 static void
-_clutter_backend_egl_native_init (ClutterBackendEglNative *backend_egl_native)
+clutter_backend_egl_native_init (ClutterBackendEglNative *backend_egl_native)
 {
-#ifdef HAVE_TSLIB
   backend_egl_native->event_timer = g_timer_new ();
-#endif
 }
 
+#ifdef CLUTTER_EGL_BACKEND_CEX100
 /**
  * clutter_cex100_set_plane:
  * @plane: FIXME
@@ -248,14 +272,13 @@ _clutter_backend_egl_native_init (ClutterBackendEglNative *backend_egl_native)
 void
 clutter_cex100_set_plane (gdl_plane_id_t plane)
 {
-#ifdef CLUTTER_EGL_BACKEND_CEX100
   g_return_if_fail (plane >= GDL_PLANE_ID_UPP_A && plane <= GDL_PLANE_ID_UPP_E);
 
   gdl_plane = plane;
-  gdl_plane_set = TRUE;
-#endif
 }
+#endif
 
+#ifdef CLUTTER_EGL_BACKEND_CEX100
 /**
  * clutter_cex100_set_plane:
  * @mode: FIXME
@@ -267,11 +290,79 @@ clutter_cex100_set_plane (gdl_plane_id_t plane)
 void
 clutter_cex100_set_buffering_mode (ClutterCex100BufferingMode mode)
 {
-#ifdef CLUTTER_EGL_BACKEND_CEX100
   g_return_if_fail (mode == CLUTTER_CEX100_DOUBLE_BUFFERING ||
                     mode == CLUTTER_CEX100_TRIPLE_BUFFERING);
 
   gdl_n_buffers = mode;
-  gdl_n_buffers_set = TRUE;
+}
+#endif
+
+/**
+ * clutter_eglx_display:
+ *
+ * Retrieves the EGL display used by Clutter.
+ *
+ * Return value: the EGL display, or 0
+ *
+ * Since: 0.6
+ *
+ * Deprecated: 1.6: Use clutter_egl_get_egl_display() instead.
+ */
+EGLDisplay
+clutter_eglx_display (void)
+{
+  return clutter_egl_get_egl_display ();
+}
+
+/**
+ * clutter_egl_display:
+ *
+ * Retrieves the EGL display used by Clutter.
+ *
+ * Return value: the EGL display used by Clutter, or 0
+ *
+ * Since: 0.6
+ *
+ * Deprecated: 1.6: Use clutter_egl_get_egl_display() instead.
+ */
+EGLDisplay
+clutter_egl_display (void)
+{
+  return clutter_egl_get_egl_display ();
+}
+
+/**
+ * clutter_egl_get_egl_display:
+ *
+ * Retrieves the EGL display used by Clutter, if it supports the
+ * EGL windowing system and if it is running using an EGL backend.
+ *
+ * Return value: the EGL display used by Clutter, or 0
+ *
+ * Since: 1.6
+ */
+EGLDisplay
+clutter_egl_get_egl_display (void)
+{
+  ClutterBackend *backend;
+
+  if (!_clutter_context_is_initialized ())
+    {
+      g_critical ("The Clutter backend has not been initialized yet");
+      return 0;
+    }
+
+  backend = clutter_get_default_backend ();
+
+  if (!CLUTTER_IS_BACKEND_EGL_NATIVE (backend))
+    {
+      g_critical ("The Clutter backend is not an EGL backend");
+      return 0;
+    }
+
+#if COGL_HAS_EGL_SUPPORT
+  return cogl_egl_context_get_egl_display (backend->cogl_context);
+#else
+  return 0;
 #endif
 }
index 959e61c..5156339 100644 (file)
@@ -70,11 +70,6 @@ struct _ClutterBackendEglNativeClass
 
 GType _clutter_backend_egl_native_get_type (void) G_GNUC_CONST;
 
-#ifdef HAVE_TSLIB
-void _clutter_events_tslib_init   (ClutterBackendEglNative *backend);
-void _clutter_events_tslib_uninit (ClutterBackendEglNative *backend);
-#endif
-
 G_END_DECLS
 
 #endif /* __CLUTTER_BACKEND_EGL_NATIVE_H__ */
index 9371039..193290a 100644 (file)
@@ -49,6 +49,9 @@
 
 G_BEGIN_DECLS
 
+#define CLUTTER_TSLIB_INPUT_BACKEND     "tslib"
+#define CLUTTER_EVDEV_INPUT_BACKEND     "evdev"
+
 #ifndef CLUTTER_DISABLE_DEPRECATED
 /**
  * clutter_eglx_display:
index 03d08be..edc01bf 100644 (file)
@@ -855,17 +855,16 @@ clutter_device_manager_evdev_init (ClutterDeviceManagerEvdev *self)
 void
 _clutter_events_evdev_init (ClutterBackend *backend)
 {
+  ClutterDeviceManager *dummy G_GNUC_UNUSED;
+
   CLUTTER_NOTE (EVENT, "Initializing evdev backend");
 
-  /* We just have to create the singleon here */
-  clutter_device_manager_get_default ();
+  /* we need to create the device manager here */
+  dummy = clutter_device_manager_get_default ();
 }
 
 void
 _clutter_events_evdev_uninit (ClutterBackend *backend)
 {
-  ClutterDeviceManager *manager;
-
-  manager = clutter_device_manager_get_default ();
-  g_object_unref (manager);
+  CLUTTER_NOTE (EVENT, "Uninitializing evdev backend");
 }
index c02cb0c..045412f 100644 (file)
@@ -19,9 +19,7 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include "clutter-backend-egl.h"
 #include "clutter-egl.h"
@@ -36,9 +34,7 @@
 
 #include <glib.h>
 
-#ifdef HAVE_TSLIB
 #include <tslib.h>
-#endif
 
 typedef struct _ClutterEventSource  ClutterEventSource;
 
@@ -49,13 +45,9 @@ struct _ClutterEventSource
   ClutterBackendEGL *backend;
   GPollFD event_poll_fd;
 
-#ifdef HAVE_TSLIB
-  struct tsdev   *ts_device;
-#endif
+  struct tsdev *ts_device;
 };
 
-#ifdef HAVE_TSLIB
-
 static gboolean clutter_event_prepare  (GSource     *source,
                                         gint        *timeout);
 static gboolean clutter_event_check    (GSource     *source);
@@ -92,16 +84,17 @@ get_backend_time (void)
 
   return g_timer_elapsed (backend_egl->event_timer, NULL) * 1000;
 }
-#endif
 
 void
-_clutter_events_tslib_init (ClutterBackendEglNative *backend_egl)
+_clutter_events_tslib_init (ClutterBackend *backend)
 {
-#ifdef HAVE_TSLIB
+  ClutterBackendEglNative *backend_egl;
   ClutterEventSource *event_source;
   const char *device_name;
   GSource *source;
 
+  backend_egl = CLUTTER_BACKEND_EGL (backend);
+
   CLUTTER_NOTE (EVENT, "Starting timer");
   g_assert (backend_egl->event_timer != NULL);
   g_timer_start (backend_egl->event_timer);
@@ -147,13 +140,11 @@ _clutter_events_tslib_init (ClutterBackendEglNative *backend_egl)
       g_warning ("Unable to open '%s'", device_name);
       g_source_unref (source);
     }
-#endif /* HAVE_TSLIB */
 }
 
 void
 _clutter_events_egl_uninit (ClutterBackendEglNative *backend_egl)
 {
-#ifdef HAVE_TSLIB
   if (backend_egl->event_timer != NULL)
     {
       CLUTTER_NOTE (EVENT, "Stopping the timer");
@@ -174,11 +165,8 @@ _clutter_events_egl_uninit (ClutterBackendEglNative *backend_egl)
       g_source_unref (backend_egl->event_source);
       backend_egl->event_source = NULL;
     }
-#endif /* HAVE_TSLIB */
 }
 
-#ifdef HAVE_TSLIB
-
 static gboolean
 clutter_event_prepare (GSource *source,
                        gint    *timeout)
@@ -226,7 +214,7 @@ clutter_event_dispatch (GSource     *source,
   if ((!clutter_events_pending()) &&
       (ts_read(event_source->ts_device, &tsevent, 1) == 1))
     {
-      static gint     last_x = 0, last_y = 0;
+      static gint last_x = 0, last_y = 0;
       static gboolean clicked = FALSE;
 
       /* Avoid sending too many events which are just pressure changes.
@@ -289,5 +277,3 @@ out:
 
   return TRUE;
 }
-
-#endif
diff --git a/clutter/tslib/clutter-event-tslib.h b/clutter/tslib/clutter-event-tslib.h
new file mode 100644 (file)
index 0000000..423633a
--- /dev/null
@@ -0,0 +1,35 @@
+/* Clutter.
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2006, 2007 OpenedHand
+ * Copyright (C) 2008, 2009, 2010, 2011  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/>.
+ *
+ *
+ */
+
+#ifndef __CLUTTER_EVENT_TSLIB_H__
+#define __CLUTTER_EVENT_TSLIB_H__
+
+#include <clutter/clutter-backend.h>
+
+G_BEGIN_DECLS
+
+void _clutter_events_tslib_init   (ClutterBackend *backend);
+void _clutter_events_tslib_uninit (ClutterBackend *backend);
+
+G_END_DECLS
+
+#endif /* __CLUTTER_EVENT_TSLIB_H__ */
index b709ed2..56d4349 100644 (file)
@@ -215,15 +215,15 @@ AC_ARG_ENABLE([osx],
 AC_ARG_ENABLE([gdk],
               [AS_HELP_STRING([--enable-gdk=@<:@yes/no@:>@], [Enable the GDK backend (default=no)])],
               [],
-              [enable_gdk=no])
+              [enable_gdk=maybe])
 AC_ARG_ENABLE([wayland],
               [AS_HELP_STRING([--enable-wayland=@<:@yes/no@:>@], [Enable the Wayland client backend (default=no)])],
               [],
-              [enable_wayland=no])
+              [enable_wayland=maybe])
 AC_ARG_ENABLE([egl],
-              [AS_HELP_STRING([--enable-egl=@<:@yes/no@:>@], [Enable the EGL framebuffer backend (default=no)])]
+              [AS_HELP_STRING([--enable-egl=@<:@yes/no@:>@], [Enable the EGL framebuffer backend (default=no)])],
               [],
-              [enable_egl=no])
+              [enable_egl=maybe])
 
 dnl Define default values
 AS_IF([test "x$platform_glx" = "xyes"], [enable_x11=yes])
@@ -245,14 +245,6 @@ AS_IF([test "x$enable_x11" = "xyes"],
                          [BACKEND_PC_FILES="$BACKEND_PC_FILES gl"],
                          [FLAVOUR_LIBS="$FLAVOUR_LIBS -lGL"])
 
-        # if Mesa has support for egl, we can use it as well
-        PKG_CHECK_EXISTS([egl],
-                         [
-                           BACKEND_PC_FILES="$BACKEND_PC_FILES egl"
-                           SUPPORT_EGL=1
-                         ],
-                         [])
-
         # We might fall back to DRM for sync-to-vblank on GLX
         PKG_CHECK_EXISTS([libdrm],
                          [
@@ -291,6 +283,7 @@ AS_IF([test "x$enable_wayland" = "xyes"],
         experimental_backend="yes"
 
         SUPPORT_WAYLAND=1
+        SUPPORT_EVDEV=1
 
         PKG_CHECK_EXISTS([gl], [BACKEND_PC_FILES="$BACKEND_PC_FILES gl"], [])
         PKG_CHECK_EXISTS([egl], [BACKEND_PC_FILES="$BACKEND_PC_FILES egl"], [])
@@ -308,6 +301,13 @@ AS_IF([test "x$enable_egl" = "xyes"],
         SUPPORT_EGL=1
         SUPPORT_COGL=1
 
+        # if Mesa has support for egl, we can use it as well
+        PKG_CHECK_EXISTS([egl],
+                         [
+                           BACKEND_PC_FILES="$BACKEND_PC_FILES egl"
+                         ],
+                         [])
+
         AC_ARG_WITH([tslib],
                     [AS_HELP_STRING([--with-tslib=@<:@yes/no@:>@], [Use TSLib for events])],
                     [],
@@ -329,8 +329,10 @@ AS_IF([test "x$enable_egl" = "xyes"],
                 AS_IF([test "x$have_tslib" = "xyes"],
                       [
                         AC_DEFINE([HAVE_TSLIB], [1], [Have tslib for touchscreen handling])
+                        SUPPORT_TSLIB=1
                       ])
-              ])
+              ],
+              [have_tslib=no])
 
         AS_IF([test "x$with_evdev" = "xyes"],
               [
@@ -338,8 +340,10 @@ AS_IF([test "x$enable_egl" = "xyes"],
                 AS_IF([test "x$have_evdev" = "xyes"],
                       [
                         AC_DEFINE([HAVE_EVDEV], [1], [Have evdev support for input handling])
+                        SUPPORT_EVDEV=1
                       ])
-              ])
+              ],
+              [have_evdev=no])
 
         AS_IF([test "x$with_gdl" = "xyes"],
               [
@@ -366,14 +370,8 @@ AS_IF([test "x$enable_egl" = "xyes"],
                 SUPPORT_EGL_PLATFORM_GDL=1
 
                 AC_DEFINE([CLUTTER_EGL_BACKEND_CEX100], [1], [Use CEX100 EGL backend])
-              ])
-
-        # Make sure we don't enable tslib and evdev at the same time, we
-        # don't support multiple event backends yet.
-        AS_IF([test "x$have_tslib" = "xyes" -a "x$have_evdev" = "xyes"],
-              [
-                AC_MSG_ERROR([Cannot enable both tslib and evdev events])
-              ])
+              ],
+              [have_gdl=no])
 
         FLAVOUR_LIBS="$FLAVOUR_LIBS $TSLIB_LIBS $EVDEV_LIBS"
         FLAVOUR_CFLAGS="$FLAVOUR_CFLAGS $TSLIB_CFLAGS $EVDEV_CFLAGS"
@@ -471,6 +469,12 @@ AS_IF([test "x$SUPPORT_WIN32" = "x1"],
 AS_IF([test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"],
       [CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
 #define CLUTTER_WINDOWING_CEX100 1"])
+AS_IF([test "x$SUPPORT_EVDEV" = "x1"],
+      [CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
+#define CLUTTER_WINDOWING_EVDEV 1"])
+AS_IF([test "x$SUPPORT_TSLIB" = "x1"],
+      [CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
+#define CLUTTER_WINDOWING_TSLIB 1"])
 
 AC_SUBST([CLUTTER_CONFIG_DEFINES])