reftests: Add a hack to make toplevels work in various WMs

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.
This commit is contained in:
Benjamin Otte 2011-05-05 04:29:56 +02:00
parent 5c026f32e9
commit 3f4f900242

View 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));