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

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

Issue 673623002: Fix regions generation on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix update region conditions. Created 6 years, 1 month 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 | « ui/gfx/path_win_unittest.cc ('k') | 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 <wtsapi32.h> 10 #include <wtsapi32.h>
11 #pragma comment(lib, "wtsapi32.lib") 11 #pragma comment(lib, "wtsapi32.lib")
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
15 #include "base/win/scoped_gdi_object.h"
15 #include "base/win/win_util.h" 16 #include "base/win/win_util.h"
16 #include "base/win/windows_version.h" 17 #include "base/win/windows_version.h"
17 #include "ui/base/touch/touch_enabled.h" 18 #include "ui/base/touch/touch_enabled.h"
18 #include "ui/base/view_prop.h" 19 #include "ui/base/view_prop.h"
19 #include "ui/base/win/internal_constants.h" 20 #include "ui/base/win/internal_constants.h"
20 #include "ui/base/win/lock_state.h" 21 #include "ui/base/win/lock_state.h"
21 #include "ui/base/win/mouse_wheel_util.h" 22 #include "ui/base/win/mouse_wheel_util.h"
22 #include "ui/base/win/shell.h" 23 #include "ui/base/win/shell.h"
23 #include "ui/base/win/touch_input.h" 24 #include "ui/base/win/touch_input.h"
24 #include "ui/events/event.h" 25 #include "ui/events/event.h"
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 // the delegate to allow for a custom hit mask. 1122 // the delegate to allow for a custom hit mask.
1122 if ((window_ex_style() & WS_EX_COMPOSITED) == 0 && !custom_window_region_ && 1123 if ((window_ex_style() & WS_EX_COMPOSITED) == 0 && !custom_window_region_ &&
1123 (!delegate_->IsUsingCustomFrame() || !delegate_->IsWidgetWindow())) { 1124 (!delegate_->IsUsingCustomFrame() || !delegate_->IsWidgetWindow())) {
1124 if (force) 1125 if (force)
1125 SetWindowRgn(hwnd(), NULL, redraw); 1126 SetWindowRgn(hwnd(), NULL, redraw);
1126 return; 1127 return;
1127 } 1128 }
1128 1129
1129 // Changing the window region is going to force a paint. Only change the 1130 // Changing the window region is going to force a paint. Only change the
1130 // window region if the region really differs. 1131 // window region if the region really differs.
1131 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0); 1132 base::win::ScopedRegion current_rgn(CreateRectRgn(0, 0, 0, 0));
1132 int current_rgn_result = GetWindowRgn(hwnd(), current_rgn); 1133 int current_rgn_result = GetWindowRgn(hwnd(), current_rgn);
1133 1134
1134 RECT window_rect; 1135 RECT window_rect;
1135 GetWindowRect(hwnd(), &window_rect); 1136 GetWindowRect(hwnd(), &window_rect);
1136 HRGN new_region; 1137 base::win::ScopedRegion new_region;
1137 if (custom_window_region_) { 1138 if (custom_window_region_) {
1138 new_region = ::CreateRectRgn(0, 0, 0, 0); 1139 new_region.Set(::CreateRectRgn(0, 0, 0, 0));
1139 ::CombineRgn(new_region, custom_window_region_.Get(), NULL, RGN_COPY); 1140 ::CombineRgn(new_region, custom_window_region_.Get(), NULL, RGN_COPY);
1140 } else if (IsMaximized()) { 1141 } else if (IsMaximized()) {
1141 HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST); 1142 HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST);
1142 MONITORINFO mi; 1143 MONITORINFO mi;
1143 mi.cbSize = sizeof mi; 1144 mi.cbSize = sizeof mi;
1144 GetMonitorInfo(monitor, &mi); 1145 GetMonitorInfo(monitor, &mi);
1145 RECT work_rect = mi.rcWork; 1146 RECT work_rect = mi.rcWork;
1146 OffsetRect(&work_rect, -window_rect.left, -window_rect.top); 1147 OffsetRect(&work_rect, -window_rect.left, -window_rect.top);
1147 new_region = CreateRectRgnIndirect(&work_rect); 1148 new_region.Set(CreateRectRgnIndirect(&work_rect));
1148 } else { 1149 } else {
1149 gfx::Path window_mask; 1150 gfx::Path window_mask;
1150 delegate_->GetWindowMask(gfx::Size(window_rect.right - window_rect.left, 1151 delegate_->GetWindowMask(gfx::Size(window_rect.right - window_rect.left,
1151 window_rect.bottom - window_rect.top), 1152 window_rect.bottom - window_rect.top),
1152 &window_mask); 1153 &window_mask);
1153 new_region = gfx::CreateHRGNFromSkPath(window_mask); 1154 if (!window_mask.isEmpty())
1155 new_region.Set(gfx::CreateHRGNFromSkPath(window_mask));
1154 } 1156 }
1155 1157
1156 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { 1158 if (!!current_rgn != !!new_region ||
sky 2014/11/12 15:28:36 Wow, could you make this any harder to read? Pleas
alex-ac 2014/11/13 08:24:40 Done.
1159 current_rgn && !EqualRgn(current_rgn, new_region)) {
1157 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion. 1160 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion.
1158 SetWindowRgn(hwnd(), new_region, redraw); 1161 SetWindowRgn(hwnd(), new_region, redraw);
sky 2014/11/12 15:28:36 Doesn't this need to release now?
alex-ac 2014/11/13 08:24:40 Done.
1159 } else {
1160 DeleteObject(new_region);
1161 } 1162 }
1162
1163 DeleteObject(current_rgn);
1164 } 1163 }
1165 1164
1166 void HWNDMessageHandler::UpdateDwmNcRenderingPolicy() { 1165 void HWNDMessageHandler::UpdateDwmNcRenderingPolicy() {
1167 if (base::win::GetVersion() < base::win::VERSION_VISTA) 1166 if (base::win::GetVersion() < base::win::VERSION_VISTA)
1168 return; 1167 return;
1169 1168
1170 if (fullscreen_handler_->fullscreen()) 1169 if (fullscreen_handler_->fullscreen())
1171 return; 1170 return;
1172 1171
1173 DWMNCRENDERINGPOLICY policy = 1172 DWMNCRENDERINGPOLICY policy =
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); 2492 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW);
2494 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); 2493 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW);
2495 } 2494 }
2496 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want 2495 // 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 2496 // to notify our children too, since we can have MDI child windows who need to
2498 // update their appearance. 2497 // update their appearance.
2499 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); 2498 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL);
2500 } 2499 }
2501 2500
2502 } // namespace views 2501 } // namespace views
OLDNEW
« no previous file with comments | « ui/gfx/path_win_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698