Commit 3730f644 by Corentin Wallez

Make X11Window::setVisible block until the window is mapped.

That way the code calling setVisible knows it can safely create a framebuffer for this window without having its content be undefined. BUG=angleproject:830 Change-Id: Ia694f50ac20e1d510d0c0f899226ed241d9a5a3a Reviewed-on: https://chromium-review.googlesource.com/271156Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent d64a38b3
...@@ -8,6 +8,15 @@ ...@@ -8,6 +8,15 @@
#include "x11/X11Window.h" #include "x11/X11Window.h"
namespace {
Bool WaitForMapNotify(Display *dpy, XEvent *event, XPointer window)
{
return event->type == MapNotify && event->xmap.window == reinterpret_cast<Window>(window);
}
}
X11Window::X11Window() X11Window::X11Window()
: WM_DELETE_WINDOW(None), : WM_DELETE_WINDOW(None),
mDisplay(nullptr), mDisplay(nullptr),
...@@ -158,12 +167,19 @@ void X11Window::setVisible(bool isVisible) ...@@ -158,12 +167,19 @@ void X11Window::setVisible(bool isVisible)
if (isVisible) if (isVisible)
{ {
XMapWindow(mDisplay, mWindow); XMapWindow(mDisplay, mWindow);
// Wait until we get an event saying this window is mapped so that the
// code calling setVisible can assume the window is visible.
// This is important when creating a framebuffer as the framebuffer content
// is undefined when the window is not visible.
XEvent dummyEvent;
XIfEvent(mDisplay, &dummyEvent, WaitForMapNotify, reinterpret_cast<XPointer>(mWindow));
} }
else else
{ {
XUnmapWindow(mDisplay, mWindow); XUnmapWindow(mDisplay, mWindow);
XFlush(mDisplay);
} }
XFlush(mDisplay);
} }
void X11Window::signalTestEvent() void X11Window::signalTestEvent()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment