[mutter] Use GDK error trapping straight-up



commit c2f894963ad622508f85c71501473eb52e41a83e
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Mon Sep 20 14:42:52 2010 -0400

    Use GDK error trapping straight-up
    
    The hacks we were playing by calling gdk_error_trap_push() and then
    resetting the error handler are incompatible with the rewrite of
    GDK error traps.
    
    Since the new error code has some features that simplify what we
    are doing (like automatically figuring out whether a XSync() is needed)
    and because our custom error handler didn't have a lot of a point,
    use a separate code path for GTK+ 3.0 builds that just uses the
    GDK error traps straight-up without a custom error handler.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630195

 src/core/errors.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/core/errors.c b/src/core/errors.c
index 7b72bf2..1f35e89 100644
--- a/src/core/errors.c
+++ b/src/core/errors.c
@@ -28,18 +28,68 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <gdk/gdk.h>
+#include <gtk/gtk.h> /* Only for GTK_CHECK_VERSION */
 
+/* In GTK+-3.0, the error trapping code was significantly rewritten. The new code
+ * has some neat features (like knowing automatically if a sync is needed or not
+ * and handling errors asynchronously when the error code isn't needed immediately),
+ * but it's basically incompatible with the hacks we played with GTK+-2.0 to
+ * use a custom error handler along with gdk_error_trap_push().
+ *
+ * Since the main point of our custom error trap was to get the error logged
+ * to the right place, with GTK+-3.0 we simply omit our own error handler and
+ * use the GTK+ handling straight-up.
+ * (See https://bugzilla.gnome.org/show_bug.cgi?id=630216 for restoring logging.)
+ */
+#if GTK_CHECK_VERSION(2, 90, 0)
+#define USE_GDK_ERROR_HANDLERS 1
+#endif
+
+#ifndef USE_GDK_ERROR_HANDLERS
 static int x_error_handler    (Display     *display,
                                XErrorEvent *error);
 static int x_io_error_handler (Display     *display);
+#endif
 
 void
 meta_errors_init (void)
 {
+#ifndef USE_GDK_ERROR_HANDLERS
   XSetErrorHandler (x_error_handler);
   XSetIOErrorHandler (x_io_error_handler);
+#endif
+}
+
+#ifdef USE_GDK_ERROR_HANDLERS
+
+void
+meta_error_trap_push (MetaDisplay *display)
+{
+  gdk_error_trap_push ();
+}
+
+void
+meta_error_trap_pop (MetaDisplay *display,
+                     gboolean     last_request_was_roundtrip)
+{
+  gdk_error_trap_pop_ignored ();
+}
+
+void
+meta_error_trap_push_with_return (MetaDisplay *display)
+{
+  gdk_error_trap_push ();
 }
 
+int
+meta_error_trap_pop_with_return  (MetaDisplay *display,
+                                  gboolean     last_request_was_roundtrip)
+{
+  return gdk_error_trap_pop ();
+}
+
+#else /* !USE_GDK_ERROR_HANDLERS */
+
 static void
 meta_error_trap_push_internal (MetaDisplay *display,
                                gboolean     need_sync)
@@ -247,3 +297,5 @@ x_io_error_handler (Display *xdisplay)
   
   return 0;
 }
+
+#endif /* USE_GDK_ERROR_HANDLERS */



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