diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-10 23:32:33 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-10 23:32:33 +0000 |
commit | e25189fa9ab9d506dd3a8118f520790d344a072c (patch) | |
tree | 507c65661dee260b411702255a514116faa11912 | |
parent | e2756703a3c14d7c60c6a476f4452ae60fb0adaf (diff) | |
download | chromium_src-e25189fa9ab9d506dd3a8118f520790d344a072c.zip chromium_src-e25189fa9ab9d506dd3a8118f520790d344a072c.tar.gz chromium_src-e25189fa9ab9d506dd3a8118f520790d344a072c.tar.bz2 |
Fix black titlebar rendering when toggling DWM when the window is maximized:
- restore window after hiding it, since our hide hack only works for non-maximized windows
- handle WM_WINDOWPOSCHANGING in this case to make sure the window isn't made visible by the restore action
http://crbug.com/8526
Review URL: http://codereview.chromium.org/43052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11401 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/views/non_client_view.cc | 7 | ||||
-rw-r--r-- | chrome/views/widget_win.h | 4 | ||||
-rw-r--r-- | chrome/views/window.cc | 18 | ||||
-rw-r--r-- | chrome/views/window.h | 8 |
4 files changed, 34 insertions, 3 deletions
diff --git a/chrome/views/non_client_view.cc b/chrome/views/non_client_view.cc index 8568969..79448af 100644 --- a/chrome/views/non_client_view.cc +++ b/chrome/views/non_client_view.cc @@ -66,6 +66,13 @@ void NonClientView::SystemThemeChanged() { GetWindowPlacement(frame_->GetHWND(), &saved_window_placement); frame_->Hide(); + // Important step: restore the window first, since our hiding hack doesn't + // work for maximized windows! We tell the frame not to allow itself to be + // made visible though, which removes the brief flicker. + frame_->set_force_hidden(true); + ShowWindow(frame_->GetHWND(), SW_RESTORE); + frame_->set_force_hidden(false); + SetUseNativeFrame(win_util::ShouldUseVistaFrame()); // Now that we've updated the frame, we'll want to restore our saved placement diff --git a/chrome/views/widget_win.h b/chrome/views/widget_win.h index 4ec5acb..cf2274e 100644 --- a/chrome/views/widget_win.h +++ b/chrome/views/widget_win.h @@ -244,6 +244,7 @@ class WidgetWin : public Widget, MSG_WM_SYSCOMMAND(OnSysCommand) MSG_WM_THEMECHANGED(OnThemeChanged) MSG_WM_VSCROLL(OnVScroll) + MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging) MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged) END_MSG_MAP() @@ -476,6 +477,9 @@ class WidgetWin : public Widget, virtual void OnVScroll(int scroll_type, short position, HWND scrollbar) { SetMsgHandled(FALSE); } + virtual void OnWindowPosChanging(WINDOWPOS* window_pos) { + SetMsgHandled(FALSE); + } virtual void OnWindowPosChanged(WINDOWPOS* window_pos) { SetMsgHandled(FALSE); } diff --git a/chrome/views/window.cc b/chrome/views/window.cc index d8ea0e9..0548fa4 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -325,7 +325,8 @@ Window::Window(WindowDelegate* window_delegate) is_active_(false), lock_updates_(false), saved_window_style_(0), - saved_maximized_state_(0) { + saved_maximized_state_(0), + force_hidden_(false) { InitClass(); DCHECK(window_delegate_); window_delegate_->window_.reset(this); @@ -650,8 +651,10 @@ static BOOL CALLBACK ClipDCToChild(HWND window, LPARAM param) { void Window::OnNCPaint(HRGN rgn) { // We only do non-client painting if we're not using the native frame. - if (non_client_view_->UseNativeFrame()) - return WidgetWin::OnNCPaint(rgn); + if (non_client_view_->UseNativeFrame()) { + WidgetWin::OnNCPaint(rgn); + 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 @@ -917,6 +920,15 @@ void Window::OnSysCommand(UINT notification_code, CPoint click) { } } +void Window::OnWindowPosChanging(WINDOWPOS* window_pos) { + if (force_hidden_) { + // Prevent the window from being made visible if we've been asked to do so. + // See comment in header as to why we might want this. + window_pos->flags &= ~SWP_SHOWWINDOW; + } + WidgetWin::OnWindowPosChanging(window_pos); +} + //////////////////////////////////////////////////////////////////////////////// // Window, private: diff --git a/chrome/views/window.h b/chrome/views/window.h index c6c3d37..9fe85dd 100644 --- a/chrome/views/window.h +++ b/chrome/views/window.h @@ -116,6 +116,7 @@ class Window : public WidgetWin, void set_focus_on_creation(bool focus_on_creation) { focus_on_creation_ = focus_on_creation; } + void set_force_hidden(bool force_hidden) { force_hidden_ = force_hidden; } // Returns the preferred size of the contents view of this window based on // its localized size data. The width in cols is held in a localized string @@ -178,6 +179,7 @@ class Window : public WidgetWin, virtual LRESULT OnSetText(const wchar_t* text); virtual void OnSize(UINT size_param, const CSize& new_size); virtual void OnSysCommand(UINT notification_code, CPoint click); + virtual void OnWindowPosChanging(WINDOWPOS* window_pos); virtual Window* AsWindow() { return this; } virtual const Window* AsWindow() const { return this; } @@ -304,6 +306,12 @@ class Window : public WidgetWin, // that explains why we save this. bool saved_maximized_state_; + // True if we should prevent attempts to make the window visible when we + // handle WM_WINDOWPOSCHANGING. Some calls like ShowWindow(SW_RESTORE) make + // the window visible in addition to restoring it, when all we want to do is + // restore it. + bool force_hidden_; + // Hold onto notifications. NotificationRegistrar notification_registrar_; |