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.
This commit is contained in:
Emmanuele Bassi 2011-10-17 16:07:05 +01:00
parent 3b38cee66b
commit c4e6f74f29

View File

@ -1,24 +1,23 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <gmodule.h> #include <gmodule.h>
#include <cairo.h>
#ifdef CAIRO_HAS_XLIB_SURFACE
#include <cairo-xlib.h>
#endif
#undef CLUTTER_DISABLE_DEPRECATED #undef CLUTTER_DISABLE_DEPRECATED
#include <clutter/clutter.h> #include <clutter/clutter.h>
#ifdef CLUTTER_WINDOWING_X11 #ifdef CLUTTER_WINDOWING_X11
#include <X11/Xlib.h>
#include <X11/extensions/Xcomposite.h>
# include <clutter/x11/clutter-x11.h> #include <clutter/x11/clutter-x11.h>
# include <clutter/x11/clutter-x11-texture-pixmap.h> #include <clutter/x11/clutter-x11-texture-pixmap.h>
#endif
# include <X11/Xlib.h>
# include <X11/extensions/Xcomposite.h>
# include <cairo.h>
# include <cairo-xlib.h>
#define IMAGE TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png" #define IMAGE TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png"
@ -127,6 +126,7 @@ stage_button_press_cb (ClutterActor *actor,
gpointer data) gpointer data)
{ {
draw_arc ((Pixmap)data); draw_arc ((Pixmap)data);
return FALSE; return FALSE;
} }
@ -172,9 +172,12 @@ create_pixmap (guint *width, guint *height, guint *depth)
cairo_paint (cr); cairo_paint (cr);
cairo_surface_destroy (image); cairo_surface_destroy (image);
if (width) *width = w; if (width)
if (height) *height = h; *width = w;
if (depth) *depth = 32; if (height)
*height = h;
if (depth)
*depth = 32;
return pixmap; return pixmap;
} }
@ -210,6 +213,11 @@ test_pixmap_main (int argc, char **argv)
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1; 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 (); xdpy = clutter_x11_get_default_display ();
XSynchronize (xdpy, True); XSynchronize (xdpy, True);
@ -308,13 +316,3 @@ test_pixmap_main (int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
#else
int
test_pixmap_main (int argc, char **argv)
{
return EXIT_SUCCESS;
};
#endif /* CLUTTER_WINDOWING_X11 */