Index: ui/aura/desktop_host_linux.cc |
diff --git a/ui/aura/desktop_host_linux.cc b/ui/aura/desktop_host_linux.cc |
index ed47ca21dad976628412990014f2c581be1e0b07..a90dc67a538ddf93c2153d09f3c410ab8f862922 100644 |
--- a/ui/aura/desktop_host_linux.cc |
+++ b/ui/aura/desktop_host_linux.cc |
@@ -377,14 +377,24 @@ gfx::AcceleratedWidget DesktopHostLinux::GetAcceleratedWidget() { |
void DesktopHostLinux::Show() { |
XMapWindow(xdisplay_, xwindow_); |
+ // Wait for notification that the window is mapped, which happens |
+ // asynchronously if there's a window manager running. Ideally we wouldn't |
+ // need to wait for this, but some window managers don't do anything to let us |
+ // know that they're there (*cough*ion3*cough*), in which case we need to make |
+ // sure that the window is mapped before sending a SetInputFocus request. |
+ while (true) { |
+ XEvent event; |
+ XWindowEvent(xdisplay_, xwindow_, StructureNotifyMask, &event); |
+ if (event.type == MapNotify) |
+ break; |
+ } |
+ |
// If there's no window manager running, we need to assign the X input focus |
- // to our host window. (If there's no window manager running, it should also |
- // be safe to assume that the host window will have been mapped by the time |
- // that our SetInputFocus request is received.) |
- if (!IsWindowManagerPresent()) |
+ // to our host window. |
+ if (!IsWindowManagerPresent()) { |
XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); |
- |
- XFlush(xdisplay_); |
+ XFlush(xdisplay_); |
+ } |
} |
gfx::Size DesktopHostLinux::GetSize() const { |