[clutter/multi-backend: 20/22] Clean up the windowing system defines
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/multi-backend: 20/22] Clean up the windowing system defines
- Date: Mon, 24 Oct 2011 14:04:16 +0000 (UTC)
commit 8b0adb50fa2bf8a6a7b748b794a80b69c54e42dd
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Mon Oct 17 16:03:19 2011 +0100
Clean up the windowing system defines
Instead of defining new symbols for the windowing systems enabled at
configure time, we can reuse the same symbols for both the compile time
and run time checks, e.g.:
#ifdef CLUTTER_WINDOWING_X11
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11))
/* use the clutter_x11_* API */
else
#endif
#ifdef CLUTTER_WINDOWING_WIN32
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WIN32))
/* use the clutter_win32_* API */
#endif
This scheme allows us to ensure that the input system namespace is free
for us to use and select at run time in later versions of Clutter.
clutter/clutter-backend-private.h | 3 +
clutter/clutter-backend.h | 77 +---------------------------------
clutter/clutter-main.c | 83 ++++++++++++++++++++++++-------------
clutter/clutter-version.h.in | 2 +-
configure.ac | 20 ++++----
5 files changed, 71 insertions(+), 114 deletions(-)
---
diff --git a/clutter/clutter-backend-private.h b/clutter/clutter-backend-private.h
index be7b58f..71b80a3 100644
--- a/clutter/clutter-backend-private.h
+++ b/clutter/clutter-backend-private.h
@@ -23,6 +23,9 @@
#define __CLUTTER_BACKEND_PRIVATE_H__
#include <clutter/clutter-backend.h>
+#include <clutter/clutter-device-manager.h>
+#include <clutter/clutter-stage-window.h>
+
#include "clutter-event-translator.h"
#define CLUTTER_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND, ClutterBackendClass))
diff --git a/clutter/clutter-backend.h b/clutter/clutter-backend.h
index c51c8dd..60c9fd0 100644
--- a/clutter/clutter-backend.h
+++ b/clutter/clutter-backend.h
@@ -29,18 +29,14 @@
#define __CLUTTER_BACKEND_H__
#include <cairo.h>
-#include <glib-object.h>
#include <pango/pango.h>
+
#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
#include <cogl/cogl.h>
#endif
-#include <clutter/clutter-actor.h>
-#include <clutter/clutter-device-manager.h>
-#include <clutter/clutter-event.h>
-#include <clutter/clutter-feature.h>
-#include <clutter/clutter-stage.h>
-#include <clutter/clutter-stage-window.h>
+#include <clutter/clutter-config.h>
+#include <clutter/clutter-types.h>
G_BEGIN_DECLS
@@ -49,73 +45,6 @@ G_BEGIN_DECLS
#define CLUTTER_IS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND))
/**
- * CLUTTER_OSX_BACKEND:
- *
- * Evaluates to the symbolic name of the Quartz Clutter backend.
- *
- * This macro should be used with clutter_check_backend().
- *
- * Since: 1.10
- */
-#define CLUTTER_OSX_BACKEND "osx"
-
-/**
- * CLUTTER_X11_BACKEND:
- *
- * Evaluates to the symbolic name of the X11 Clutter backend.
- *
- * This macro should be used with clutter_check_backend().
- *
- * Since: 1.10
- */
-
-#define CLUTTER_X11_BACKEND "x11"
-
-/**
- * CLUTTER_WIN32_BACKEND:
- *
- * Evaluates to the symbolic name of the Windows Clutter backend.
- *
- * This macro should be used with clutter_check_backend().
- *
- * Since: 1.10
- */
-#define CLUTTER_WIN32_BACKEND "win32"
-
-/**
- * CLUTTER_EGL_NATIVE_BACKEND:
- *
- * Evaluates to the symbolic name of the EGL framebuffer Clutter backend.
- *
- * This macro should be used with clutter_check_backend().
- *
- * Since: 1.10
- */
-#define CLUTTER_EGL_NATIVE_BACKEND "eglnative"
-
-/**
- * CLUTTER_WAYLAND_BACKEND:
- *
- * Evaluates to the symbolic name of the Wayland client Clutter backend.
- *
- * This macro should be used with clutter_check_backend().
- *
- * Since: 1.10
- */
-#define CLUTTER_WAYLAND_BACKEND "wayland"
-
-/**
- * CLUTTER_GDK_BACKEND:
- *
- * Evaluates to the symbolic name of the GDK Clutter backend.
- *
- * This macro should be used with clutter_check_backend().
- *
- * Since: 1.10
- */
-#define CLUTTER_GDK_BACKEND "gdk"
-
-/**
* ClutterBackend:
*
* <structname>ClutterBackend</structname> is an opaque structure whose
diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c
index ce3f118..defd856 100644
--- a/clutter/clutter-main.c
+++ b/clutter/clutter-main.c
@@ -1313,44 +1313,43 @@ clutter_create_backend (void)
const char *backend = g_getenv ("CLUTTER_BACKEND");
ClutterBackend *retval = NULL;
+ if (backend != NULL)
+ backend = g_intern_string (backend);
+
#ifdef CLUTTER_WINDOWING_OSX
- if (backend == NULL || strcmp (backend, CLUTTER_OSX_BACKEND) == 0)
+ if (backend == NULL || backend == I_(CLUTTER_WINDOWING_OSX))
retval = g_object_new (CLUTTER_TYPE_BACKEND_OSX, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_WIN32
- if (backend == NULL || strcmp (backend, CLUTTER_WIN32_BACKEND) == 0)
+ if (backend == NULL || backend == I_(CLUTTER_WINDOWING_WIN32))
retval = g_object_new (CLUTTER_TYPE_BACKEND_WIN32, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_WAYLAND
- if (backend == NULL || strcmp (backend, CLUTTER_WAYLAND_BACKEND) == 0)
+ if (backend == NULL || backend == I_(CLUTTER_WINDOWING_WAYLAND))
retval = g_object_new (CLUTTER_TYPE_BACKEND_WAYLAND, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_EGL
- if (backend == NULL || strcmp (backend, CLUTTER_EGL_NATIVE_BACKEND) == 0)
+ if (backend == NULL || backend == I_(CLUTTER_WINDOWING_EGL))
retval = g_object_new (CLUTTER_TYPE_BACKEND_EGL_NATIVE, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_X11
- if (backend == NULL || strcmp (backend, CLUTTER_X11_BACKEND) == 0)
+ if (backend == NULL || backend == I_(CLUTTER_WINDOWING_X11))
retval = g_object_new (CLUTTER_TYPE_BACKEND_X11, NULL);
else
#endif
#ifdef CLUTTER_WINDOWING_GDK
- if (backend == NULL || strcmp (backend, CLUTTER_GDK_BACKEND) == 0)
+ if (backend == NULL || backend == I_(CLUTTER_WINDOWING_GDK))
retval = g_object_new (CLUTTER_TYPE_BACKEND_GDK, NULL);
else
#endif
- if (backend != NULL)
- g_error ("Unsupported Clutter backend: '%s'", backend);
- else
+ if (backend == NULL)
g_error ("No default Clutter backend found.");
-
- CLUTTER_NOTE (BACKEND, "Backend type: '%s' (requested: '%s')",
- G_OBJECT_TYPE_NAME (retval),
- backend != NULL ? backend : "<default>");
+ else
+ g_error ("Unsupported Clutter backend: '%s'", backend);
return retval;
}
@@ -3615,57 +3614,83 @@ _clutter_context_get_motion_events_enabled (void)
}
/**
- * clutter_check_backend:
+ * clutter_check_windowing_backend:
* @backend_type: the name of the backend to check
*
- * Checks the run-time name of the Clutter backend, using the symbolic
- * macros like %CLUTTER_OSX_BACKEND or %CLUTTER_X11_BACKEND.
+ * Checks the run-time name of the Clutter windowing system backend, using
+ * the symbolic macros like %CLUTTER_WINDOWING_WIN32 or
+ * %CLUTTER_WINDOWING_X11.
+ *
+ * This function should be used in conjuction with the compile-time macros
+ * inside applications and libraries that are using the platform-specific
+ * windowing system API, to ensure that they are running on the correct
+ * windowing system; for instance:
*
- * Return value: %TRUE if the current Clutter backend is the one checked,
- * and %FALSE otherwise
+ * |[
+ * #ifdef CLUTTER_WINDOWING_X11
+ * if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11))
+ * {
+ * /* it is safe to use the clutter_x11_* API */
+ * }
+ * else
+ * #endif
+ * #ifdef CLUTTER_WINDOWING_WIN32
+ * if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WIN32))
+ * {
+ * /* it is safe to use the clutter_win32_* API */
+ * }
+ * else
+ * #endif
+ * g_error ("Unknown Clutter backend.");
+ * ]|
+ *
+ * Return value: %TRUE if the current Clutter windowing system backend is
+ * the one checked, and %FALSE otherwise
*
* Since: 1.10
*/
gboolean
-clutter_check_backend (const char *backend_type)
+clutter_check_windowing_backend (const char *backend_type)
{
ClutterMainContext *context = _clutter_context_get_default ();
g_return_val_if_fail (backend_type != NULL, FALSE);
+ backend_type = g_intern_string (backend_type);
+
#ifdef CLUTTER_WINDOWING_OSX
- if (strcmp (backend_type, CLUTTER_OSX_BACKEND) == 0 &&
+ if (backend_type == I_(CLUTTER_WINDOWING_OSX) &&
CLUTTER_IS_BACKEND_OSX (context->backend))
return TRUE;
else
#endif
#ifdef CLUTTER_WINDOWING_WIN32
- if (strcmp (backend_type, CLUTTER_WIN32_BACKEND) == 0 &&
+ if (backend_type == I_(CLUTTER_WINDOWING_WIN32) &&
CLUTTER_IS_BACKEND_WIN32 (context->backend))
return TRUE;
else
#endif
#ifdef CLUTTER_WINDOWING_WAYLAND
- if (strcmp (backend_type, CLUTTER_WAYLAND_BACKEND) == 0 &&
+ if (backend_type == I_(CLUTTER_WINDOWING_WAYLAND) &&
CLUTTER_IS_BACKEND_WAYLAND (context->backend))
return TRUE;
else
#endif
#ifdef CLUTTER_WINDOWING_EGL
- if (strcmp (backend_type, CLUTTER_EGL_NATIVE_BACKEND) == 0 &&
+ if (backend_type == I_(CLUTTER_WINDOWING_EGL) &&
CLUTTER_IS_BACKEND_EGL_NATIVE (context->backend))
return TRUE;
else
#endif
-#ifdef CLUTTER_WINDOWING_X11
- if (strcmp (backend_type, CLUTTER_X11_BACKEND) == 0 &&
- CLUTTER_IS_BACKEND_X11 (context->backend))
+#ifdef CLUTTER_WINDOWING_GDK
+ if (backend_type == I_(CLUTTER_WINDOWING_GDK) &&
+ CLUTTER_IS_BACKEND_GDK (context->backend))
return TRUE;
else
#endif
-#ifdef CLUTTER_WINDOWING_GDK
- if (strcmp (backend_type, CLUTTER_GDK_BACKEND) == 0 &&
- CLUTTER_IS_BACKEND_GDK (context->backend))
+#ifdef CLUTTER_WINDOWING_X11
+ if (backend_type == I_(CLUTTER_WINDOWING_X11) &&
+ CLUTTER_IS_BACKEND_X11 (context->backend))
return TRUE;
else
#endif
diff --git a/clutter/clutter-version.h.in b/clutter/clutter-version.h.in
index 5b38ee0..a08d768 100644
--- a/clutter/clutter-version.h.in
+++ b/clutter/clutter-version.h.in
@@ -195,7 +195,7 @@ gboolean clutter_check_version (guint major,
guint minor,
guint micro);
-gboolean clutter_check_backend (const char *backend_type);
+gboolean clutter_check_windowing_backend (const char *backend_type);
G_END_DECLS
diff --git a/configure.ac b/configure.ac
index bc489e6..23aec9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -460,34 +460,34 @@ CLUTTER_CONFIG_DEFINES=
# windowing systems
AS_IF([test "x$SUPPORT_X11" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_X11 1"])
+#define CLUTTER_WINDOWING_X11 \"x11\""])
AS_IF([test "x$SUPPORT_GDK" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_GDK 1"])
+#define CLUTTER_WINDOWING_GDK \"gdk\""])
AS_IF([test "x$SUPPORT_GLX" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_GLX 1"])
+#define CLUTTER_WINDOWING_GLX \"glx\""])
AS_IF([test "x$SUPPORT_EGL" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_EGL 1"])
+#define CLUTTER_WINDOWING_EGL \"eglnative\""])
AS_IF([test "x$SUPPORT_WAYLAND" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_WAYLAND 1"])
+#define CLUTTER_WINDOWING_WAYLAND \"wayland\""])
AS_IF([test "x$SUPPORT_OSX" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_OSX 1"])
+#define CLUTTER_WINDOWING_OSX \"osx\""])
AS_IF([test "x$SUPPORT_WIN32" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_WIN32 1"])
+#define CLUTTER_WINDOWING_WIN32 \"win32\""])
AS_IF([test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_CEX100 1"])
+#define CLUTTER_WINDOWING_CEX100 \"cex100\""])
AS_IF([test "x$SUPPORT_EVDEV" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_EVDEV 1"])
+#define CLUTTER_INPUT_EVDEV \"evdev\""])
AS_IF([test "x$SUPPORT_TSLIB" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
-#define CLUTTER_WINDOWING_TSLIB 1"])
+#define CLUTTER_INPUT_TSLIB \"tslib\""])
AC_SUBST([CLUTTER_CONFIG_DEFINES])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]