[gtk+] reftests: Add a hack to make toplevels work in various WMs
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] reftests: Add a hack to make toplevels work in various WMs
- Date: Thu, 5 May 2011 15:40:08 +0000 (UTC)
commit 3f4f900242f7d8c3e1f4e1722e0f211f3347b41d
Author: Benjamin Otte <otte redhat com>
Date: Thu May 5 04:29:56 2011 +0200
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.
tests/reftests/gtk-reftest.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/tests/reftests/gtk-reftest.c b/tests/reftests/gtk-reftest.c
index 492031b..111a4c9 100644
--- a/tests/reftests/gtk-reftest.c
+++ b/tests/reftests/gtk-reftest.c
@@ -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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]