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

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

Issue 1811913007: Fix window drawing after snap on Windows 10. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix signedness Created 4 years, 4 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 | « ui/views/win/hwnd_message_handler.h ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | 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 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 TrackMouseEvents(mouse_tracking_flags); 1096 TrackMouseEvents(mouse_tracking_flags);
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 void HWNDMessageHandler::ClientAreaSizeChanged() { 1100 void HWNDMessageHandler::ClientAreaSizeChanged() {
1101 // Ignore size changes due to fullscreen windows losing activation. 1101 // Ignore size changes due to fullscreen windows losing activation.
1102 if (background_fullscreen_hack_ && !sent_window_size_changing_) 1102 if (background_fullscreen_hack_ && !sent_window_size_changing_)
1103 return; 1103 return;
1104 gfx::Size s = GetClientAreaBounds().size(); 1104 gfx::Size s = GetClientAreaBounds().size();
1105 delegate_->HandleClientSizeChanged(s); 1105 delegate_->HandleClientSizeChanged(s);
1106
1107 current_window_size_message_++;
1108 sent_window_size_changing_ = false;
1106 } 1109 }
1107 1110
1108 bool HWNDMessageHandler::GetClientAreaInsets(gfx::Insets* insets) const { 1111 bool HWNDMessageHandler::GetClientAreaInsets(gfx::Insets* insets) const {
1109 if (delegate_->GetClientAreaInsets(insets)) 1112 if (delegate_->GetClientAreaInsets(insets))
1110 return true; 1113 return true;
1111 DCHECK(insets->IsEmpty()); 1114 DCHECK(insets->IsEmpty());
1112 1115
1113 // Returning false causes the default handling in OnNCCalcSize() to 1116 // Returning false causes the default handling in OnNCCalcSize() to
1114 // be invoked. 1117 // be invoked.
1115 if (!delegate_->HasNonClientView() || HasSystemFrame()) 1118 if (!delegate_->HasNonClientView() || HasSystemFrame())
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 2270
2268 RECT window_rect; 2271 RECT window_rect;
2269 gfx::Size old_size; 2272 gfx::Size old_size;
2270 if (GetWindowRect(hwnd(), &window_rect)) 2273 if (GetWindowRect(hwnd(), &window_rect))
2271 old_size = gfx::Rect(window_rect).size(); 2274 old_size = gfx::Rect(window_rect).size();
2272 gfx::Size new_size = gfx::Size(window_pos->cx, window_pos->cy); 2275 gfx::Size new_size = gfx::Size(window_pos->cx, window_pos->cy);
2273 if ((old_size != new_size && !(window_pos->flags & SWP_NOSIZE)) || 2276 if ((old_size != new_size && !(window_pos->flags & SWP_NOSIZE)) ||
2274 window_pos->flags & SWP_FRAMECHANGED) { 2277 window_pos->flags & SWP_FRAMECHANGED) {
2275 delegate_->HandleWindowSizeChanging(); 2278 delegate_->HandleWindowSizeChanging();
2276 sent_window_size_changing_ = true; 2279 sent_window_size_changing_ = true;
2280
2281 // It's possible that if Aero snap is being entered then the window size
2282 // won't actually change. Post a message to ensure swaps will be re-enabled
2283 // in that case.
2284 PostMessage(hwnd(), WM_WINDOWSIZINGFINISHED, ++current_window_size_message_,
2285 0);
2277 } 2286 }
2278 2287
2279 if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) { 2288 if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) {
2280 // Prevent the window from being made visible if we've been asked to do so. 2289 // Prevent the window from being made visible if we've been asked to do so.
2281 // See comment in header as to why we might want this. 2290 // See comment in header as to why we might want this.
2282 window_pos->flags &= ~SWP_SHOWWINDOW; 2291 window_pos->flags &= ~SWP_SHOWWINDOW;
2283 } 2292 }
2284 2293
2285 if (window_pos->flags & SWP_SHOWWINDOW) 2294 if (window_pos->flags & SWP_SHOWWINDOW)
2286 delegate_->HandleVisibilityChanging(true); 2295 delegate_->HandleVisibilityChanging(true);
(...skipping 13 matching lines...) Expand all
2300 if (window_pos->flags & SWP_SHOWWINDOW) { 2309 if (window_pos->flags & SWP_SHOWWINDOW) {
2301 delegate_->HandleVisibilityChanged(true); 2310 delegate_->HandleVisibilityChanged(true);
2302 if (direct_manipulation_helper_) 2311 if (direct_manipulation_helper_)
2303 direct_manipulation_helper_->Activate(hwnd()); 2312 direct_manipulation_helper_->Activate(hwnd());
2304 SetDwmFrameExtension(DwmFrameState::ON); 2313 SetDwmFrameExtension(DwmFrameState::ON);
2305 } else if (window_pos->flags & SWP_HIDEWINDOW) { 2314 } else if (window_pos->flags & SWP_HIDEWINDOW) {
2306 delegate_->HandleVisibilityChanged(false); 2315 delegate_->HandleVisibilityChanged(false);
2307 if (direct_manipulation_helper_) 2316 if (direct_manipulation_helper_)
2308 direct_manipulation_helper_->Deactivate(hwnd()); 2317 direct_manipulation_helper_->Deactivate(hwnd());
2309 } 2318 }
2310 if (sent_window_size_changing_) { 2319
2311 sent_window_size_changing_ = false;
2312 delegate_->HandleWindowSizeChanged();
2313 }
2314 SetMsgHandled(FALSE); 2320 SetMsgHandled(FALSE);
2315 } 2321 }
2316 2322
2323 LRESULT HWNDMessageHandler::OnWindowSizingFinished(UINT message,
2324 WPARAM w_param,
2325 LPARAM l_param) {
2326 // Check if a newer WM_WINDOWPOSCHANGING or WM_WINDOWPOSCHANGED have been
2327 // received after this message was posted.
2328 if (current_window_size_message_ != w_param)
2329 return 0;
2330
2331 delegate_->HandleWindowSizeUnchanged();
2332 sent_window_size_changing_ = false;
2333
sky 2016/08/01 15:30:09 SetMsgHanded(FALSE)?
2334 return 0;
2335 }
2336
2317 void HWNDMessageHandler::OnSessionChange(WPARAM status_code) { 2337 void HWNDMessageHandler::OnSessionChange(WPARAM status_code) {
2318 // Direct3D presents are ignored while the screen is locked, so force the 2338 // Direct3D presents are ignored while the screen is locked, so force the
2319 // window to be redrawn on unlock. 2339 // window to be redrawn on unlock.
2320 if (status_code == WTS_SESSION_UNLOCK) 2340 if (status_code == WTS_SESSION_UNLOCK)
2321 ForceRedrawWindow(10); 2341 ForceRedrawWindow(10);
2322 } 2342 }
2323 2343
2324 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { 2344 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) {
2325 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); 2345 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
2326 for (size_t i = 0; i < touch_events.size() && ref; ++i) 2346 for (size_t i = 0; i < touch_events.size() && ref; ++i)
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 MONITORINFO monitor_info = {sizeof(monitor_info)}; 2691 MONITORINFO monitor_info = {sizeof(monitor_info)};
2672 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), 2692 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY),
2673 &monitor_info); 2693 &monitor_info);
2674 gfx::Rect shrunk_rect(monitor_info.rcMonitor); 2694 gfx::Rect shrunk_rect(monitor_info.rcMonitor);
2675 shrunk_rect.set_height(shrunk_rect.height() - 1); 2695 shrunk_rect.set_height(shrunk_rect.height() - 1);
2676 background_fullscreen_hack_ = true; 2696 background_fullscreen_hack_ = true;
2677 SetBoundsInternal(shrunk_rect, false); 2697 SetBoundsInternal(shrunk_rect, false);
2678 } 2698 }
2679 2699
2680 } // namespace views 2700 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/win/hwnd_message_handler.h ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698