diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-31 07:39:29 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-31 07:39:29 +0000 |
commit | 86681b9dccc5d4ea00d5f767f0e9bf417c618cc9 (patch) | |
tree | c1eada026dcccecd2163ce62d1e1472bce267610 /views/window/window_win.cc | |
parent | 878ae96bea0bb797e2a47b7a685c56cb6b5601d0 (diff) | |
download | chromium_src-86681b9dccc5d4ea00d5f767f0e9bf417c618cc9.zip chromium_src-86681b9dccc5d4ea00d5f767f0e9bf417c618cc9.tar.gz chromium_src-86681b9dccc5d4ea00d5f767f0e9bf417c618cc9.tar.bz2 |
Use the right frame type on startup, do proper swapping of frames when themes change. Leave the native frame decision up to the ThemeProvider.
BUG=12890
TEST=In Aero, unstall a theme, reset to default, install again, restart, reset theme to default. Make sure that the Aero frame changes to the themed frame and back again appropriately.
Review URL: http://codereview.chromium.org/118053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window/window_win.cc')
-rw-r--r-- | views/window/window_win.cc | 92 |
1 files changed, 52 insertions, 40 deletions
diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 3e52871..3759851 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -12,6 +12,7 @@ #include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "app/theme_provider.h" #include "app/win_util.h" #include "base/win_util.h" #include "views/widget/root_view.h" @@ -182,6 +183,48 @@ void WindowWin::ExecuteSystemMenuCommand(int command) { SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0); } +namespace { +static BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) { + SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0); + return TRUE; +} +} // namespace + +void WindowWin::FrameTypeChanged() { + // The window may try to paint in SetUseNativeFrame, and as a result it can + // get into a state where it is very unhappy with itself - rendering black + // behind the entire client area. This is because for some reason the + // SkPorterDuff::kClear_mode erase done in the RootView thinks the window is + // still opaque. So, to work around this we hide the window as soon as we can + // (now), saving off its placement so it can be properly restored once + // everything has settled down. + WINDOWPLACEMENT saved_window_placement; + saved_window_placement.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement(GetNativeView(), &saved_window_placement); + 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. + ++force_hidden_count_; + ::ShowWindow(GetNativeView(), SW_RESTORE); + --force_hidden_count_; + + // We respond to this in response to WM_DWMCOMPOSITIONCHANGED since that is + // the only thing we care about - we don't actually respond to WM_THEMECHANGED + // messages. + non_client_view_->UpdateFrame(); + + // Now that we've updated the frame, we'll want to restore our saved placement + // since the display should have settled down and we can be properly rendered. + SetWindowPlacement(GetNativeView(), &saved_window_placement); + + // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want + // to notify our children too, since we can have MDI child windows who need to + // update their appearance. + EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); +} + // static int Window::GetLocalizedContentsWidth(int col_resource_id) { double chars = _wtof(l10n_util::GetString(col_resource_id).c_str()); @@ -408,7 +451,7 @@ void WindowWin::SetIsAlwaysOnTop(bool always_on_top) { } NonClientFrameView* WindowWin::CreateFrameViewForWindow() { - if (non_client_view_->UseNativeFrame()) + if (ShouldUseNativeFrame()) return new NativeFrameView(this); return new CustomFrameView(this); } @@ -434,6 +477,13 @@ gfx::NativeWindow WindowWin::GetNativeWindow() const { return GetNativeView(); } +bool WindowWin::ShouldUseNativeFrame() const { + ThemeProvider* tp = GetThemeProvider(); + if (!tp) + return win_util::ShouldUseVistaFrame(); + return tp->ShouldUseNativeFrame(); +} + /////////////////////////////////////////////////////////////////////////////// // WindowWin, protected: @@ -564,47 +614,9 @@ void WindowWin::OnDestroy() { WidgetWin::OnDestroy(); } -namespace { -static BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) { - SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0); - return TRUE; -} -} // namespace - LRESULT WindowWin::OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param) { - // The window may try to paint in SetUseNativeFrame, and as a result it can - // get into a state where it is very unhappy with itself - rendering black - // behind the entire client area. This is because for some reason the - // SkPorterDuff::kClear_mode erase done in the RootView thinks the window is - // still opaque. So, to work around this we hide the window as soon as we can - // (now), saving off its placement so it can be properly restored once - // everything has settled down. - WINDOWPLACEMENT saved_window_placement; - saved_window_placement.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(GetNativeView(), &saved_window_placement); - 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. - ++force_hidden_count_; - ::ShowWindow(GetNativeView(), SW_RESTORE); - --force_hidden_count_; - - // We respond to this in response to WM_DWMCOMPOSITIONCHANGED since that is - // the only thing we care about - we don't actually respond to WM_THEMECHANGED - // messages. - non_client_view_->SetUseNativeFrame(win_util::ShouldUseVistaFrame()); - - // Now that we've updated the frame, we'll want to restore our saved placement - // since the display should have settled down and we can be properly rendered. - SetWindowPlacement(GetNativeView(), &saved_window_placement); - - // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want - // to notify our children too, since we can have MDI child windows who need to - // update their appearance. - EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL); + FrameTypeChanged(); return 0; } |