summaryrefslogtreecommitdiffstats
path: root/views/widget
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 /views/widget
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 'views/widget')
-rw-r--r--views/widget/widget_win.cc14
-rw-r--r--views/widget/widget_win.h12
2 files changed, 17 insertions, 9 deletions
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index a4f2181..3d9987c 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -342,9 +342,7 @@ void WidgetWin::SetUseLayeredBuffer(bool use_layered_buffer) {
if (use_layered_buffer_) {
// Force creation of the buffer at the right size.
- RECT wr;
- GetWindowRect(&wr);
- ChangeSize(0, CSize(wr.right - wr.left, wr.bottom - wr.top));
+ LayoutRootView();
} else {
contents_.reset(NULL);
}
@@ -808,7 +806,7 @@ void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
}
void WidgetWin::OnSize(UINT param, const CSize& size) {
- ChangeSize(param, size);
+ LayoutRootView();
}
void WidgetWin::OnSysCommand(UINT notification_code, CPoint click) {
@@ -951,15 +949,17 @@ void WidgetWin::ProcessMouseExited() {
active_mouse_tracking_flags_ = 0;
}
-void WidgetWin::ChangeSize(UINT size_param, const CSize& size) {
+void WidgetWin::LayoutRootView() {
CRect rect;
- if (use_layered_buffer_) {
+ if (SizeRootViewToWindowRect() || use_layered_buffer_) {
GetWindowRect(&rect);
- SizeContents(rect);
} else {
GetClientRect(&rect);
}
+ if (use_layered_buffer_)
+ SizeContents(rect);
+
// Resizing changes the size of the view hierarchy and thus forces a
// complete relayout.
root_view_->SetBounds(0, 0, rect.Width(), rect.Height());
diff --git a/views/widget/widget_win.h b/views/widget/widget_win.h
index 40b3387..f8ba2a5 100644
--- a/views/widget/widget_win.h
+++ b/views/widget/widget_win.h
@@ -387,6 +387,13 @@ class WidgetWin : public app::WindowImpl,
// behavior.
virtual void OnFinalMessage(HWND window);
+ // Returns true if the RootView should be sized to the window rect instead of
+ // the client rect when the widget is resized. This is true if the widget's
+ // WM_NCCALCSIZE handler returns a client rect that differs from the window
+ // rect but the painted content of the window should still fill the entire
+ // visible window.
+ virtual bool SizeRootViewToWindowRect() const { return false; }
+
// Start tracking all mouse events so that this window gets sent mouse leave
// messages too.
void TrackMouseEvents(DWORD mouse_tracking_flags);
@@ -403,8 +410,9 @@ class WidgetWin : public app::WindowImpl,
void ProcessMouseMoved(const CPoint& point, UINT flags, bool is_nonclient);
void ProcessMouseExited();
- // Handles re-laying out content in response to a window size change.
- virtual void ChangeSize(UINT size_param, const CSize& size);
+ // Lays out the root view to fit the appropriate area within the widget.
+ // Called when the window size or non client metrics change.
+ void LayoutRootView();
// Returns whether capture should be released on mouse release. The default
// is true.