incorrect position when restored from maximize-on-top-drag under Windows #7630

This commit is contained in:
liusi 2016-10-27 17:42:43 +08:00
parent 93464b8100
commit a2b3abbf47
3 changed files with 13 additions and 55 deletions

View file

@ -327,7 +327,6 @@ NativeWindowViews::NativeWindowViews(
last_window_state_ = ui::SHOW_STATE_FULLSCREEN; last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
else else
last_window_state_ = ui::SHOW_STATE_NORMAL; last_window_state_ = ui::SHOW_STATE_NORMAL;
last_normal_bounds_ = GetBounds();
#endif #endif
} }

View file

@ -211,22 +211,6 @@ class NativeWindowViews : public NativeWindow,
ui::WindowShowState last_window_state_; ui::WindowShowState last_window_state_;
// There's an issue with restore on Windows, that sometimes causes the Window
// to receive the wrong size (#2498). To circumvent that, we keep tabs on the
// size of the window while in the normal state (not maximized, minimized or
// fullscreen), so we restore it correctly.
gfx::Rect last_normal_bounds_;
// 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
// sized (WM_SIZE). In this case, last_normal_bounds_ should not update. We
// keep last_normal_bounds_candidate_ as a candidate which will become valid
// last_normal_bounds_ if the moves are consecutive with no WM_SIZE event in
// between.
gfx::Rect last_normal_bounds_candidate_;
bool consecutive_moves_;
// In charge of running taskbar related APIs. // In charge of running taskbar related APIs.
TaskbarHost taskbar_host_; TaskbarHost taskbar_host_;

View file

@ -125,7 +125,6 @@ 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);
return false; return false;
@ -135,15 +134,6 @@ bool NativeWindowViews::PreHandleMSG(
::GetWindowRect(GetAcceleratedWidget(), (LPRECT)l_param); ::GetWindowRect(GetAcceleratedWidget(), (LPRECT)l_param);
return false; return false;
} }
case WM_MOVE: {
if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
if (consecutive_moves_)
last_normal_bounds_ = last_normal_bounds_candidate_;
last_normal_bounds_candidate_ = GetBounds();
consecutive_moves_ = true;
}
return false;
}
default: default:
return false; return false;
} }
@ -162,18 +152,9 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
NotifyWindowMinimize(); NotifyWindowMinimize();
break; break;
case SIZE_RESTORED: case SIZE_RESTORED:
if (last_window_state_ == ui::SHOW_STATE_NORMAL) {
// Window was resized so we save it's new size.
last_normal_bounds_ = GetBounds();
} 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
// normal size.
SetBounds(last_normal_bounds_, false);
NotifyWindowUnmaximize(); NotifyWindowUnmaximize();
break; break;
case ui::SHOW_STATE_MINIMIZED: case ui::SHOW_STATE_MINIMIZED:
@ -182,16 +163,10 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
NotifyWindowEnterFullScreen(); NotifyWindowEnterFullScreen();
} else { } else {
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
// normal size.
SetBounds(last_normal_bounds_, false);
NotifyWindowRestore(); NotifyWindowRestore();
} }
break; break;
} }
}
break; break;
} }
} }