[clutter] interactive/pixmap: Make sure to work only on the X11 backend



commit c4e6f74f2944e20dbf04794f167a3da1b817235a
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Mon Oct 17 16:07:05 2011 +0100

    interactive/pixmap: Make sure to work only on the X11 backend
    
    Even if the test has been successfully compiled against the X11 backend,
    we need to ensure that it is actually running against it, otherwise bad
    things will happen.

 tests/interactive/test-pixmap.c |   48 ++++++++++++++++++--------------------
 1 files changed, 23 insertions(+), 25 deletions(-)
---
diff --git a/tests/interactive/test-pixmap.c b/tests/interactive/test-pixmap.c
index 9bdf950..5a40cad 100644
--- a/tests/interactive/test-pixmap.c
+++ b/tests/interactive/test-pixmap.c
@@ -1,24 +1,23 @@
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include <stdlib.h>
 #include <string.h>
 #include <gmodule.h>
 
+#include <cairo.h>
+
+#ifdef CAIRO_HAS_XLIB_SURFACE
+#include <cairo-xlib.h>
+#endif
+
 #undef CLUTTER_DISABLE_DEPRECATED
 #include <clutter/clutter.h>
 
 #ifdef CLUTTER_WINDOWING_X11
+#include <X11/Xlib.h>
+#include <X11/extensions/Xcomposite.h>
 
-# include <clutter/x11/clutter-x11.h>
-# include <clutter/x11/clutter-x11-texture-pixmap.h>
-
-# include <X11/Xlib.h>
-# include <X11/extensions/Xcomposite.h>
-
-# include <cairo.h>
-# include <cairo-xlib.h>
+#include <clutter/x11/clutter-x11.h>
+#include <clutter/x11/clutter-x11-texture-pixmap.h>
+#endif
 
 #define IMAGE   TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png"
 
@@ -127,6 +126,7 @@ stage_button_press_cb (ClutterActor    *actor,
 		       gpointer         data)
 {
   draw_arc ((Pixmap)data);
+
   return FALSE;
 }
 
@@ -172,9 +172,12 @@ create_pixmap (guint *width, guint *height, guint *depth)
   cairo_paint (cr);
   cairo_surface_destroy (image);
 
-  if (width) *width = w;
-  if (height) *height = h;
-  if (depth) *depth = 32;
+  if (width)
+    *width = w;
+  if (height)
+    *height = h;
+  if (depth)
+    *depth = 32;
 
   return pixmap;
 }
@@ -210,6 +213,11 @@ test_pixmap_main (int argc, char **argv)
   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
     return 1;
 
+#ifdef CLUTTER_WINDOWING_X11
+  if (!clutter_check_windowing_backend (CLUTTER_WINDOWING_X11))
+    g_error ("test-pixmap requires the X11 Clutter backend.");
+#endif
+
   xdpy = clutter_x11_get_default_display ();
   XSynchronize (xdpy, True);
 
@@ -308,13 +316,3 @@ test_pixmap_main (int argc, char **argv)
 
   return EXIT_SUCCESS;
 }
-
-#else
-
-int
-test_pixmap_main (int argc, char **argv)
-{
-  return EXIT_SUCCESS;
-};
-
-#endif /* CLUTTER_WINDOWING_X11 */



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