Chromium Code Reviews| Index: ui/views/win/hwnd_message_handler.cc |
| diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc |
| index 531b4881a52f56d1dfe62604a6999364b81b6fd9..26ae06b06786545fcd5d9fa2398ae943b2dcf4e5 100644 |
| --- a/ui/views/win/hwnd_message_handler.cc |
| +++ b/ui/views/win/hwnd_message_handler.cc |
| @@ -1796,21 +1796,58 @@ LRESULT HWNDMessageHandler::OnNCHitTest(const gfx::Point& point) { |
| } |
| void HWNDMessageHandler::OnNCPaint(HRGN rgn) { |
| + RECT window_rect; |
|
ananta
2016/04/02 01:35:06
This code is only needed for Aero frames?. Perhaps
jbauman
2016/04/04 21:19:54
No, this is also needed to get the dirty_region fo
|
| + GetWindowRect(hwnd(), &window_rect); |
| + RECT dirty_region; |
| + // A value of 1 indicates paint all. |
| + if (!rgn || rgn == reinterpret_cast<HRGN>(1)) { |
| + dirty_region.left = 0; |
| + dirty_region.top = 0; |
| + dirty_region.right = window_rect.right - window_rect.left; |
| + dirty_region.bottom = window_rect.bottom - window_rect.top; |
| + } else { |
| + RECT rgn_bounding_box; |
| + GetRgnBox(rgn, &rgn_bounding_box); |
| + if (!IntersectRect(&dirty_region, &rgn_bounding_box, &window_rect)) |
| + return; // Dirty region doesn't intersect window bounds, bale. |
|
sky
2016/04/01 23:55:52
If you early return do you need to SetMsgHandled?
ananta
2016/04/04 23:32:15
+1. We should call SetMsgHandled(FALSE) here.
|
| + |
| + // rgn_bounding_box is in screen coordinates. Map it to window coordinates. |
| + OffsetRect(&dirty_region, -window_rect.left, -window_rect.top); |
| + } |
| + |
| // We only do non-client painting if we're not using the system frame. |
| // It's required to avoid some native painting artifacts from appearing when |
| // the window is resized. |
| if (!delegate_->HasNonClientView() || |
| delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) { |
| + if (ui::win::IsAeroGlassEnabled()) { |
| + // The default WM_NCPAINT handler under Aero Glass doesn't clear the |
| + // nonclient area, so it'll remain the default white color. That area is |
| + // invisible initially (covered by the window border) but can become |
| + // temporarily visible on maximizing or fullscreening, so clear it here. |
| + HDC dc = GetWindowDC(hwnd()); |
| + RECT client_rect; |
| + ::GetClientRect(hwnd(), &client_rect); |
| + ::MapWindowPoints(hwnd(), nullptr, reinterpret_cast<POINT*>(&client_rect), |
| + 2); |
| + ::OffsetRect(&client_rect, -window_rect.left, -window_rect.top); |
|
ananta
2016/04/02 01:35:06
MapWindowPoints converts to screen above. Why is t
jbauman
2016/04/04 21:19:54
We need client_rect to be relative to the top-left
|
| + // client_rect now is in window space. |
| + |
| + base::win::ScopedRegion base(::CreateRectRgnIndirect(&dirty_region)); |
| + base::win::ScopedRegion client(::CreateRectRgnIndirect(&client_rect)); |
| + base::win::ScopedRegion nonclient(::CreateRectRgn(0, 0, 0, 0)); |
| + ::CombineRgn(nonclient.get(), base.get(), client.get(), RGN_DIFF); |
| + |
| + ::SelectClipRgn(dc, nonclient.get()); |
| + HBRUSH brush = CreateSolidBrush(0); |
| + ::FillRect(dc, &dirty_region, brush); |
| + ::DeleteObject(brush); |
| + ::ReleaseDC(hwnd(), dc); |
| + } |
| SetMsgHandled(FALSE); |
| return; |
| } |
| - // We have an NC region and need to paint it. We expand the NC region to |
| - // include the dirty region of the root view. This is done to minimize |
| - // paints. |
| - RECT window_rect; |
| - GetWindowRect(hwnd(), &window_rect); |
| - |
| gfx::Size root_view_size = delegate_->GetRootViewSize(); |
| if (gfx::Size(window_rect.right - window_rect.left, |
| window_rect.bottom - window_rect.top) != root_view_size) { |
| @@ -1822,24 +1859,6 @@ void HWNDMessageHandler::OnNCPaint(HRGN rgn) { |
| // all is well. |
| return; |
| } |
| - |
| - RECT dirty_region; |
| - // A value of 1 indicates paint all. |
| - if (!rgn || rgn == reinterpret_cast<HRGN>(1)) { |
| - dirty_region.left = 0; |
| - dirty_region.top = 0; |
| - dirty_region.right = window_rect.right - window_rect.left; |
| - dirty_region.bottom = window_rect.bottom - window_rect.top; |
| - } else { |
| - RECT rgn_bounding_box; |
| - GetRgnBox(rgn, &rgn_bounding_box); |
| - if (!IntersectRect(&dirty_region, &rgn_bounding_box, &window_rect)) |
| - return; // Dirty region doesn't intersect window bounds, bale. |
| - |
| - // rgn_bounding_box is in screen coordinates. Map it to window coordinates. |
| - OffsetRect(&dirty_region, -window_rect.left, -window_rect.top); |
| - } |
| - |
| delegate_->HandlePaintAccelerated(gfx::Rect(dirty_region)); |
| // When using a custom frame, we want to avoid calling DefWindowProc() since |