diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-09 20:41:27 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-09 20:41:27 +0000 |
commit | bc2f935b5525528f5b2c90c8de3a94be7d56b369 (patch) | |
tree | 0dd06a589ce5178789a8ec3f61e85c4b5553c614 /chrome | |
parent | 83eb8970409e92ca196b42d9d6fc1ae504ed6f3a (diff) | |
download | chromium_src-bc2f935b5525528f5b2c90c8de3a94be7d56b369.zip chromium_src-bc2f935b5525528f5b2c90c8de3a94be7d56b369.tar.gz chromium_src-bc2f935b5525528f5b2c90c8de3a94be7d56b369.tar.bz2 |
Back out r10845 because it caused too many other regressions.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/frame/browser_frame.cc | 58 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_frame.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/frame/glass_browser_frame_view.cc | 19 | ||||
-rw-r--r-- | chrome/browser/views/frame/glass_browser_frame_view.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_browser_frame_view.cc | 17 | ||||
-rw-r--r-- | chrome/common/win_util.cc | 12 | ||||
-rw-r--r-- | chrome/common/win_util.h | 7 | ||||
-rw-r--r-- | chrome/views/window.cc | 45 |
8 files changed, 49 insertions, 113 deletions
diff --git a/chrome/browser/views/frame/browser_frame.cc b/chrome/browser/views/frame/browser_frame.cc index 2f110d1..ad7beff 100644 --- a/chrome/browser/views/frame/browser_frame.cc +++ b/chrome/browser/views/frame/browser_frame.cc @@ -119,49 +119,22 @@ LRESULT BrowserFrame::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 (!non_client_view_->UseNativeFrame() || - !browser_view_->IsBrowserTypeNormal()) { + !browser_view_->IsBrowserTypeNormal() || !mode) { return Window::OnNCCalcSize(mode, l_param); } - RECT* client_rect = mode ? - &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : - reinterpret_cast<RECT*>(l_param); - int border_thickness = 0; - if (browser_view_->IsMaximized()) { - // Make the maximized mode client rect fit the screen exactly, by - // subtracting the border Windows automatically adds for maximized mode. - border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); - // Find all auto-hide taskbars along the screen edges and adjust in by the - // thickness of the auto-hide taskbar on each such edge, so the window isn't - // treated as a "fullscreen app", which would cause the taskbars to - // disappear. - HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); - if (win_util::EdgeHasAutoHideTaskbar(ABE_LEFT, monitor)) - client_rect->left += win_util::kAutoHideTaskbarThicknessPx; - if (win_util::EdgeHasAutoHideTaskbar(ABE_RIGHT, monitor)) - client_rect->right -= win_util::kAutoHideTaskbarThicknessPx; - if (win_util::EdgeHasAutoHideTaskbar(ABE_BOTTOM, monitor)) { - client_rect->bottom -= win_util::kAutoHideTaskbarThicknessPx; - } else if (win_util::EdgeHasAutoHideTaskbar(ABE_TOP, monitor)) { - // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of - // WM_NCHITTEST, having any nonclient area atop the window causes the - // caption buttons to draw onscreen but not respond to mouse hover/clicks. - // So for a taskbar at the screen top, we can't push the client_rect->top - // down; instead, we move the bottom up by one pixel, which is the - // smallest change we can make and still get a client area less than the - // screen size. This is visibly ugly, but there seems to be no better - // solution. - --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; + // In fullscreen mode, we make the whole window client area. + if (!browser_view_->IsFullscreen()) { + NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param); + int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); + params->rgrc[0].left += (border_thickness - kClientEdgeThickness); + params->rgrc[0].right -= (border_thickness - kClientEdgeThickness); + params->rgrc[0].bottom -= (border_thickness - kClientEdgeThickness); } - client_rect->left += border_thickness; - client_rect->right -= border_thickness; - client_rect->bottom -= border_thickness; UpdateDWMFrame(); + + SetMsgHandled(TRUE); return 0; } @@ -170,8 +143,9 @@ LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) { if (non_client_view_->UseNativeFrame()) { LRESULT result; if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y), - &result)) + &result)) { return result; + } } return Window::OnNCHitTest(pt); } @@ -208,16 +182,12 @@ void BrowserFrame::UpdateDWMFrame() { // because the GDI-drawn text in the web content composited over it will // become semi-transparent over any glass area. MARGINS margins = { 0 }; - if (browser_view_->CanCurrentlyResize()) { + if (!browser_view_->IsFullscreen()) { margins.cxLeftWidth = kClientEdgeThickness + 1; margins.cxRightWidth = kClientEdgeThickness + 1; - margins.cyBottomHeight = kClientEdgeThickness + 1; - } - // In maximized mode, we only have a titlebar strip of glass, no side/bottom - // borders. - if (!browser_view_->IsFullscreen()) { margins.cyTopHeight = GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); + margins.cyBottomHeight = kClientEdgeThickness + 1; } DwmExtendFrameIntoClientArea(GetHWND(), &margins); } diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h index 13dace7..c7efcab 100644 --- a/chrome/browser/views/frame/browser_frame.h +++ b/chrome/browser/views/frame/browser_frame.h @@ -55,9 +55,9 @@ class BrowserFrame : public views::Window { // Overridden from views::WidgetWin: virtual bool AcceleratorPressed(views::Accelerator* accelerator); virtual bool GetAccelerator(int cmd_id, views::Accelerator* accelerator); + virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); virtual void OnEnterSizeMove(); virtual void OnEndSession(BOOL ending, UINT logoff); - virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); virtual LRESULT OnMouseActivate(HWND window, UINT hittest_code, UINT message); diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index 6c19083..9fce143 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -225,8 +225,7 @@ void GlassBrowserFrameView::Paint(ChromeCanvas* canvas) { PaintDistributorLogo(canvas); PaintToolbarBackground(canvas); PaintOTRAvatar(canvas); - if (!frame_->IsMaximized()) - PaintRestoredClientEdge(canvas); + PaintClientEdge(canvas); } void GlassBrowserFrameView::Layout() { @@ -239,22 +238,16 @@ void GlassBrowserFrameView::Layout() { // GlassBrowserFrameView, private: int GlassBrowserFrameView::FrameBorderThickness() const { - return browser_view_->CanCurrentlyResize() ? - GetSystemMetrics(SM_CXSIZEFRAME) : 0; + return GetSystemMetrics(SM_CXSIZEFRAME); } int GlassBrowserFrameView::NonClientBorderThickness() const { - return browser_view_->CanCurrentlyResize() ? kNonClientBorderThickness : 0; + return kNonClientBorderThickness; } int GlassBrowserFrameView::NonClientTopBorderHeight() const { - if (browser_view_->IsFullscreen()) - return 0; - // We'd like to use FrameBorderThickness() here, but the maximized Aero glass - // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border - // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). - return GetSystemMetrics(SM_CXSIZEFRAME) + - (browser_view_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); + return FrameBorderThickness() + + (frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); } void GlassBrowserFrameView::PaintDistributorLogo(ChromeCanvas* canvas) { @@ -302,7 +295,7 @@ void GlassBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) { otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); } -void GlassBrowserFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) { +void GlassBrowserFrameView::PaintClientEdge(ChromeCanvas* canvas) { // The client edges start below the toolbar upper corner images regardless // of how tall the toolbar itself is. int client_area_top = diff --git a/chrome/browser/views/frame/glass_browser_frame_view.h b/chrome/browser/views/frame/glass_browser_frame_view.h index f6e3aff..626f23d 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.h +++ b/chrome/browser/views/frame/glass_browser_frame_view.h @@ -54,7 +54,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView { void PaintDistributorLogo(ChromeCanvas* canvas); void PaintToolbarBackground(ChromeCanvas* canvas); void PaintOTRAvatar(ChromeCanvas* canvas); - void PaintRestoredClientEdge(ChromeCanvas* canvas); + void PaintClientEdge(ChromeCanvas* canvas); // Layout various sub-components of this view. void LayoutDistributorLogo(); diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index 8452a37..5d4df77 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -505,7 +505,7 @@ void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) { DCHECK(window_mask); - if (!browser_view_->CanCurrentlyResize()) + if (browser_view_->IsFullscreen()) return; // Redefine the window visible region for the new size. @@ -649,7 +649,10 @@ SkBitmap OpaqueBrowserFrameView::GetFavIconForTabIconView() { // OpaqueBrowserFrameView, private: int OpaqueBrowserFrameView::FrameBorderThickness() const { - return browser_view_->CanCurrentlyResize() ? kFrameBorderThickness : 0; + if (browser_view_->IsFullscreen()) + return 0; + return frame_->IsMaximized() ? + GetSystemMetrics(SM_CXSIZEFRAME) : kFrameBorderThickness; } int OpaqueBrowserFrameView::TopResizeHeight() const { @@ -917,11 +920,13 @@ void OpaqueBrowserFrameView::LayoutWindowControls() { // button to the screen corner to obey Fitts' Law. int right_extra_width = is_maximized ? (kFrameBorderThickness - kFrameShadowThickness) : 0; + int right_spacing = is_maximized ? + (GetSystemMetrics(SM_CXSIZEFRAME) + right_extra_width) : frame_thickness; gfx::Size close_button_size = close_button_->GetPreferredSize(); - close_button_->SetBounds(width() - close_button_size.width() - - right_extra_width - frame_thickness, caption_y, - close_button_size.width() + right_extra_width, - close_button_size.height() + top_extra_height); + close_button_->SetBounds(width() - close_button_size.width() - right_spacing, + caption_y, + close_button_size.width() + right_extra_width, + close_button_size.height() + top_extra_height); // When the window is restored, we show a maximized button; otherwise, we show // a restore button. diff --git a/chrome/common/win_util.cc b/chrome/common/win_util.cc index 50850d1..7437031 100644 --- a/chrome/common/win_util.cc +++ b/chrome/common/win_util.cc @@ -28,8 +28,6 @@ namespace win_util { -const int kAutoHideTaskbarThicknessPx = 2; - namespace { // Enforce visible dialog box. @@ -626,16 +624,6 @@ void CenterAndSizeWindow(HWND parent, HWND window, const SIZE& pref, } } -bool EdgeHasAutoHideTaskbar(UINT edge, HMONITOR monitor) { - APPBARDATA taskbar_data = { 0 }; - taskbar_data.cbSize = sizeof APPBARDATA; - taskbar_data.uEdge = edge; - HWND taskbar = reinterpret_cast<HWND>(SHAppBarMessage(ABM_GETAUTOHIDEBAR, - &taskbar_data)); - return ::IsWindow(taskbar) && - (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor); -} - HANDLE GetSectionFromProcess(HANDLE section, HANDLE process, bool read_only) { HANDLE valid_section = NULL; DWORD access = STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ; diff --git a/chrome/common/win_util.h b/chrome/common/win_util.h index 8e703cb..c93b098 100644 --- a/chrome/common/win_util.h +++ b/chrome/common/win_util.h @@ -211,10 +211,6 @@ void AdjustWindowToFit(HWND hwnd); void CenterAndSizeWindow(HWND parent, HWND window, const SIZE& pref, bool pref_is_client); -// Returns true if edge |edge| (one of ABE_LEFT, TOP, RIGHT, or BOTTOM) of -// monitor |monitor| has an auto-hiding taskbar. -bool EdgeHasAutoHideTaskbar(UINT edge, HMONITOR monitor); - // Duplicates a section handle from another process to the current process. // Returns the new valid handle if the function succeed. NULL otherwise. HANDLE GetSectionFromProcess(HANDLE section, HANDLE process, bool read_only); @@ -278,9 +274,6 @@ int MessageBox(HWND hwnd, // Returns the system set window title font. ChromeFont GetWindowTitleFont(); -// The thickness of an auto-hide taskbar in pixels. -extern const int kAutoHideTaskbarThicknessPx; - } // namespace win_util #endif // CHROME_COMMON_WIN_UTIL_H_ diff --git a/chrome/views/window.cc b/chrome/views/window.cc index ca3f6ec..67f1b5a 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -568,32 +568,8 @@ LRESULT Window::OnNCCalcSize(BOOL mode, LPARAM l_param) { if (non_client_view_->UseNativeFrame()) return WidgetWin::OnNCCalcSize(mode, l_param); - RECT* client_rect = mode ? - &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : - reinterpret_cast<RECT*>(l_param); - if (IsMaximized()) { - // Make the maximized mode client rect fit the screen exactly, by - // subtracting the border Windows automatically adds for maximized mode. - int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); - InflateRect(client_rect, -border_thickness, -border_thickness); - - // Find all auto-hide taskbars along the screen edges and adjust in by the - // thickness of the auto-hide taskbar on each such edge, so the window isn't - // treated as a "fullscreen app", which would cause the taskbars to - // disappear. - HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); - if (win_util::EdgeHasAutoHideTaskbar(ABE_LEFT, monitor)) - client_rect->left += win_util::kAutoHideTaskbarThicknessPx; - if (win_util::EdgeHasAutoHideTaskbar(ABE_TOP, monitor)) - client_rect->top += win_util::kAutoHideTaskbarThicknessPx; - if (win_util::EdgeHasAutoHideTaskbar(ABE_RIGHT, monitor)) - client_rect->right -= win_util::kAutoHideTaskbarThicknessPx; - if (win_util::EdgeHasAutoHideTaskbar(ABE_BOTTOM, monitor)) - client_rect->bottom -= win_util::kAutoHideTaskbarThicknessPx; - } - // We need to repaint all when the window bounds change. - return mode ? WVR_REDRAW : 0; + return WVR_REDRAW; } LRESULT Window::OnNCHitTest(const CPoint& point) { @@ -1122,10 +1098,21 @@ void Window::ResetWindowRegion(bool force) { CRect window_rect; GetWindowRect(&window_rect); HRGN new_region; - gfx::Path window_mask; - non_client_view_->GetWindowMask( - gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask); - new_region = window_mask.CreateHRGN(); + if (IsMaximized()) { + HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); + MONITORINFO mi; + mi.cbSize = sizeof mi; + GetMonitorInfo(monitor, &mi); + CRect work_rect = mi.rcWork; + work_rect.OffsetRect(-window_rect.left, -window_rect.top); + new_region = CreateRectRgnIndirect(&work_rect); + } else { + gfx::Path window_mask; + non_client_view_->GetWindowMask(gfx::Size(window_rect.Width(), + window_rect.Height()), + &window_mask); + new_region = window_mask.CreateHRGN(); + } if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) { // SetWindowRgn takes ownership of the HRGN created by CreateHRGN. |