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..467f930279a01a73c692d15301f0a7a092290846 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,49 @@ aura::WindowTreeHost* DesktopWindowTreeHostX11::AsWindowTreeHost() { |
void DesktopWindowTreeHostX11::ShowWindowWithState( |
ui::WindowShowState show_state) { |
+ if (window_mapped_) |
+ return; |
+ |
if (show_state != ui::SHOW_STATE_DEFAULT && |
- show_state != ui::SHOW_STATE_NORMAL) { |
- // Only forwarding to Show(). |
+ show_state != ui::SHOW_STATE_NORMAL && |
+ show_state != ui::SHOW_STATE_INACTIVE) { |
+ // It will behave like SHOW_STATE_NORMAL. |
NOTIMPLEMENTED(); |
} |
- Show(); |
+ // Before we map the window, set size hints. Otherwise, some window managers |
+ // will ignore toplevel XMoveWindow commands. |
Matt Giuca
2014/01/13 00:18:57
Optional nit (I realize you didn't write this): to
mlamouri (slow - plz ping)
2014/01/13 02:04:58
If I knew which WM would ignore the toplevel XMove
|
+ 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; |
Matt Giuca
2014/01/13 00:18:57
// If SHOW_STATE_INACTIVE, tell the window manager
mlamouri (slow - plz ping)
2014/01/13 02:04:58
Done.
Matt Giuca
2014/01/14 05:43:27
I don't see any such comment?
|
+ 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 |
Matt Giuca
2014/01/13 00:18:57
Optional nit (I realize you didn't write this): Ge
mlamouri (slow - plz ping)
2014/01/13 02:04:58
I removed "and burn". I guess those other API call
|
+ // asynchronous. |
+ base::MessagePumpX11::Current()->BlockUntilWindowMapped(xwindow_); |
+ window_mapped_ = true; |
+ |
+ // The window has been created and mapped. Keeping the hint will simply |
+ // confuse the WM at that point. |
Matt Giuca
2014/01/13 00:18:57
What does "confuse" mean? Which hint are you refer
mlamouri (slow - plz ping)
2014/01/13 02:04:58
Updated the comment. There is no need to set |init
|
+ if (show_state == ui::SHOW_STATE_INACTIVE) { |
+ XWMHints wm_hints; |
+ wm_hints.flags = InputHint; |
+ wm_hints.input = true; |
Matt Giuca
2014/01/13 00:18:57
// Tell the window manager that the window is now
mlamouri (slow - plz ping)
2014/01/13 02:04:58
Done.
|
+ XSetWMHints(xdisplay_, xwindow_, &wm_hints); |
+ } |
+ |
+ if (show_state != ui::SHOW_STATE_INACTIVE) |
Matt Giuca
2014/01/13 00:18:57
How about "else"?
mlamouri (slow - plz ping)
2014/01/13 02:04:58
That has changed. It is being taken care of in cl
Matt Giuca
2014/01/14 05:43:27
As I wrote on that CL, is this one going first or
|
+ native_widget_delegate_->AsWidget()->SetInitialFocus(); |
} |
void DesktopWindowTreeHostX11::ShowMaximizedWithBounds( |
@@ -725,25 +761,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() { |