[clutter-gtk/multi-backend: 2/2] Start supporting run-time backend detection
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter-gtk/multi-backend: 2/2] Start supporting run-time backend detection
- Date: Fri, 30 Sep 2011 13:14:30 +0000 (UTC)
commit 121d51cda68381542cfb391b36ed44458e237630
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Thu Sep 29 18:20:13 2011 +0100
Start supporting run-time backend detection
Currently, we only support initialization and embedding a ClutterStage
inside a GtkClutterEmbed. GtkClutterActor will come later.
clutter-gtk/gtk-clutter-embed.c | 135 ++++++++++++++++++++++++++-------------
clutter-gtk/gtk-clutter-util.c | 81 +++++++++++++++--------
2 files changed, 142 insertions(+), 74 deletions(-)
---
diff --git a/clutter-gtk/gtk-clutter-embed.c b/clutter-gtk/gtk-clutter-embed.c
index 9977ed7..b470df4 100644
--- a/clutter-gtk/gtk-clutter-embed.c
+++ b/clutter-gtk/gtk-clutter-embed.c
@@ -45,17 +45,25 @@
#include <gdk/gdk.h>
-#if defined(HAVE_CLUTTER_GTK_X11)
-
+#if defined(CLUTTER_WINDOWING_X11)
#include <clutter/x11/clutter-x11.h>
-#include <gdk/gdkx.h>
+#endif
-#elif defined(HAVE_CLUTTER_GTK_WIN32)
+#if defined(CLUTTER_WINDOWING_GDK)
+#include <clutter/gdk/clutter-gdk.h>
+#endif
+#if defined(CLUTTER_WINDOWING_WIN32)
#include <clutter/win32/clutter-win32.h>
-#include <gdk/gdkwin32.h>
+#endif
-#endif /* HAVE_CLUTTER_GTK_{X11,WIN32} */
+#if defined(GDK_WINDOWING_X11)
+#include <gdk/gdkx.h>
+#endif
+
+#if defined(GDK_WINDOWING_WIN32)
+#include <gdk/gdkwin32.h>
+#endif
G_DEFINE_TYPE (GtkClutterEmbed, gtk_clutter_embed, GTK_TYPE_CONTAINER);
@@ -183,11 +191,31 @@ gtk_clutter_filter_func (GdkXEvent *native_event,
GdkEvent *event G_GNUC_UNUSED,
gpointer user_data G_GNUC_UNUSED)
{
-#ifdef HAVE_CLUTTER_GTK_X11
- XEvent *xevent = native_event;
+#if defined(CLUTTER_WINDOWING_X11)
+ if (clutter_check_backend (CLUTTER_X11_BACKEND))
+ {
+ XEvent *xevent = native_event;
+
+ /* let Clutter handle all events coming from the windowing system */
+ clutter_x11_handle_event (xevent);
+ }
+ else
+#endif
+#if defined(CLUTTER_WINDOWING_GDK)
+ if (clutter_check_backend (CLUTTER_GDK_BACKEND))
+ {
+ clutter_gdk_handle_event (event);
+ }
+ else
+#endif
+#if defined(CLUTTER_WINDOWING_WIN32)
+ if (clutter_check_backend (CLUTTER_WIN32_BACKEND))
+ {
+ MSG *msg = native_event;
- /* let Clutter handle all events coming from the windowing system */
- clutter_x11_handle_event (xevent);
+ clutter_win32_handle_event (msg);
+ }
+ else
#endif
/* we don't care if Clutter handled the event: we want GDK to continue
@@ -207,26 +235,27 @@ gtk_clutter_embed_realize (GtkWidget *widget)
gint attributes_mask;
gint border_width;
-#ifdef HAVE_CLUTTER_GTK_X11
- {
- const XVisualInfo *xvinfo;
- GdkVisual *visual;
-
- /* We need to use the colormap from the Clutter visual, since
- * the visual is tied to the GLX context
- */
- xvinfo = clutter_x11_get_visual_info ();
- if (xvinfo == None)
- {
- g_critical ("Unable to retrieve the XVisualInfo from Clutter");
- return;
- }
-
- visual = gdk_x11_screen_lookup_visual (gtk_widget_get_screen (widget),
- xvinfo->visualid);
- gtk_widget_set_visual (widget, visual);
- }
-#endif /* HAVE_CLUTTER_GTK_X11 */
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
+ if (clutter_check_backend (CLUTTER_X11_BACKEND))
+ {
+ const XVisualInfo *xvinfo;
+ GdkVisual *visual;
+
+ /* We need to use the colormap from the Clutter visual, since
+ * the visual is tied to the GLX context
+ */
+ xvinfo = clutter_x11_get_visual_info ();
+ if (xvinfo == None)
+ {
+ g_critical ("Unable to retrieve the XVisualInfo from Clutter");
+ return;
+ }
+
+ visual = gdk_x11_screen_lookup_visual (gtk_widget_get_screen (widget),
+ xvinfo->visualid);
+ gtk_widget_set_visual (widget, visual);
+ }
+#endif
gtk_widget_set_realized (widget, TRUE);
@@ -259,6 +288,7 @@ gtk_clutter_embed_realize (GtkWidget *widget)
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes,
attributes_mask);
+
gtk_widget_set_window (widget, window);
gdk_window_set_user_data (window, widget);
@@ -274,13 +304,28 @@ gtk_clutter_embed_realize (GtkWidget *widget)
gdk_window_add_filter (NULL, gtk_clutter_filter_func, widget);
-#if defined(HAVE_CLUTTER_GTK_X11)
- clutter_x11_set_stage_foreign (CLUTTER_STAGE (priv->stage),
- GDK_WINDOW_XID (window));
-#elif defined(HAVE_CLUTTER_GTK_WIN32)
- clutter_win32_set_stage_foreign (CLUTTER_STAGE (priv->stage),
- GDK_WINDOW_HWND (window));
-#endif /* HAVE_CLUTTER_GTK_{X11,WIN32} */
+#if defined(CLUTTER_WINDOWING_GDK)
+ if (clutter_check_backend (CLUTTER_GDK_BACKEND))
+ {
+ clutter_gdk_set_stage_foreign (CLUTTER_STAGE (priv->stage), window);
+ }
+ else
+#endif
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
+ if (clutter_check_backend (CLUTTER_X11_BACKEND) &&
+ GDK_IS_X11_WINDOW (window))
+ {
+ clutter_x11_set_stage_foreign (CLUTTER_STAGE (priv->stage), GDK_WINDOW_XID (window));
+ }
+ else
+#endif
+#if defined(GDK_WINDOWING_WIN32) && defined(CLUTTER_WINDOWING_WIN32)
+ if (clutter_check_backend (CLUTTER_WIN32_BACKEND) &&
+ GDK_IS_WIN32_WINDOW (window))
+ {
+ clutter_win32_set_stage_foreign (CLUTTER_STAGE (priv->stage), GDK_WINDOW_HWND (window));
+ }
+#endif
clutter_actor_realize (priv->stage);
@@ -444,10 +489,10 @@ gtk_clutter_embed_style_updated (GtkWidget *widget)
ClutterSettings *clutter_settings;
gchar *font_name;
gint double_click_time, double_click_distance;
-#if HAVE_CLUTTER_GTK_X11
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
gint xft_dpi, xft_hinting, xft_antialias;
gchar *xft_hintstyle, *xft_rgba;
-#endif /* HAVE_CLUTTER_GTK_X11 */
+#endif
if (gtk_widget_get_realized (widget))
{
@@ -484,13 +529,13 @@ gtk_clutter_embed_style_updated (GtkWidget *widget)
"gtk-font-name", &font_name,
"gtk-double-click-time", &double_click_time,
"gtk-double-click-distance", &double_click_distance,
-#if HAVE_CLUTTER_GTK_X11
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
"gtk-xft-dpi", &xft_dpi,
"gtk-xft-antialias", &xft_antialias,
"gtk-xft-hinting", &xft_hinting,
"gtk-xft-hintstyle", &xft_hintstyle,
"gtk-xft-rgba", &xft_rgba,
-#endif /* HAVE_CLUTTER_GTK_X11 */
+#endif
NULL);
/* copy all settings and values coming from GTK+ into
@@ -502,19 +547,19 @@ gtk_clutter_embed_style_updated (GtkWidget *widget)
"font-name", font_name,
"double-click-time", double_click_time,
"double-click-distance", double_click_distance,
-#if HAVE_CLUTTER_GTK_X11
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
"font-antialias", xft_antialias,
"font-dpi", xft_dpi,
"font-hinting", xft_hinting,
"font-hint-style", xft_hintstyle,
"font-subpixel-order", xft_rgba,
-#endif /* HAVE_CLUTTER_GTK_X11 */
+#endif
NULL);
-#if HAVE_CLUTTER_GTK_X11
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
g_free (xft_hintstyle);
g_free (xft_rgba);
-#endif /* HAVE_CLUTTER_GTK_X11 */
+#endif
g_free (font_name);
diff --git a/clutter-gtk/gtk-clutter-util.c b/clutter-gtk/gtk-clutter-util.c
index ec303ec..45dca71 100644
--- a/clutter-gtk/gtk-clutter-util.c
+++ b/clutter-gtk/gtk-clutter-util.c
@@ -11,17 +11,25 @@
#include <gtk/gtk.h>
#include <clutter/clutter.h>
-#if defined(HAVE_CLUTTER_GTK_X11)
+#if defined(CLUTTER_WINDOWING_GDK)
+#include <clutter/gdk/clutter-gdk.h>
+#endif
+#if defined(CLUTTER_WINDOWING_X11)
#include <clutter/x11/clutter-x11.h>
-#include <gdk/gdkx.h>
-
-#elif defined(HAVE_CLUTTER_GTK_WIN32)
+#endif
+#if defined(CLUTTER_WINDOWING_WIN32)
#include <clutter/win32/clutter-win32.h>
-#include <gdk/gdkwin32.h>
+#endif
+
+#if defined(GDK_WINDOWING_X11)
+#include <gdk/gdkx.h>
+#endif
-#endif /* HAVE_CLUTTER_GTK_{X11,WIN32} */
+#if defined(GDK_WINDOWING_WIN32)
+#include <gdk/gdkwin32.h>
+#endif
/**
* SECTION:gtk-clutter-util
@@ -50,16 +58,35 @@ post_parse_hook (GOptionContext *context,
{
gtk_clutter_is_initialized = TRUE;
-#if defined(GDK_WINDOWING_X11)
- /* share the X11 Display with GTK+ */
- clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+#if defined(CLUTTER_WINDOWING_GDK)
+ if (clutter_check_backend (CLUTTER_GDK_BACKEND))
+ {
+ clutter_gdk_set_display (gdk_display_get_default ());
- /* let GTK+ in charge of the event handling */
- clutter_x11_disable_event_retrieval ();
-#elif defined(GDK_WINDOWING_WIN32)
- /* let GTK+ in charge of the event handling */
- clutter_win32_disable_event_retrieval ();
-#endif /* GDK_WINDOWING_{X11,WIN32} */
+ clutter_gdk_disable_event_retrieval ();
+ }
+ else
+#endif
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
+ if (clutter_check_backend (CLUTTER_X11_BACKEND))
+ {
+ /* share the X11 Display with GTK+ */
+ clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+
+ /* let GTK+ in charge of the event handling */
+ clutter_x11_disable_event_retrieval ();
+ }
+ else
+#endif
+#if defined(GDK_WINDOWING_WIN32) && defined(CLUTTER_WINDOWING_WIN32)
+ if (clutter_check_backend (CLUTTER_WIN32_BACKEND))
+ {
+ /* let GTK+ in charge of the event handling */
+ clutter_win32_disable_event_retrieval ();
+ }
+ else
+#endif
+ g_error ("*** Unsupported backend.");
/* this is required since parsing clutter's option group did not
* complete the initialization process
@@ -141,26 +168,24 @@ gtk_clutter_init (int *argc,
gtk_clutter_is_initialized = TRUE;
- gdk_disable_multidevice ();
-
if (!gtk_init_check (argc, argv))
return CLUTTER_INIT_ERROR_UNKNOWN;
-#if defined(HAVE_CLUTTER_GTK_X11)
-# if CLUTTER_CHECK_VERSION (1, 1, 5)
- /* enable ARGB visuals by default for Clutter */
+#if defined(CLUTTER_WINDOWING_GDK)
+ clutter_gdk_disable_event_retrieval ();
+#endif
+
+#if defined(GDK_WINDOWING_X11) && defined(CLUTTER_WINDOWING_X11)
clutter_x11_set_use_argb_visual (TRUE);
-# endif
- /* share the X11 Display with GTK+ */
clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
- /* let GTK+ in charge of the event handling */
clutter_x11_disable_event_retrieval ();
-#elif defined(HAVE_CLUTTER_GTK_WIN32)
- /* let GTK+ in charge of the event handling */
+#endif
+
+#if defined(CLUTTER_WINDOWING_WIN32)
clutter_win32_disable_event_retrieval ();
-#endif /* HAVE_CLUTTER_GTK_{X11,WIN32} */
+#endif
return clutter_init (argc, argv);
}
@@ -202,9 +227,7 @@ gtk_clutter_init_with_args (int *argc,
if (gtk_clutter_is_initialized)
return CLUTTER_INIT_SUCCESS;
- gdk_disable_multidevice ();
-
-#if defined(GDK_WINDOWING_X11) && CLUTTER_CHECK_VERSION (1, 1, 5)
+#if defined(CLUTTER_WINDOWING_X11)
/* enable ARGB visuals by default for Clutter */
clutter_x11_set_use_argb_visual (TRUE);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]