| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/views/frame/browser_frame.h" | 5 #include "chrome/browser/views/frame/browser_frame.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/views/frame/browser_view.h" | 10 #include "chrome/browser/views/frame/browser_view.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 frame_initialized_ = true; | 109 frame_initialized_ = true; |
| 110 } | 110 } |
| 111 browser_view_->ActivationChanged(!!active); | 111 browser_view_->ActivationChanged(!!active); |
| 112 return Window::OnNCActivate(active); | 112 return Window::OnNCActivate(active); |
| 113 } | 113 } |
| 114 | 114 |
| 115 LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) { | 115 LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) { |
| 116 // We don't adjust the client area unless we're a tabbed browser window and | 116 // We don't adjust the client area unless we're a tabbed browser window and |
| 117 // are using the native frame. | 117 // are using the native frame. |
| 118 if (!non_client_view_->UseNativeFrame() || | 118 if (!non_client_view_->UseNativeFrame() || |
| 119 !browser_view_->IsBrowserTypeNormal() || !mode) { | 119 !browser_view_->IsBrowserTypeNormal()) { |
| 120 return Window::OnNCCalcSize(mode, l_param); | 120 return Window::OnNCCalcSize(mode, l_param); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // In fullscreen mode, we make the whole window client area. | 123 RECT* client_rect = mode ? |
| 124 if (!browser_view_->IsFullscreen()) { | 124 &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] : |
| 125 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param); | 125 reinterpret_cast<RECT*>(l_param); |
| 126 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 126 int border_thickness = 0; |
| 127 params->rgrc[0].left += (border_thickness - kClientEdgeThickness); | 127 if (browser_view_->IsMaximized()) { |
| 128 params->rgrc[0].right -= (border_thickness - kClientEdgeThickness); | 128 // Make the maximized mode client rect fit the screen exactly, by |
| 129 params->rgrc[0].bottom -= (border_thickness - kClientEdgeThickness); | 129 // subtracting the border Windows automatically adds for maximized mode. |
| 130 border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
| 131 // Find all auto-hide taskbars along the screen edges and adjust in by the |
| 132 // thickness of the auto-hide taskbar on each such edge, so the window isn't |
| 133 // treated as a "fullscreen app", which would cause the taskbars to |
| 134 // disappear. |
| 135 HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST); |
| 136 if (win_util::EdgeHasAutoHideTaskbar(ABE_LEFT, monitor)) |
| 137 client_rect->left += win_util::kAutoHideTaskbarThicknessPx; |
| 138 if (win_util::EdgeHasAutoHideTaskbar(ABE_RIGHT, monitor)) |
| 139 client_rect->right -= win_util::kAutoHideTaskbarThicknessPx; |
| 140 if (win_util::EdgeHasAutoHideTaskbar(ABE_BOTTOM, monitor)) { |
| 141 client_rect->bottom -= win_util::kAutoHideTaskbarThicknessPx; |
| 142 } else if (win_util::EdgeHasAutoHideTaskbar(ABE_TOP, monitor)) { |
| 143 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of |
| 144 // WM_NCHITTEST, having any nonclient area atop the window causes the |
| 145 // caption buttons to draw onscreen but not respond to mouse hover/clicks. |
| 146 // So for a taskbar at the screen top, we can't push the client_rect->top |
| 147 // down; instead, we move the bottom up by one pixel, which is the |
| 148 // smallest change we can make and still get a client area less than the |
| 149 // screen size. This is visibly ugly, but there seems to be no better |
| 150 // solution. |
| 151 --client_rect->bottom; |
| 152 } |
| 153 } else if (!browser_view_->IsFullscreen()) { |
| 154 // We draw our own client edge over part of the default frame would be. |
| 155 border_thickness = GetSystemMetrics(SM_CXSIZEFRAME) - kClientEdgeThickness; |
| 130 } | 156 } |
| 157 client_rect->left += border_thickness; |
| 158 client_rect->right -= border_thickness; |
| 159 client_rect->bottom -= border_thickness; |
| 131 | 160 |
| 132 UpdateDWMFrame(); | 161 UpdateDWMFrame(); |
| 133 | |
| 134 SetMsgHandled(TRUE); | |
| 135 return 0; | 162 return 0; |
| 136 } | 163 } |
| 137 | 164 |
| 138 LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) { | 165 LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) { |
| 139 // Only do DWM hit-testing when we are using the native frame. | 166 // Only do DWM hit-testing when we are using the native frame. |
| 140 if (non_client_view_->UseNativeFrame()) { | 167 if (non_client_view_->UseNativeFrame()) { |
| 141 LRESULT result; | 168 LRESULT result; |
| 142 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y), | 169 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y), |
| 143 &result)) { | 170 &result)) |
| 144 return result; | 171 return result; |
| 145 } | |
| 146 } | 172 } |
| 147 return Window::OnNCHitTest(pt); | 173 return Window::OnNCHitTest(pt); |
| 148 } | 174 } |
| 149 | 175 |
| 150 /////////////////////////////////////////////////////////////////////////////// | 176 /////////////////////////////////////////////////////////////////////////////// |
| 151 // BrowserFrame, views::CustomFrameWindow overrides: | 177 // BrowserFrame, views::CustomFrameWindow overrides: |
| 152 | 178 |
| 153 int BrowserFrame::GetShowState() const { | 179 int BrowserFrame::GetShowState() const { |
| 154 return browser_view_->GetShowState(); | 180 return browser_view_->GetShowState(); |
| 155 } | 181 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 172 | 198 |
| 173 void BrowserFrame::UpdateDWMFrame() { | 199 void BrowserFrame::UpdateDWMFrame() { |
| 174 // Nothing to do yet. | 200 // Nothing to do yet. |
| 175 if (!client_view() || !browser_view_->IsBrowserTypeNormal()) | 201 if (!client_view() || !browser_view_->IsBrowserTypeNormal()) |
| 176 return; | 202 return; |
| 177 | 203 |
| 178 // In fullscreen mode, we don't extend glass into the client area at all, | 204 // In fullscreen mode, we don't extend glass into the client area at all, |
| 179 // because the GDI-drawn text in the web content composited over it will | 205 // because the GDI-drawn text in the web content composited over it will |
| 180 // become semi-transparent over any glass area. | 206 // become semi-transparent over any glass area. |
| 181 MARGINS margins = { 0 }; | 207 MARGINS margins = { 0 }; |
| 182 if (!browser_view_->IsFullscreen()) { | 208 if (browser_view_->CanCurrentlyResize()) { |
| 183 margins.cxLeftWidth = kClientEdgeThickness + 1; | 209 margins.cxLeftWidth = kClientEdgeThickness + 1; |
| 184 margins.cxRightWidth = kClientEdgeThickness + 1; | 210 margins.cxRightWidth = kClientEdgeThickness + 1; |
| 211 margins.cyBottomHeight = kClientEdgeThickness + 1; |
| 212 } |
| 213 // In maximized mode, we only have a titlebar strip of glass, no side/bottom |
| 214 // borders. |
| 215 if (!browser_view_->IsFullscreen()) { |
| 185 margins.cyTopHeight = | 216 margins.cyTopHeight = |
| 186 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); | 217 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); |
| 187 margins.cyBottomHeight = kClientEdgeThickness + 1; | |
| 188 } | 218 } |
| 189 DwmExtendFrameIntoClientArea(GetHWND(), &margins); | 219 DwmExtendFrameIntoClientArea(GetHWND(), &margins); |
| 190 } | 220 } |
| 191 | 221 |
| OLD | NEW |