Index: ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc |
diff --git a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc |
index 71d690f918eccbe2b3b23f909b9f6516d8085537..0a6d9b888dbb0ba3f3b77dbda7c67fb5598004ab 100644 |
--- a/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc |
+++ b/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc |
@@ -335,13 +335,53 @@ aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() { |
void DesktopWindowTreeHostX11::ShowWindowWithState( |
ui::WindowShowState show_state) { |
- if (show_state != ui::SHOW_STATE_DEFAULT && |
- show_state != ui::SHOW_STATE_NORMAL) { |
- // Only forwarding to Show(). |
- NOTIMPLEMENTED(); |
+ if (!window_mapped_) { |
Matt Giuca
2014/01/14 05:43:28
Why did you revert this change? (Is it because you
|
+ if (show_state != ui::SHOW_STATE_DEFAULT && |
+ show_state != ui::SHOW_STATE_NORMAL && |
+ show_state != ui::SHOW_STATE_INACTIVE) { |
+ // It will behave like SHOW_STATE_NORMAL. |
+ NOTIMPLEMENTED(); |
+ } |
+ |
+ // Before we map the window, set size hints. Otherwise, some window managers |
+ // will ignore toplevel XMoveWindow commands. |
+ XSizeHints size_hints; |
+ size_hints.flags = PPosition; |
+ size_hints.x = bounds_.x(); |
+ size_hints.y = bounds_.y(); |
+ XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); |
+ |
+ XWMHints wm_hints; |
+ wm_hints.flags = InputHint | StateHint; |
+ wm_hints.input = show_state != ui::SHOW_STATE_INACTIVE; |
+ wm_hints.initial_state = NormalState; |
+ XSetWMHints(xdisplay_, xwindow_, &wm_hints); |
+ |
+ XMapWindow(xdisplay_, xwindow_); |
+ |
+ // We now block until our window is mapped. Some X11 APIs will crash and |
+ // burn if passed |xwindow_| before the window is mapped, and XMapWindow is |
+ // asynchronous. |
+ base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); |
+ window_mapped_ = true; |
+ |
+ // The window has been created and mapped. It should now accept input. |
+ if (show_state == ui::SHOW_STATE_INACTIVE) { |
+ XWMHints wm_hints; |
+ wm_hints.flags = InputHint; |
+ wm_hints.input = true; |
+ // Tell the window manager that the window is now focusable. |
+ XSetWMHints(xdisplay_, xwindow_, &wm_hints); |
+ } |
} |
- Show(); |
+ if (show_state == ui::SHOW_STATE_NORMAL || |
+ show_state == ui::SHOW_STATE_MAXIMIZED) { |
+ Activate(); |
+ } |
+ |
+ if (show_state != ui::SHOW_STATE_INACTIVE) |
+ native_widget_delegate_->AsWidget()->SetInitialFocus(); |
} |
void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( |
@@ -725,25 +765,7 @@ gfx::AcceleratedWidget DesktopWindowTreeHostX11::GetAcceleratedWidget() { |
} |
void DesktopWindowTreeHostX11::Show() { |
- if (!window_mapped_) { |
- // Before we map the window, set size hints. Otherwise, some window managers |
- // will ignore toplevel XMoveWindow commands. |
- XSizeHints size_hints; |
- size_hints.flags = PPosition; |
- size_hints.x = bounds_.x(); |
- size_hints.y = bounds_.y(); |
- XSetWMNormalHints(xdisplay_, xwindow_, &size_hints); |
- |
- XMapWindow(xdisplay_, xwindow_); |
- |
- // We now block until our window is mapped. Some X11 APIs will crash and |
- // burn if passed |xwindow_| before the window is mapped, and XMapWindow is |
- // asynchronous. |
- base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); |
- window_mapped_ = true; |
- } |
- |
- native_widget_delegate_->AsWidget()->SetInitialFocus(); |
+ ShowWindowWithState(ui::SHOW_STATE_NORMAL); |
} |
void DesktopWindowTreeHostX11::Hide() { |