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

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

Issue 1852613003: Remove flash of white borders on maximize/fullscreen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | 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 <tchar.h> 10 #include <tchar.h>
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 } 1789 }
1790 1790
1791 default: 1791 default:
1792 break; 1792 break;
1793 } 1793 }
1794 } 1794 }
1795 return hit_test_code; 1795 return hit_test_code;
1796 } 1796 }
1797 1797
1798 void HWNDMessageHandler::OnNCPaint(HRGN rgn) { 1798 void HWNDMessageHandler::OnNCPaint(HRGN rgn) {
1799 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
1800 GetWindowRect(hwnd(), &window_rect);
1801 RECT dirty_region;
1802 // A value of 1 indicates paint all.
1803 if (!rgn || rgn == reinterpret_cast<HRGN>(1)) {
1804 dirty_region.left = 0;
1805 dirty_region.top = 0;
1806 dirty_region.right = window_rect.right - window_rect.left;
1807 dirty_region.bottom = window_rect.bottom - window_rect.top;
1808 } else {
1809 RECT rgn_bounding_box;
1810 GetRgnBox(rgn, &rgn_bounding_box);
1811 if (!IntersectRect(&dirty_region, &rgn_bounding_box, &window_rect))
1812 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.
1813
1814 // rgn_bounding_box is in screen coordinates. Map it to window coordinates.
1815 OffsetRect(&dirty_region, -window_rect.left, -window_rect.top);
1816 }
1817
1799 // We only do non-client painting if we're not using the system frame. 1818 // We only do non-client painting if we're not using the system frame.
1800 // It's required to avoid some native painting artifacts from appearing when 1819 // It's required to avoid some native painting artifacts from appearing when
1801 // the window is resized. 1820 // the window is resized.
1802 if (!delegate_->HasNonClientView() || 1821 if (!delegate_->HasNonClientView() ||
1803 delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) { 1822 delegate_->GetFrameMode() == FrameMode::SYSTEM_DRAWN) {
1823 if (ui::win::IsAeroGlassEnabled()) {
1824 // The default WM_NCPAINT handler under Aero Glass doesn't clear the
1825 // nonclient area, so it'll remain the default white color. That area is
1826 // invisible initially (covered by the window border) but can become
1827 // temporarily visible on maximizing or fullscreening, so clear it here.
1828 HDC dc = GetWindowDC(hwnd());
1829 RECT client_rect;
1830 ::GetClientRect(hwnd(), &client_rect);
1831 ::MapWindowPoints(hwnd(), nullptr, reinterpret_cast<POINT*>(&client_rect),
1832 2);
1833 ::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
1834 // client_rect now is in window space.
1835
1836 base::win::ScopedRegion base(::CreateRectRgnIndirect(&dirty_region));
1837 base::win::ScopedRegion client(::CreateRectRgnIndirect(&client_rect));
1838 base::win::ScopedRegion nonclient(::CreateRectRgn(0, 0, 0, 0));
1839 ::CombineRgn(nonclient.get(), base.get(), client.get(), RGN_DIFF);
1840
1841 ::SelectClipRgn(dc, nonclient.get());
1842 HBRUSH brush = CreateSolidBrush(0);
1843 ::FillRect(dc, &dirty_region, brush);
1844 ::DeleteObject(brush);
1845 ::ReleaseDC(hwnd(), dc);
1846 }
1804 SetMsgHandled(FALSE); 1847 SetMsgHandled(FALSE);
1805 return; 1848 return;
1806 } 1849 }
1807 1850
1808 // We have an NC region and need to paint it. We expand the NC region to
1809 // include the dirty region of the root view. This is done to minimize
1810 // paints.
1811 RECT window_rect;
1812 GetWindowRect(hwnd(), &window_rect);
1813
1814 gfx::Size root_view_size = delegate_->GetRootViewSize(); 1851 gfx::Size root_view_size = delegate_->GetRootViewSize();
1815 if (gfx::Size(window_rect.right - window_rect.left, 1852 if (gfx::Size(window_rect.right - window_rect.left,
1816 window_rect.bottom - window_rect.top) != root_view_size) { 1853 window_rect.bottom - window_rect.top) != root_view_size) {
1817 // If the size of the window differs from the size of the root view it 1854 // If the size of the window differs from the size of the root view it
1818 // means we're being asked to paint before we've gotten a WM_SIZE. This can 1855 // means we're being asked to paint before we've gotten a WM_SIZE. This can
1819 // happen when the user is interactively resizing the window. To avoid 1856 // happen when the user is interactively resizing the window. To avoid
1820 // mass flickering we don't do anything here. Once we get the WM_SIZE we'll 1857 // mass flickering we don't do anything here. Once we get the WM_SIZE we'll
1821 // reset the region of the window which triggers another WM_NCPAINT and 1858 // reset the region of the window which triggers another WM_NCPAINT and
1822 // all is well. 1859 // all is well.
1823 return; 1860 return;
1824 } 1861 }
1825
1826 RECT dirty_region;
1827 // A value of 1 indicates paint all.
1828 if (!rgn || rgn == reinterpret_cast<HRGN>(1)) {
1829 dirty_region.left = 0;
1830 dirty_region.top = 0;
1831 dirty_region.right = window_rect.right - window_rect.left;
1832 dirty_region.bottom = window_rect.bottom - window_rect.top;
1833 } else {
1834 RECT rgn_bounding_box;
1835 GetRgnBox(rgn, &rgn_bounding_box);
1836 if (!IntersectRect(&dirty_region, &rgn_bounding_box, &window_rect))
1837 return; // Dirty region doesn't intersect window bounds, bale.
1838
1839 // rgn_bounding_box is in screen coordinates. Map it to window coordinates.
1840 OffsetRect(&dirty_region, -window_rect.left, -window_rect.top);
1841 }
1842
1843 delegate_->HandlePaintAccelerated(gfx::Rect(dirty_region)); 1862 delegate_->HandlePaintAccelerated(gfx::Rect(dirty_region));
1844 1863
1845 // When using a custom frame, we want to avoid calling DefWindowProc() since 1864 // When using a custom frame, we want to avoid calling DefWindowProc() since
1846 // that may render artifacts. 1865 // that may render artifacts.
1847 SetMsgHandled(delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN); 1866 SetMsgHandled(delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN);
1848 } 1867 }
1849 1868
1850 LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message, 1869 LRESULT HWNDMessageHandler::OnNCUAHDrawCaption(UINT message,
1851 WPARAM w_param, 1870 WPARAM w_param,
1852 LPARAM l_param) { 1871 LPARAM l_param) {
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size()); 2648 delegate_->HandleClientSizeChanged(GetClientAreaBounds().size());
2630 ResetWindowRegion(false, true); 2649 ResetWindowRegion(false, true);
2631 } 2650 }
2632 2651
2633 if (direct_manipulation_helper_) 2652 if (direct_manipulation_helper_)
2634 direct_manipulation_helper_->SetBounds(bounds_in_pixels); 2653 direct_manipulation_helper_->SetBounds(bounds_in_pixels);
2635 } 2654 }
2636 2655
2637 2656
2638 } // namespace views 2657 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698