]> Pileus Git - ~andy/gtk/commitdiff
reftests: Add a hack to make toplevels work in various WMs
authorBenjamin Otte <otte@redhat.com>
Thu, 5 May 2011 02:29:56 +0000 (04:29 +0200)
committerBenjamin Otte <otte@redhat.com>
Thu, 5 May 2011 15:33:04 +0000 (17:33 +0200)
If we have a toplevel, and not a popup window, do wait an additional
0.5s to give the WM/server enough time to actually create the window.

This is a hack and there should be a better solution. But it works.

Please use POPUP windows for tests unless the test must use toplevel
windows.

tests/reftests/gtk-reftest.c

index 492031bc4b4f078d6484c129c683d23d52ebd557..111a4c900020f6ab833fcc7e430db5b5d515fdec 100644 (file)
@@ -225,8 +225,21 @@ snapshot_widget (GtkWidget *widget, SnapshotMode mode)
   switch (mode)
     {
     case SNAPSHOT_WINDOW:
-      gdk_cairo_set_source_window (cr, gtk_widget_get_window (widget), 0, 0);
-      cairo_paint (cr);
+      {
+        GdkWindow *window = gtk_widget_get_window (widget);
+        if (gdk_window_get_window_type (window) == GDK_WINDOW_TOPLEVEL ||
+            gdk_window_get_window_type (window) == GDK_WINDOW_FOREIGN)
+          {
+            /* give the WM/server some time to sync. They need it.
+             * Also, do use popups instead of toplevls in your tests
+             * whenever you can. */
+            gdk_display_sync (gdk_window_get_display (window));
+            g_timeout_add (500, quit_when_idle, loop);
+            g_main_loop_run (loop);
+          }
+        gdk_cairo_set_source_window (cr, window, 0, 0);
+        cairo_paint (cr);
+      }
       break;
     case SNAPSHOT_DRAW:
       bg = gdk_window_get_background_pattern (gtk_widget_get_window (widget));