Commit 79cd33a2 authored by arjanl's avatar arjanl Committed by Commit bot

Fix maximize on some window managers

On some window managers the Maximize hints are not respected when they
are set on an unmapped window. There was an existing workaround for this
in the code, but the workaround failed whenever ShowWindowWithState
didn't happen to be called with the parameters needed to activate the
workaround. This meant that if a window was first made visible and later
activated, it would not get maximized at all.

This fix saves whether the maximize hints need to be sent to the window,
and makes sure it gets done after mapping the window.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#293698}
parent 2c8acfe2
...@@ -138,6 +138,7 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11( ...@@ -138,6 +138,7 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
is_fullscreen_(false), is_fullscreen_(false),
is_always_on_top_(false), is_always_on_top_(false),
use_native_frame_(false), use_native_frame_(false),
should_maximize_after_map_(false),
use_argb_visual_(false), use_argb_visual_(false),
drag_drop_client_(NULL), drag_drop_client_(NULL),
native_widget_delegate_(native_widget_delegate), native_widget_delegate_(native_widget_delegate),
...@@ -366,9 +367,6 @@ void DesktopWindowTreeHostX11::ShowWindowWithState( ...@@ -366,9 +367,6 @@ void DesktopWindowTreeHostX11::ShowWindowWithState(
if (show_state == ui::SHOW_STATE_NORMAL || if (show_state == ui::SHOW_STATE_NORMAL ||
show_state == ui::SHOW_STATE_MAXIMIZED) { show_state == ui::SHOW_STATE_MAXIMIZED) {
// Note: XFCE ignores a maximize hint given before mapping the window.
if (show_state == ui::SHOW_STATE_MAXIMIZED)
Maximize();
Activate(); Activate();
} }
...@@ -541,6 +539,10 @@ void DesktopWindowTreeHostX11::Maximize() { ...@@ -541,6 +539,10 @@ void DesktopWindowTreeHostX11::Maximize() {
SetBounds(adjusted_bounds); SetBounds(adjusted_bounds);
} }
// Some WMs do not respect maximization hints on unmapped windows, so we
// save this one for later too.
should_maximize_after_map_ = !window_mapped_;
// When we are in the process of requesting to maximize a window, we can // When we are in the process of requesting to maximize a window, we can
// accurately keep track of our restored bounds instead of relying on the // accurately keep track of our restored bounds instead of relying on the
// heuristics that are in the PropertyNotify and ConfigureNotify handlers. // heuristics that are in the PropertyNotify and ConfigureNotify handlers.
...@@ -559,6 +561,7 @@ void DesktopWindowTreeHostX11::Minimize() { ...@@ -559,6 +561,7 @@ void DesktopWindowTreeHostX11::Minimize() {
} }
void DesktopWindowTreeHostX11::Restore() { void DesktopWindowTreeHostX11::Restore() {
should_maximize_after_map_ = false;
SetWMSpecState(false, SetWMSpecState(false,
atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"), atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_VERT"),
atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ")); atom_cache_.GetAtom("_NET_WM_STATE_MAXIMIZED_HORZ"));
...@@ -1585,6 +1588,13 @@ void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) { ...@@ -1585,6 +1588,13 @@ void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) {
if (ui::X11EventSource::GetInstance()) if (ui::X11EventSource::GetInstance())
ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_); ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(xwindow_);
window_mapped_ = true; window_mapped_ = true;
// Some WMs only respect maximize hints after the window has been mapped.
// Check whether we need to re-do a maximization.
if (should_maximize_after_map_) {
Maximize();
should_maximize_after_map_ = false;
}
} }
void DesktopWindowTreeHostX11::SetWindowTransparency() { void DesktopWindowTreeHostX11::SetWindowTransparency() {
......
...@@ -286,6 +286,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 ...@@ -286,6 +286,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
// True if the window has title-bar / borders provided by the window manager. // True if the window has title-bar / borders provided by the window manager.
bool use_native_frame_; bool use_native_frame_;
// True if a Maximize() call should be done after mapping the window.
bool should_maximize_after_map_;
// Whether we used an ARGB visual for our window. // Whether we used an ARGB visual for our window.
bool use_argb_visual_; bool use_argb_visual_;
......
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