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

Side by Side Diff: ui/views/win/hwnd_message_handler.cc

Issue 2379063003: Restore maximized window position after detaching display. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/win/hwnd_message_handler.h" 5 #include "ui/views/win/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <oleacc.h> 8 #include <oleacc.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <tchar.h> 10 #include <tchar.h>
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 GetProcAddress(GetModuleHandleA("user32.dll"), "GetPointerType")); 1624 GetProcAddress(GetModuleHandleA("user32.dll"), "GetPointerType"));
1625 if (get_pointer_type && get_pointer_type(pointer_id, &pointer_type) && 1625 if (get_pointer_type && get_pointer_type(pointer_id, &pointer_type) &&
1626 pointer_type == PT_TOUCHPAD) 1626 pointer_type == PT_TOUCHPAD)
1627 return PA_NOACTIVATE; 1627 return PA_NOACTIVATE;
1628 SetMsgHandled(FALSE); 1628 SetMsgHandled(FALSE);
1629 return -1; 1629 return -1;
1630 } 1630 }
1631 1631
1632 void HWNDMessageHandler::OnMove(const gfx::Point& point) { 1632 void HWNDMessageHandler::OnMove(const gfx::Point& point) {
1633 delegate_->HandleMove(); 1633 delegate_->HandleMove();
1634
1635 RECT window_rect;
sky 2016/09/29 18:16:23 Would it make more sense for this to be in OnWindo
1636 HMONITOR monitor;
1637 gfx::Rect monitor_rect, work_area;
1638 if (!GetParent(hwnd()) && IsMaximized() &&
1639 GetWindowRect(hwnd(), &window_rect) &&
1640 GetMonitorAndRects(window_rect, &monitor, &monitor_rect, &work_area)) {
1641 gfx::Rect expected_window_bounds = work_area;
1642
1643 // Windows automatically adds a standard width border to all sides when a
1644 // window is maximized. We should take this into account.
1645 gfx::Insets client_area_insets;
1646 if (GetClientAreaInsets(&client_area_insets))
1647 expected_window_bounds.Inset(client_area_insets.Scale(-1));
1648
1649 if (GetWindowBoundsInScreen() != expected_window_bounds) {
1650 // Sometimes Windows incorrectly changes bounds of maximized windows after
1651 // attaching or detaching additional displays. In this case user can see
1652 // non-client area of the window (that should be hidden in normal case).
1653 // This workaround code restores window position if problem occurs.
1654 SetWindowPos(hwnd(), NULL,
1655 expected_window_bounds.x(),
1656 expected_window_bounds.y(),
1657 expected_window_bounds.width(),
1658 expected_window_bounds.height(),
1659 SWP_NOACTIVATE | SWP_NOZORDER);
1660 }
1661 }
1662
1634 SetMsgHandled(FALSE); 1663 SetMsgHandled(FALSE);
1635 } 1664 }
1636 1665
1637 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) { 1666 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) {
1638 delegate_->HandleMove(); 1667 delegate_->HandleMove();
1639 } 1668 }
1640 1669
1641 LRESULT HWNDMessageHandler::OnNCActivate(UINT message, 1670 LRESULT HWNDMessageHandler::OnNCActivate(UINT message,
1642 WPARAM w_param, 1671 WPARAM w_param,
1643 LPARAM l_param) { 1672 LPARAM l_param) {
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 MONITORINFO monitor_info = {sizeof(monitor_info)}; 2739 MONITORINFO monitor_info = {sizeof(monitor_info)};
2711 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), 2740 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY),
2712 &monitor_info); 2741 &monitor_info);
2713 gfx::Rect shrunk_rect(monitor_info.rcMonitor); 2742 gfx::Rect shrunk_rect(monitor_info.rcMonitor);
2714 shrunk_rect.set_height(shrunk_rect.height() - 1); 2743 shrunk_rect.set_height(shrunk_rect.height() - 1);
2715 background_fullscreen_hack_ = true; 2744 background_fullscreen_hack_ = true;
2716 SetBoundsInternal(shrunk_rect, false); 2745 SetBoundsInternal(shrunk_rect, false);
2717 } 2746 }
2718 2747
2719 } // namespace views 2748 } // namespace views
OLDNEW
« 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