summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 19:21:57 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 19:21:57 +0000
commit9f36b348f2408118d42d219c8a4fa04877ed3b83 (patch)
treebc33b026905d139ad739b0c4345fc5cb97a2ed1c /chrome/browser
parent6ef0feb87c69e28e81dd7ca0e45dc402f181619a (diff)
downloadchromium_src-9f36b348f2408118d42d219c8a4fa04877ed3b83.zip
chromium_src-9f36b348f2408118d42d219c8a4fa04877ed3b83.tar.gz
chromium_src-9f36b348f2408118d42d219c8a4fa04877ed3b83.tar.bz2
Fix a whole category of frame switching bugs relating to the window z-order being screwed up screwed up when DWM is toggled or themes are installed or reset.
The first part of the fix was to remove the hack I put in to hide then show the window while the frame type change occurs. The hack was to work around the fact that upon returning to glass from non-glass, the area identified by BrowserFrameWin::OnNCCalcSize as client was filled with solid black vs. transparent black. I don't know why this fix works, but returning a client size for the opaque frame as 1 pixel different to the window rect causes the blackness bug to not occur, so that's what I did (in addition to removing the hack). I also had to put in a couple of fixes to accommodate the pixel turd we gain in the opaque frame. I renamed ChangeSize to LayoutRootView. When we're using the opaque frame, since the views system is rendering the entire content of the window all the time I always size the widget to the window rect rather than the client rect. http://crbug.com/15424 TEST=change the frame type by: - turning on/off aero glass - installing a theme, then resetting - running an app that forces the DWM off, e.g. the O3D plugin The frame should appear correct after the transition in either direction, and window z-order should be preserved. Review URL: http://codereview.chromium.org/266013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/views/frame/browser_frame_win.cc43
-rw-r--r--chrome/browser/views/frame/browser_frame_win.h1
2 files changed, 34 insertions, 10 deletions
diff --git a/chrome/browser/views/frame/browser_frame_win.cc b/chrome/browser/views/frame/browser_frame_win.cc
index 4315346..2616dfb 100644
--- a/chrome/browser/views/frame/browser_frame_win.cc
+++ b/chrome/browser/views/frame/browser_frame_win.cc
@@ -182,12 +182,17 @@ LRESULT BrowserFrameWin::OnNCActivate(BOOL active) {
}
LRESULT BrowserFrameWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
- // We don't adjust the client area unless we're a tabbed browser window and
- // are using the native frame.
- if (!GetNonClientView()->UseNativeFrame() ||
- !browser_view_->IsBrowserTypeNormal()) {
+ // This class' client rect calculations are specific to the tabbed browser
+ // window. When the glass frame is active, the client area is reported to be
+ // a rectangle that touches the top of the window and is inset from the left,
+ // right and bottom edges. The client rect touches the top because the
+ // tabstrip is painted over the caption at a custom offset.
+ // When the glass frame is not active, the client area is reported to be the
+ // entire window rect, except for the cases noted below.
+ // For non-tabbed browser windows, we use the default handling from the
+ // views system.
+ if (!browser_view_->IsBrowserTypeNormal())
return WindowWin::OnNCCalcSize(mode, l_param);
- }
RECT* client_rect = mode ?
&reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] :
@@ -221,8 +226,22 @@ LRESULT BrowserFrameWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
--client_rect->bottom;
}
} else if (!browser_view_->IsFullscreen()) {
- // We draw our own client edge over part of the default frame would be.
- border_thickness = GetSystemMetrics(SM_CXSIZEFRAME) - kClientEdgeThickness;
+ if (GetNonClientView()->UseNativeFrame()) {
+ // We draw our own client edge over part of the default frame.
+ border_thickness =
+ GetSystemMetrics(SM_CXSIZEFRAME) - kClientEdgeThickness;
+ } else {
+ // This is weird, but highly essential. If we don't offset the bottom edge
+ // of the client rect, the window client area and window area will match,
+ // and when returning to glass rendering mode from non-glass, the client
+ // area will not paint black as transparent. This is because (and I don't
+ // know why) the client area goes from matching the window rect to being
+ // something else. If the client area is not the window rect in both
+ // modes, the blackness doesn't occur. Because of this, we need to tell
+ // the RootView to lay out to fit the window rect, rather than the client
+ // rect when using the opaque frame. See SizeRootViewToWindowRect.
+ --client_rect->bottom;
+ }
}
client_rect->left += border_thickness;
client_rect->right -= border_thickness;
@@ -301,6 +320,10 @@ ThemeProvider* BrowserFrameWin::GetDefaultThemeProvider() const {
return profile_->GetThemeProvider();
}
+bool BrowserFrameWin::SizeRootViewToWindowRect() const {
+ return !GetNonClientView()->UseNativeFrame();
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserFrame, views::CustomFrameWindow overrides:
@@ -317,8 +340,10 @@ views::NonClientFrameView* BrowserFrameWin::CreateFrameViewForWindow() {
}
void BrowserFrameWin::UpdateFrameAfterFrameChange() {
- WindowWin::UpdateFrameAfterFrameChange();
+ // We need to update the glass region on or off before the base class adjusts
+ // the window region.
UpdateDWMFrame();
+ WindowWin::UpdateFrameAfterFrameChange();
}
views::RootView* BrowserFrameWin::CreateRootView() {
@@ -352,8 +377,6 @@ void BrowserFrameWin::UpdateDWMFrame() {
}
} else {
// For popup and app windows we want to use the default margins.
- margins.cxLeftWidth = margins.cxRightWidth = margins.cyTopHeight =
- margins.cyBottomHeight = 0;
}
DwmExtendFrameIntoClientArea(GetNativeView(), &margins);
}
diff --git a/chrome/browser/views/frame/browser_frame_win.h b/chrome/browser/views/frame/browser_frame_win.h
index dc23eb7..df59f36 100644
--- a/chrome/browser/views/frame/browser_frame_win.h
+++ b/chrome/browser/views/frame/browser_frame_win.h
@@ -64,6 +64,7 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin {
virtual void OnWindowPosChanged(WINDOWPOS* window_pos);
virtual ThemeProvider* GetThemeProvider() const;
virtual ThemeProvider* GetDefaultThemeProvider() const;
+ virtual bool SizeRootViewToWindowRect() const;
// Overridden from views::Window:
virtual int GetShowState() const;