tcuX11: fix to wait for matching ConfigureNotify
authorTapani Pälli <tapani.palli@intel.com>
Wed, 11 Jan 2017 06:37:54 +0000 (08:37 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Thu, 12 Jan 2017 05:33:23 +0000 (07:33 +0200)
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.

Test: run dEQP-EGL.functional.resize* on different configurations

Change-Id: Ic32243e9b25ea6cbdb5a7ab6bfccc7a196f1a5b8
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
framework/platform/X11/tcuX11.cpp
framework/platform/X11/tcuX11.hpp

index ee24d13..27277ce 100644 (file)
@@ -86,6 +86,20 @@ XlibDisplay::~XlibDisplay (void)
        XCloseDisplay(m_display);
 }
 
+void XlibDisplay::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 XlibDisplay::processEvents (void)
 {
        XEvent  event;
@@ -93,10 +107,7 @@ void XlibDisplay::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);
        }
 }
 
@@ -244,8 +255,13 @@ void XlibWindow::setDimensions (int width, int height)
        for(;;)
        {
                XNextEvent(dpy, &myevent);
-               if (myevent.type == ConfigureNotify)
-                       break;
+               if (myevent.type == ConfigureNotify) {
+                       XConfigureEvent e = myevent.xconfigure;
+                       if (e.width == width && e.height == height)
+                               break;
+               }
+               else
+                       m_display.processEvent(myevent);
        }
 }
 
index 02a731b..ac2fd02 100644 (file)
@@ -109,6 +109,7 @@ public:
        ::Visual*               getVisual               (VisualID visualID);
        bool                    getVisualInfo   (VisualID visualID, XVisualInfo& dst);
        void                    processEvents   (void);
+       void                    processEvent    (XEvent& event);
 
 protected:
        ::Display*              m_display;