From e4f2d631670f61c442fca79ce08050a90fb35505 Mon Sep 17 00:00:00 2001 From: "sky@google.com" Date: Thu, 21 Aug 2008 16:41:34 +0000 Subject: Makes resize of custom frame window a bit smoother. I tried a whole slew of variations, and this is the best I could get. From nc calc size we now return WVR_REDRAW, which indicates we need to redraw the frame. Without this I believe windows was copying some bits around for us resulting in the jitter. Additionally in OnNCPaint we do nothing if the root view's size isn't the same as the window's size. This is done as during resizes we get a WM_NCPAINT *before* a WM_SIZE. We also get a WM_NCPAINT after the WM_SIZE, so that it's ok to ignore the first one. BUG=1293978 TEST=make sure sizing of task manager/keyword editor doesn't break. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1157 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/views/custom_frame_window.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'chrome') diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc index 7679e3f..e045e8b 100644 --- a/chrome/views/custom_frame_window.cc +++ b/chrome/views/custom_frame_window.cc @@ -986,8 +986,10 @@ LRESULT CustomFrameWindow::OnNCCalcSize(BOOL mode, LPARAM l_param) { RECT* rect = reinterpret_cast(l_param); *rect = non_client_view_->CalculateClientAreaBounds( rect->right - rect->left, rect->bottom - rect->top).ToRECT(); + return 0; } - return 0; + // We need to repaint all when the window bounds change. + return WVR_REDRAW; } LRESULT CustomFrameWindow::OnNCHitTest(const CPoint& point) { @@ -1043,6 +1045,17 @@ void CustomFrameWindow::OnNCPaint(HRGN rgn) { CRect window_rect; GetWindowRect(&window_rect); + if (window_rect.Width() != root_view_->GetWidth() || + window_rect.Height() != root_view_->GetHeight()) { + // If the size of the window differs from the size of the root view it + // means we're being asked to paint before we've gotten a WM_SIZE. This can + // happen when the user is interactively resizing the window. To avoid + // mass flickering we don't do anything here. Once we get the WM_SIZE we'll + // reset the region of the window which triggers another WM_NCPAINT and + // all is well. + return; + } + CRect dirty_region; // A value of 1 indicates paint all. if (!rgn || rgn == reinterpret_cast(1)) { -- cgit v1.1