diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 22:13:32 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 22:13:32 +0000 |
commit | b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8 (patch) | |
tree | 2f9074d5ad8acf95156fc9c390646eca935d232e /views | |
parent | 004f2cf5d5eb19764260b1f513738be15ae77d47 (diff) | |
download | chromium_src-b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8.zip chromium_src-b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8.tar.gz chromium_src-b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8.tar.bz2 |
Move some functions out of win_util and into hwnd_util, and into a new win/shell file.
This also moves two functions that were only called once from win_util and inwo window_win and download_util, respectively.
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/6035011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/widget/default_theme_provider.cc | 4 | ||||
-rw-r--r-- | views/window/window_win.cc | 59 |
2 files changed, 56 insertions, 7 deletions
diff --git a/views/widget/default_theme_provider.cc b/views/widget/default_theme_provider.cc index e6087e2..c9cf99c 100644 --- a/views/widget/default_theme_provider.cc +++ b/views/widget/default_theme_provider.cc @@ -7,7 +7,7 @@ #include "app/resource_bundle.h" #if defined(OS_WIN) -#include "app/win_util.h" +#include "app/win/hwnd_util.h" #endif namespace views { @@ -18,7 +18,7 @@ SkBitmap* DefaultThemeProvider::GetBitmapNamed(int id) const { bool DefaultThemeProvider::ShouldUseNativeFrame() const { #if defined(OS_WIN) - return win_util::ShouldUseVistaFrame(); + return app::win::ShouldUseVistaFrame(); #else return false; #endif diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 1f525e9..664e17f 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -47,6 +47,55 @@ bool GetMonitorAndRects(const RECT& rect, return true; } +// Ensures that the child window stays within the boundaries of the parent +// before setting its bounds. If |parent_window| is NULL, the bounds of the +// parent are assumed to be the bounds of the monitor that |child_window| is +// nearest to. If |child_window| isn't visible yet and |insert_after_window| +// is non-NULL and visible, the monitor |insert_after_window| is on is used +// as the parent bounds instead. +void SetChildBounds(HWND child_window, HWND parent_window, + HWND insert_after_window, const gfx::Rect& bounds, + int padding, unsigned long flags) { + DCHECK(IsWindow(child_window)); + + // First figure out the bounds of the parent. + RECT parent_rect = {0}; + if (parent_window) { + GetClientRect(parent_window, &parent_rect); + } else { + // If there is no parent, we consider the bounds of the monitor the window + // is on to be the parent bounds. + + // If the child_window isn't visible yet and we've been given a valid, + // visible insert after window, use that window to locate the correct + // monitor instead. + HWND window = child_window; + if (!IsWindowVisible(window) && IsWindow(insert_after_window) && + IsWindowVisible(insert_after_window)) + window = insert_after_window; + + POINT window_point = { bounds.x(), bounds.y() }; + HMONITOR monitor = MonitorFromPoint(window_point, + MONITOR_DEFAULTTONEAREST); + if (monitor) { + MONITORINFO mi = {0}; + mi.cbSize = sizeof(mi); + GetMonitorInfo(monitor, &mi); + parent_rect = mi.rcWork; + } else { + NOTREACHED() << "Unable to get default monitor"; + } + } + + gfx::Rect actual_bounds = bounds; + win_util::EnsureRectIsVisibleInRect(gfx::Rect(parent_rect), &actual_bounds, + padding); + + SetWindowPos(child_window, insert_after_window, actual_bounds.x(), + actual_bounds.y(), actual_bounds.width(), + actual_bounds.height(), flags); +} + } // namespace namespace views { @@ -133,8 +182,8 @@ gfx::Rect WindowWin::GetNormalBounds() const { void WindowWin::SetBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window) { - win_util::SetChildBounds(GetNativeView(), GetParent(), other_window, bounds, - kMonitorEdgePadding, 0); + SetChildBounds(GetNativeView(), GetParent(), other_window, bounds, + kMonitorEdgePadding, 0); } void WindowWin::Show(int show_state) { @@ -491,7 +540,7 @@ gfx::NativeWindow WindowWin::GetNativeWindow() const { bool WindowWin::ShouldUseNativeFrame() const { ThemeProvider* tp = GetThemeProvider(); if (!tp) - return win_util::ShouldUseVistaFrame(); + return app::win::ShouldUseVistaFrame(); return tp->ShouldUseNativeFrame(); } @@ -565,8 +614,8 @@ void WindowWin::Init(HWND parent, const gfx::Rect& bounds) { } void WindowWin::SizeWindowToDefault() { - win_util::CenterAndSizeWindow(owning_window(), GetNativeView(), - non_client_view_->GetPreferredSize().ToSIZE(), + app::win::CenterAndSizeWindow(owning_window(), GetNativeView(), + non_client_view_->GetPreferredSize(), false); } |