Commit d36e01e1 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Allow inactive windows to be created with Linux Aura.

BUG=325142

Review URL: https://codereview.chromium.org/100623008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245338 0039d316-1c4b-4281-b951-d872f2087c98
parent 967d1b53
......@@ -335,13 +335,15 @@ 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_)
MapWindow(show_state);
if (show_state == ui::SHOW_STATE_NORMAL ||
show_state == ui::SHOW_STATE_MAXIMIZED) {
Activate();
}
Show();
native_widget_delegate_->AsWidget()->SetInitialFocus();
}
void DesktopWindowTreeHostX11::ShowMaximizedWithBounds(
......@@ -729,25 +731,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() {
......@@ -1198,6 +1182,48 @@ std::list<XID>& DesktopWindowTreeHostX11::open_windows() {
return *open_windows_;
}
void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) {
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;
// If SHOW_STATE_INACTIVE, tell the window manager that the window is not
// focusable. This will make the window inactive upon creation.
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);
}
}
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11, MessageLoop::Dispatcher implementation:
......
......@@ -198,6 +198,9 @@ private:
// See comment for variable open_windows_.
static std::list<XID>& open_windows();
// Map the window (shows it) taking into account the given |show_state|.
void MapWindow(ui::WindowShowState show_state);
// Overridden from Dispatcher:
virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
......
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