Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 2379063003: Restore maximized window position after detaching display. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/win/hwnd_message_handler.cc
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index ec631af3b840741db1404d454ad652586b11bc25..c20f120cb4af921dcecf891c05ec462d884be59d 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -1631,6 +1631,35 @@ LRESULT HWNDMessageHandler::OnPointerActivate(UINT message,
void HWNDMessageHandler::OnMove(const gfx::Point& point) {
delegate_->HandleMove();
+
+ RECT window_rect;
sky 2016/09/29 18:16:23 Would it make more sense for this to be in OnWindo
+ HMONITOR monitor;
+ gfx::Rect monitor_rect, work_area;
+ if (!GetParent(hwnd()) && IsMaximized() &&
+ GetWindowRect(hwnd(), &window_rect) &&
+ GetMonitorAndRects(window_rect, &monitor, &monitor_rect, &work_area)) {
+ gfx::Rect expected_window_bounds = work_area;
+
+ // Windows automatically adds a standard width border to all sides when a
+ // window is maximized. We should take this into account.
+ gfx::Insets client_area_insets;
+ if (GetClientAreaInsets(&client_area_insets))
+ expected_window_bounds.Inset(client_area_insets.Scale(-1));
+
+ if (GetWindowBoundsInScreen() != expected_window_bounds) {
+ // Sometimes Windows incorrectly changes bounds of maximized windows after
+ // attaching or detaching additional displays. In this case user can see
+ // non-client area of the window (that should be hidden in normal case).
+ // This workaround code restores window position if problem occurs.
+ SetWindowPos(hwnd(), NULL,
+ expected_window_bounds.x(),
+ expected_window_bounds.y(),
+ expected_window_bounds.width(),
+ expected_window_bounds.height(),
+ SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+ }
+
SetMsgHandled(FALSE);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698