From 90dff4b57b7e6c80e3fe946f9823c5b561740c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Thu, 5 Jan 2017 09:03:36 +0200 Subject: [PATCH] tcuX11: fix to wait for matching ConfigureNotify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch adds a loop to setDimensions that spins until exact matching ConfigureNotify event is caught. This is done to make sure X has updated the window size before we get further. New processEvent method is added so that we can handle possible WM_DELETE_WINDOW message during the loop as suggested by Pyry. Signed-off-by: Tapani Pälli --- framework/platform/X11/tcuX11.cpp | 34 ++++++++++++++++++++++++++++++---- framework/platform/X11/tcuX11.hpp | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/framework/platform/X11/tcuX11.cpp b/framework/platform/X11/tcuX11.cpp index c60c95e..974fd63 100644 --- a/framework/platform/X11/tcuX11.cpp +++ b/framework/platform/X11/tcuX11.cpp @@ -76,6 +76,20 @@ Display::~Display (void) XCloseDisplay(m_display); } +void Display::processEvent (XEvent& event) +{ + switch (event.type) + { + case ClientMessage: + if ((unsigned)event.xclient.data.l[0] == m_deleteAtom) + m_eventState.setQuitFlag(true); + break; + // note: ConfigureNotify for window is handled in setDimensions() + default: + break; + } +} + void Display::processEvents (void) { XEvent event; @@ -83,10 +97,7 @@ void Display::processEvents (void) while (XPending(m_display)) { XNextEvent(m_display, &event); - - // \todo [2010-10-27 pyry] Handle ConfigureNotify? - if (event.type == ClientMessage && (unsigned)event.xclient.data.l[0] == m_deleteAtom) - m_eventState.setQuitFlag(true); + processEvent(event); } } @@ -227,6 +238,21 @@ void Window::setDimensions (int width, int height) changes.height = height; XConfigureWindow(m_display.getXDisplay(), m_window, mask, &changes); + // wait for matching configurenotify event + for (;;) + { + XEvent myevent; + XNextEvent(m_display.getXDisplay(), &myevent); + if (myevent.type == ConfigureNotify) + { + XConfigureEvent e = myevent.xconfigure; + if (e.width == width && e.height == height) + break; + } + else { + m_display.processEvent(myevent); + } + } } void Window::processEvents (void) diff --git a/framework/platform/X11/tcuX11.hpp b/framework/platform/X11/tcuX11.hpp index 7a4df12..18ff689 100644 --- a/framework/platform/X11/tcuX11.hpp +++ b/framework/platform/X11/tcuX11.hpp @@ -68,6 +68,7 @@ public: ::Visual* getVisual (VisualID visualID); bool getVisualInfo (VisualID visualID, XVisualInfo& dst); void processEvents (void); + void processEvent (XEvent& event); protected: EventState& m_eventState; -- 2.7.4