OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/window.h" | 5 #include "chrome/views/window.h" |
6 | 6 |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 | 8 |
9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } | 561 } |
562 return CallDefaultNCActivateHandler(active); | 562 return CallDefaultNCActivateHandler(active); |
563 } | 563 } |
564 | 564 |
565 LRESULT Window::OnNCCalcSize(BOOL mode, LPARAM l_param) { | 565 LRESULT Window::OnNCCalcSize(BOOL mode, LPARAM l_param) { |
566 // We only need to adjust the client size/paint handling when we're not using | 566 // We only need to adjust the client size/paint handling when we're not using |
567 // the native frame. | 567 // the native frame. |
568 if (non_client_view_->UseNativeFrame()) | 568 if (non_client_view_->UseNativeFrame()) |
569 return WidgetWin::OnNCCalcSize(mode, l_param); | 569 return WidgetWin::OnNCCalcSize(mode, l_param); |
570 | 570 |
571 // We need to repaint all when the window bounds change. | 571 RECT* client_rect = mode ? |
572 return WVR_REDRAW; | 572 &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : |
| 573 reinterpret_cast<RECT*>(l_param); |
| 574 if (IsMaximized()) { |
| 575 // Make the maximized mode client rect fit the screen exactly, by |
| 576 // subtracting the border Windows automatically adds for maximized mode. |
| 577 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
| 578 InflateRect(client_rect, -border_thickness, -border_thickness); |
| 579 |
| 580 // Find all auto-hide taskbars along the screen edges and adjust in by the |
| 581 // thickness of the auto-hide taskbar on each such edge, so the window isn't |
| 582 // treated as a "fullscreen app", which would cause the taskbars to |
| 583 // disappear. |
| 584 HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); |
| 585 if (win_util::EdgeHasAutoHideTaskbar(ABE_LEFT, monitor)) |
| 586 client_rect->left += win_util::kAutoHideTaskbarThicknessPx; |
| 587 if (win_util::EdgeHasAutoHideTaskbar(ABE_TOP, monitor)) |
| 588 client_rect->top += win_util::kAutoHideTaskbarThicknessPx; |
| 589 if (win_util::EdgeHasAutoHideTaskbar(ABE_RIGHT, monitor)) |
| 590 client_rect->right -= win_util::kAutoHideTaskbarThicknessPx; |
| 591 if (win_util::EdgeHasAutoHideTaskbar(ABE_BOTTOM, monitor)) |
| 592 client_rect->bottom -= win_util::kAutoHideTaskbarThicknessPx; |
| 593 |
| 594 // We cannot return WVR_REDRAW when there is nonclient area, or Windows |
| 595 // exhibits bugs where client pixels and child HWNDs are mispositioned by |
| 596 // the width/height of the upper-left nonclient area. |
| 597 return 0; |
| 598 } |
| 599 |
| 600 // If the window bounds change, we're going to relayout and repaint anyway. |
| 601 // Returning WVR_REDRAW avoids an extra paint before that of the old client |
| 602 // pixels in the (now wrong) location, and thus makes actions like resizing a |
| 603 // window from the left edge look slightly less broken. |
| 604 return mode ? WVR_REDRAW : 0; |
573 } | 605 } |
574 | 606 |
575 LRESULT Window::OnNCHitTest(const CPoint& point) { | 607 LRESULT Window::OnNCHitTest(const CPoint& point) { |
576 // First, give the NonClientView a chance to test the point to see if it | 608 // First, give the NonClientView a chance to test the point to see if it |
577 // provides any of the non-client area. | 609 // provides any of the non-client area. |
578 CPoint temp = point; | 610 CPoint temp = point; |
579 MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); | 611 MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); |
580 int component = non_client_view_->NonClientHitTest(gfx::Point(temp)); | 612 int component = non_client_view_->NonClientHitTest(gfx::Point(temp)); |
581 if (component != HTNOWHERE) | 613 if (component != HTNOWHERE) |
582 return component; | 614 return component; |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 } | 1123 } |
1092 | 1124 |
1093 // Changing the window region is going to force a paint. Only change the | 1125 // Changing the window region is going to force a paint. Only change the |
1094 // window region if the region really differs. | 1126 // window region if the region really differs. |
1095 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); | 1127 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); |
1096 int current_rgn_result = GetWindowRgn(GetHWND(), current_rgn); | 1128 int current_rgn_result = GetWindowRgn(GetHWND(), current_rgn); |
1097 | 1129 |
1098 CRect window_rect; | 1130 CRect window_rect; |
1099 GetWindowRect(&window_rect); | 1131 GetWindowRect(&window_rect); |
1100 HRGN new_region; | 1132 HRGN new_region; |
1101 if (IsMaximized()) { | 1133 gfx::Path window_mask; |
1102 HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); | 1134 non_client_view_->GetWindowMask( |
1103 MONITORINFO mi; | 1135 gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask); |
1104 mi.cbSize = sizeof mi; | 1136 new_region = window_mask.CreateHRGN(); |
1105 GetMonitorInfo(monitor, &mi); | |
1106 CRect work_rect = mi.rcWork; | |
1107 work_rect.OffsetRect(-window_rect.left, -window_rect.top); | |
1108 new_region = CreateRectRgnIndirect(&work_rect); | |
1109 } else { | |
1110 gfx::Path window_mask; | |
1111 non_client_view_->GetWindowMask(gfx::Size(window_rect.Width(), | |
1112 window_rect.Height()), | |
1113 &window_mask); | |
1114 new_region = window_mask.CreateHRGN(); | |
1115 } | |
1116 | 1137 |
1117 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { | 1138 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { |
1118 // SetWindowRgn takes ownership of the HRGN created by CreateHRGN. | 1139 // SetWindowRgn takes ownership of the HRGN created by CreateHRGN. |
1119 SetWindowRgn(new_region, TRUE); | 1140 SetWindowRgn(new_region, TRUE); |
1120 } else { | 1141 } else { |
1121 DeleteObject(new_region); | 1142 DeleteObject(new_region); |
1122 } | 1143 } |
1123 | 1144 |
1124 DeleteObject(current_rgn); | 1145 DeleteObject(current_rgn); |
1125 } | 1146 } |
(...skipping 25 matching lines...) Expand all Loading... |
1151 resize_cursors_[RC_VERTICAL] = LoadCursor(NULL, IDC_SIZENS); | 1172 resize_cursors_[RC_VERTICAL] = LoadCursor(NULL, IDC_SIZENS); |
1152 resize_cursors_[RC_HORIZONTAL] = LoadCursor(NULL, IDC_SIZEWE); | 1173 resize_cursors_[RC_HORIZONTAL] = LoadCursor(NULL, IDC_SIZEWE); |
1153 resize_cursors_[RC_NESW] = LoadCursor(NULL, IDC_SIZENESW); | 1174 resize_cursors_[RC_NESW] = LoadCursor(NULL, IDC_SIZENESW); |
1154 resize_cursors_[RC_NWSE] = LoadCursor(NULL, IDC_SIZENWSE); | 1175 resize_cursors_[RC_NWSE] = LoadCursor(NULL, IDC_SIZENWSE); |
1155 initialized = true; | 1176 initialized = true; |
1156 } | 1177 } |
1157 } | 1178 } |
1158 | 1179 |
1159 } // namespace views | 1180 } // namespace views |
1160 | 1181 |
OLD | NEW |