[PATCH] clutter-gtk: support quartz



Basic patch for examples running on Mac OS X(not quit with TRAP,
SEGV, etc).
clutter-gtk doesn't work on Mac OS X as #684244 said. Though clutter-gtk
based programs are runnable on Mac OS X but the GtkWidget window and
Clutter window are seperated. This patch fixes the SEGV/TRAP while
running clutter-gtk based programs, which seems be triggerred by
g_error("Not support quartz backend") or double registered event handlers.
---
 clutter-gtk/Makefile.am        |  5 +++++
 clutter-gtk/gtk-clutter-util.c | 22 ++++++++++++++++++++++
 configure.ac                   | 16 ++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/clutter-gtk/Makefile.am b/clutter-gtk/Makefile.am
index 9a35919..956dc75 100644
--- a/clutter-gtk/Makefile.am
+++ b/clutter-gtk/Makefile.am
@@ -19,6 +19,11 @@ AM_CPPFLAGS = \
 
 AM_CFLAGS = $(MAINTAINER_CFLAGS) $(CLUTTER_GTK_DEPS_CFLAGS)
 
+if USE_QUARTZ
+AM_CPPFLAGS += -xobjective-c
+AM_CFLAGS += -xobjective-c
+endif # USE_QUARTZ
+
 lib_LTLIBRARIES = libclutter-gtk- CLUTTER_GTK_API_VERSION@.la
 
 source_c = \
diff --git a/clutter-gtk/gtk-clutter-util.c b/clutter-gtk/gtk-clutter-util.c
index d4a9fa5..1b84866 100644
--- a/clutter-gtk/gtk-clutter-util.c
+++ b/clutter-gtk/gtk-clutter-util.c
@@ -23,6 +23,10 @@
 #include <clutter/win32/clutter-win32.h>
 #endif
 
+#if defined(CLUTTER_WINDOWING_OSX)
+#include <clutter/osx/clutter-osx.h>
+#endif
+
 #if defined(GDK_WINDOWING_X11)
 #include <gdk/gdkx.h>
 #endif
@@ -31,6 +35,10 @@
 #include <gdk/gdkwin32.h>
 #endif
 
+#if defined(GDK_WINDOWING_QUARTZ)
+#include <gdk/gdkquartz.h>
+#endif
+
 /**
  * SECTION:gtk-clutter-util
  * @Title: Utility Functions
@@ -96,6 +104,15 @@ post_parse_hook (GOptionContext  *context,
     }
   else
 #endif
+#if defined(GDK_WINDOWING_QUARTZ) && defined(CLUTTER_WINDOWING_OSX)
+  if (clutter_check_windowing_backend (CLUTTER_WINDOWING_OSX) &&
+      GDK_IS_QUARTZ_DISPLAY (display))
+    {
+      /* let GTK+ be in charge of the event handling */
+      clutter_osx_disable_event_retrieval ();
+    }
+  else
+#endif
     g_error ("*** Unsupported backend.");
 
   /* this is required since parsing clutter's option group did not
@@ -202,6 +219,11 @@ gtk_clutter_init (int    *argc,
     clutter_win32_disable_event_retrieval ();
 #endif
 
+#if defined(CLUTTER_WINDOWING_OSX)
+  if (clutter_check_windowing_backend (CLUTTER_WINDOWING_OSX))
+      clutter_osx_disable_event_retrieval ();
+#endif
+
   /* We disable clutter accessibility support in order to not
    * interfere with gtk accessibility support.
    */
diff --git a/configure.ac b/configure.ac
index 7d381e2..52a134c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,6 +118,22 @@ AS_CASE([$enable_deprecated],
 
 AC_SUBST([CLUTTER_GTK_DEPRECATED_CFLAGS])
 
+dnl = Check for osx compiling ==============================================
+orig_cppflags="$CPPFLAGS"
+CPPFLAGS=`$PKG_CONFIG --cflags gdk-3.0 clutter-1.0`
+
+AC_LANG(C)
+AC_PREPROC_IFELSE(
+       [AC_LANG_SOURCE([[#include <gdk/gdk.h>
+       #include <clutter/clutter.h>
+       #if !defined (CLUTTER_WINDOWING_OSX) && !defined (GDK_WINDOWING_QUARTZ)
+       #error "No quartz realted macros defined."
+       #endif]])],
+       [AM_CONDITIONAL(USE_QUARTZ, true)],
+       [AM_CONDITIONAL(USE_QUARTZ, false)])
+
+CPPFLAGS="$orig_cppflags"
+
 dnl = Enable debug level ===================================================
 
 m4_define([debug_default], [m4_if(m4_eval(clutter_gtk_minor % 2), [1], [yes], [minimum])])
-- 
1.8.3.4 (Apple Git-47)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]