From 243a0660e10d13b8bd6eb4f90e5695aefab4611f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 25 May 2012 14:35:32 +0300 Subject: Make qWaitForWindowShown more robust on X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try ensuring the window has received its valid position from the WM. Change-Id: Ibd75bc19ae820765bfaadd30c22e77a19cd28849 Reviewed-by: Samuel Rødal --- src/testlib/qtestsystem.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/testlib/qtestsystem.h') diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index 095f791cac..31c9f481c5 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -88,6 +88,20 @@ namespace QTest QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QTest::qSleep(10); } + // Try ensuring the platform window receives the real position. + // (i.e. that window->pos() reflects reality) + // isActive() ( == FocusIn in case of X) does not guarantee this. It seems some WMs randomly + // send the final ConfigureNotify (the one with the non-bogus 0,0 position) after the FocusIn. + // If we just let things go, every mapTo/FromGlobal call the tests perform directly after + // qWaitForWindowShown() will generate bogus results. + if (window->isActive()) { + int waitNo = 0; // 0, 0 might be a valid position after all, so do not wait for ever + while (window->pos().isNull()) { + if (waitNo++ > timeout / 10) + break; + qWait(10); + } + } return window->isActive(); } -- cgit v1.2.3