mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 03:20:46 -05:00
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.
This commit is contained in:
parent
98c177def5
commit
8249e48802
@ -23,6 +23,9 @@
|
|||||||
#define __CLUTTER_BACKEND_PRIVATE_H__
|
#define __CLUTTER_BACKEND_PRIVATE_H__
|
||||||
|
|
||||||
#include <clutter/clutter-backend.h>
|
#include <clutter/clutter-backend.h>
|
||||||
|
#include <clutter/clutter-device-manager.h>
|
||||||
|
#include <clutter/clutter-stage-window.h>
|
||||||
|
|
||||||
#include "clutter-event-translator.h"
|
#include "clutter-event-translator.h"
|
||||||
|
|
||||||
#define CLUTTER_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND, ClutterBackendClass))
|
#define CLUTTER_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND, ClutterBackendClass))
|
||||||
|
@ -29,18 +29,14 @@
|
|||||||
#define __CLUTTER_BACKEND_H__
|
#define __CLUTTER_BACKEND_H__
|
||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <glib-object.h>
|
|
||||||
#include <pango/pango.h>
|
#include <pango/pango.h>
|
||||||
|
|
||||||
#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
|
#ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API
|
||||||
#include <cogl/cogl.h>
|
#include <cogl/cogl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <clutter/clutter-actor.h>
|
#include <clutter/clutter-config.h>
|
||||||
#include <clutter/clutter-device-manager.h>
|
#include <clutter/clutter-types.h>
|
||||||
#include <clutter/clutter-event.h>
|
|
||||||
#include <clutter/clutter-feature.h>
|
|
||||||
#include <clutter/clutter-stage.h>
|
|
||||||
#include <clutter/clutter-stage-window.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -48,73 +44,6 @@ G_BEGIN_DECLS
|
|||||||
#define CLUTTER_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND, ClutterBackend))
|
#define CLUTTER_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND, ClutterBackend))
|
||||||
#define CLUTTER_IS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND))
|
#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:
|
* ClutterBackend:
|
||||||
*
|
*
|
||||||
|
@ -1319,44 +1319,43 @@ clutter_create_backend (void)
|
|||||||
const char *backend = g_getenv ("CLUTTER_BACKEND");
|
const char *backend = g_getenv ("CLUTTER_BACKEND");
|
||||||
ClutterBackend *retval = NULL;
|
ClutterBackend *retval = NULL;
|
||||||
|
|
||||||
|
if (backend != NULL)
|
||||||
|
backend = g_intern_string (backend);
|
||||||
|
|
||||||
#ifdef CLUTTER_WINDOWING_OSX
|
#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);
|
retval = g_object_new (CLUTTER_TYPE_BACKEND_OSX, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_WIN32
|
#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);
|
retval = g_object_new (CLUTTER_TYPE_BACKEND_WIN32, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_WAYLAND
|
#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);
|
retval = g_object_new (CLUTTER_TYPE_BACKEND_WAYLAND, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_EGL
|
#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);
|
retval = g_object_new (CLUTTER_TYPE_BACKEND_EGL_NATIVE, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_X11
|
#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);
|
retval = g_object_new (CLUTTER_TYPE_BACKEND_X11, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_GDK
|
#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);
|
retval = g_object_new (CLUTTER_TYPE_BACKEND_GDK, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (backend != NULL)
|
if (backend == NULL)
|
||||||
g_error ("Unsupported Clutter backend: '%s'", backend);
|
|
||||||
else
|
|
||||||
g_error ("No default Clutter backend found.");
|
g_error ("No default Clutter backend found.");
|
||||||
|
else
|
||||||
CLUTTER_NOTE (BACKEND, "Backend type: '%s' (requested: '%s')",
|
g_error ("Unsupported Clutter backend: '%s'", backend);
|
||||||
G_OBJECT_TYPE_NAME (retval),
|
|
||||||
backend != NULL ? backend : "<default>");
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -3621,57 +3620,83 @@ _clutter_context_get_motion_events_enabled (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_check_backend:
|
* clutter_check_windowing_backend:
|
||||||
* @backend_type: the name of the backend to check
|
* @backend_type: the name of the backend to check
|
||||||
*
|
*
|
||||||
* Checks the run-time name of the Clutter backend, using the symbolic
|
* Checks the run-time name of the Clutter windowing system backend, using
|
||||||
* macros like %CLUTTER_OSX_BACKEND or %CLUTTER_X11_BACKEND.
|
* the symbolic macros like %CLUTTER_WINDOWING_WIN32 or
|
||||||
|
* %CLUTTER_WINDOWING_X11.
|
||||||
*
|
*
|
||||||
* Return value: %TRUE if the current Clutter backend is the one checked,
|
* This function should be used in conjuction with the compile-time macros
|
||||||
* and %FALSE otherwise
|
* 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:
|
||||||
|
*
|
||||||
|
* |[
|
||||||
|
* #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
|
* Since: 1.10
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
clutter_check_backend (const char *backend_type)
|
clutter_check_windowing_backend (const char *backend_type)
|
||||||
{
|
{
|
||||||
ClutterMainContext *context = _clutter_context_get_default ();
|
ClutterMainContext *context = _clutter_context_get_default ();
|
||||||
|
|
||||||
g_return_val_if_fail (backend_type != NULL, FALSE);
|
g_return_val_if_fail (backend_type != NULL, FALSE);
|
||||||
|
|
||||||
|
backend_type = g_intern_string (backend_type);
|
||||||
|
|
||||||
#ifdef CLUTTER_WINDOWING_OSX
|
#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))
|
CLUTTER_IS_BACKEND_OSX (context->backend))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_WIN32
|
#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))
|
CLUTTER_IS_BACKEND_WIN32 (context->backend))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_WAYLAND
|
#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))
|
CLUTTER_IS_BACKEND_WAYLAND (context->backend))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_EGL
|
#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))
|
CLUTTER_IS_BACKEND_EGL_NATIVE (context->backend))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_X11
|
#ifdef CLUTTER_WINDOWING_GDK
|
||||||
if (strcmp (backend_type, CLUTTER_X11_BACKEND) == 0 &&
|
if (backend_type == I_(CLUTTER_WINDOWING_GDK) &&
|
||||||
CLUTTER_IS_BACKEND_X11 (context->backend))
|
CLUTTER_IS_BACKEND_GDK (context->backend))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CLUTTER_WINDOWING_GDK
|
#ifdef CLUTTER_WINDOWING_X11
|
||||||
if (strcmp (backend_type, CLUTTER_GDK_BACKEND) == 0 &&
|
if (backend_type == I_(CLUTTER_WINDOWING_X11) &&
|
||||||
CLUTTER_IS_BACKEND_GDK (context->backend))
|
CLUTTER_IS_BACKEND_X11 (context->backend))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -195,7 +195,7 @@ gboolean clutter_check_version (guint major,
|
|||||||
guint minor,
|
guint minor,
|
||||||
guint micro);
|
guint micro);
|
||||||
|
|
||||||
gboolean clutter_check_backend (const char *backend_type);
|
gboolean clutter_check_windowing_backend (const char *backend_type);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
20
configure.ac
20
configure.ac
@ -460,34 +460,34 @@ CLUTTER_CONFIG_DEFINES=
|
|||||||
# windowing systems
|
# windowing systems
|
||||||
AS_IF([test "x$SUPPORT_X11" = "x1"],
|
AS_IF([test "x$SUPPORT_X11" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_X11 1"])
|
#define CLUTTER_WINDOWING_X11 \"x11\""])
|
||||||
AS_IF([test "x$SUPPORT_GDK" = "x1"],
|
AS_IF([test "x$SUPPORT_GDK" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_GDK 1"])
|
#define CLUTTER_WINDOWING_GDK \"gdk\""])
|
||||||
AS_IF([test "x$SUPPORT_GLX" = "x1"],
|
AS_IF([test "x$SUPPORT_GLX" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_GLX 1"])
|
#define CLUTTER_WINDOWING_GLX \"glx\""])
|
||||||
AS_IF([test "x$SUPPORT_EGL" = "x1"],
|
AS_IF([test "x$SUPPORT_EGL" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_EGL 1"])
|
#define CLUTTER_WINDOWING_EGL \"eglnative\""])
|
||||||
AS_IF([test "x$SUPPORT_WAYLAND" = "x1"],
|
AS_IF([test "x$SUPPORT_WAYLAND" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_WAYLAND 1"])
|
#define CLUTTER_WINDOWING_WAYLAND \"wayland\""])
|
||||||
AS_IF([test "x$SUPPORT_OSX" = "x1"],
|
AS_IF([test "x$SUPPORT_OSX" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_OSX 1"])
|
#define CLUTTER_WINDOWING_OSX \"osx\""])
|
||||||
AS_IF([test "x$SUPPORT_WIN32" = "x1"],
|
AS_IF([test "x$SUPPORT_WIN32" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[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"],
|
AS_IF([test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_CEX100 1"])
|
#define CLUTTER_WINDOWING_CEX100 \"cex100\""])
|
||||||
AS_IF([test "x$SUPPORT_EVDEV" = "x1"],
|
AS_IF([test "x$SUPPORT_EVDEV" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_EVDEV 1"])
|
#define CLUTTER_INPUT_EVDEV \"evdev\""])
|
||||||
AS_IF([test "x$SUPPORT_TSLIB" = "x1"],
|
AS_IF([test "x$SUPPORT_TSLIB" = "x1"],
|
||||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||||
#define CLUTTER_WINDOWING_TSLIB 1"])
|
#define CLUTTER_INPUT_TSLIB \"tslib\""])
|
||||||
|
|
||||||
AC_SUBST([CLUTTER_CONFIG_DEFINES])
|
AC_SUBST([CLUTTER_CONFIG_DEFINES])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user