OLD | NEW |
---|---|
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 <wtsapi32.h> | 10 #include <wtsapi32.h> |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1126 return; | 1126 return; |
1127 } | 1127 } |
1128 | 1128 |
1129 // Changing the window region is going to force a paint. Only change the | 1129 // Changing the window region is going to force a paint. Only change the |
1130 // window region if the region really differs. | 1130 // window region if the region really differs. |
1131 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); | 1131 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); |
1132 int current_rgn_result = GetWindowRgn(hwnd(), current_rgn); | 1132 int current_rgn_result = GetWindowRgn(hwnd(), current_rgn); |
1133 | 1133 |
1134 RECT window_rect; | 1134 RECT window_rect; |
1135 GetWindowRect(hwnd(), &window_rect); | 1135 GetWindowRect(hwnd(), &window_rect); |
1136 HRGN new_region; | 1136 HRGN new_region = NULL; |
Wez
2014/10/27 20:28:39
While you're here, I'd suggest using ScopedRegion
alex-ac
2014/10/28 10:38:36
Done.
| |
1137 if (custom_window_region_) { | 1137 if (custom_window_region_) { |
1138 new_region = ::CreateRectRgn(0, 0, 0, 0); | 1138 new_region = ::CreateRectRgn(0, 0, 0, 0); |
1139 ::CombineRgn(new_region, custom_window_region_.Get(), NULL, RGN_COPY); | 1139 ::CombineRgn(new_region, custom_window_region_.Get(), NULL, RGN_COPY); |
1140 } else if (IsMaximized()) { | 1140 } else if (IsMaximized()) { |
1141 HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST); | 1141 HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST); |
1142 MONITORINFO mi; | 1142 MONITORINFO mi; |
1143 mi.cbSize = sizeof mi; | 1143 mi.cbSize = sizeof mi; |
1144 GetMonitorInfo(monitor, &mi); | 1144 GetMonitorInfo(monitor, &mi); |
1145 RECT work_rect = mi.rcWork; | 1145 RECT work_rect = mi.rcWork; |
1146 OffsetRect(&work_rect, -window_rect.left, -window_rect.top); | 1146 OffsetRect(&work_rect, -window_rect.left, -window_rect.top); |
1147 new_region = CreateRectRgnIndirect(&work_rect); | 1147 new_region = CreateRectRgnIndirect(&work_rect); |
1148 } else { | 1148 } else { |
1149 gfx::Path window_mask; | 1149 gfx::Path window_mask; |
1150 delegate_->GetWindowMask(gfx::Size(window_rect.right - window_rect.left, | 1150 delegate_->GetWindowMask(gfx::Size(window_rect.right - window_rect.left, |
1151 window_rect.bottom - window_rect.top), | 1151 window_rect.bottom - window_rect.top), |
1152 &window_mask); | 1152 &window_mask); |
1153 new_region = gfx::CreateHRGNFromSkPath(window_mask); | 1153 if (!window_mask.isEmpty()) |
1154 new_region = gfx::CreateHRGNFromSkPath(window_mask); | |
1154 } | 1155 } |
1155 | 1156 |
1156 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { | 1157 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { |
1157 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion. | 1158 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion. |
1158 SetWindowRgn(hwnd(), new_region, redraw); | 1159 SetWindowRgn(hwnd(), new_region, redraw); |
1159 } else { | 1160 } else { |
1160 DeleteObject(new_region); | 1161 DeleteObject(new_region); |
1161 } | 1162 } |
1162 | 1163 |
1163 DeleteObject(current_rgn); | 1164 DeleteObject(current_rgn); |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2493 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); | 2494 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
2494 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); | 2495 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
2495 } | 2496 } |
2496 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 2497 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
2497 // to notify our children too, since we can have MDI child windows who need to | 2498 // to notify our children too, since we can have MDI child windows who need to |
2498 // update their appearance. | 2499 // update their appearance. |
2499 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 2500 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
2500 } | 2501 } |
2501 | 2502 |
2502 } // namespace views | 2503 } // namespace views |
OLD | NEW |