Fix maximize --> unmaximize positioning issue

This commit is contained in:
Samuel Attard 2016-11-22 16:07:05 +11:00
parent c65033a13b
commit 621a934160
No known key found for this signature in database
GPG key ID: 273DC1869D8F13EF
2 changed files with 11 additions and 4 deletions

View file

@ -216,6 +216,7 @@ class NativeWindowViews : public NativeWindow,
// size of the window while in the normal state (not maximized, minimized or // size of the window while in the normal state (not maximized, minimized or
// fullscreen), so we restore it correctly. // fullscreen), so we restore it correctly.
gfx::Rect last_normal_bounds_; gfx::Rect last_normal_bounds_;
gfx::Rect last_normal_bounds_before_move_;
// last_normal_bounds_ may or may not require update on WM_MOVE. When a // last_normal_bounds_ may or may not require update on WM_MOVE. When a
// window is maximized, it is moved (WM_MOVE) to maximum size first and then // window is maximized, it is moved (WM_MOVE) to maximum size first and then

View file

@ -125,9 +125,12 @@ bool NativeWindowViews::PreHandleMSG(
return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param)); return taskbar_host_.HandleThumbarButtonEvent(LOWORD(w_param));
return false; return false;
case WM_SIZE: { case WM_SIZE: {
consecutive_moves_ = false;
// Handle window state change. // Handle window state change.
HandleSizeEvent(w_param, l_param); HandleSizeEvent(w_param, l_param);
consecutive_moves_ = false;
last_normal_bounds_before_move_ = last_normal_bounds_;
return false; return false;
} }
case WM_MOVING: { case WM_MOVING: {
@ -155,6 +158,9 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
switch (w_param) { switch (w_param) {
case SIZE_MAXIMIZED: case SIZE_MAXIMIZED:
last_window_state_ = ui::SHOW_STATE_MAXIMIZED; last_window_state_ = ui::SHOW_STATE_MAXIMIZED;
if (consecutive_moves_) {
last_normal_bounds_ = last_normal_bounds_before_move_;
}
NotifyWindowMaximize(); NotifyWindowMaximize();
break; break;
case SIZE_MINIMIZED: case SIZE_MINIMIZED:
@ -165,14 +171,14 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
if (last_window_state_ == ui::SHOW_STATE_NORMAL) { if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
// Window was resized so we save it's new size. // Window was resized so we save it's new size.
last_normal_bounds_ = GetBounds(); last_normal_bounds_ = GetBounds();
last_normal_bounds_before_move_ = last_normal_bounds_;
} else { } else {
switch (last_window_state_) { switch (last_window_state_) {
case ui::SHOW_STATE_MAXIMIZED: case ui::SHOW_STATE_MAXIMIZED:
last_window_state_ = ui::SHOW_STATE_NORMAL; last_window_state_ = ui::SHOW_STATE_NORMAL;
// When the window is restored we resize it to the previous known // Don't force out last known bounds onto the window as Windows
// normal size. // actually gets these correct
SetBounds(last_normal_bounds_, false);
NotifyWindowUnmaximize(); NotifyWindowUnmaximize();
break; break;