Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: chrome/browser/views/frame/browser_frame.cc

Issue 42027: Make Chromium windows not hide auto-hide taskbars, take 2.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 frame_initialized_ = true; 112 frame_initialized_ = true;
113 } 113 }
114 browser_view_->ActivationChanged(!!active); 114 browser_view_->ActivationChanged(!!active);
115 return Window::OnNCActivate(active); 115 return Window::OnNCActivate(active);
116 } 116 }
117 117
118 LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) { 118 LRESULT BrowserFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
119 // We don't adjust the client area unless we're a tabbed browser window and 119 // We don't adjust the client area unless we're a tabbed browser window and
120 // are using the native frame. 120 // are using the native frame.
121 if (!non_client_view_->UseNativeFrame() || 121 if (!non_client_view_->UseNativeFrame() ||
122 !browser_view_->IsBrowserTypeNormal() || !mode) { 122 !browser_view_->IsBrowserTypeNormal()) {
123 return Window::OnNCCalcSize(mode, l_param); 123 return Window::OnNCCalcSize(mode, l_param);
124 } 124 }
125 125
126 // In fullscreen mode, we make the whole window client area. 126 RECT* client_rect = mode ?
127 if (!browser_view_->IsFullscreen()) { 127 &reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param)->rgrc[0] :
128 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param); 128 reinterpret_cast<RECT*>(l_param);
129 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); 129 int border_thickness = 0;
130 params->rgrc[0].left += (border_thickness - kClientEdgeThickness); 130 if (browser_view_->IsMaximized()) {
131 params->rgrc[0].right -= (border_thickness - kClientEdgeThickness); 131 // Make the maximized mode client rect fit the screen exactly, by
132 params->rgrc[0].bottom -= (border_thickness - kClientEdgeThickness); 132 // subtracting the border Windows automatically adds for maximized mode.
133 border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
134 // Find all auto-hide taskbars along the screen edges and adjust in by the
135 // thickness of the auto-hide taskbar on each such edge, so the window isn't
136 // treated as a "fullscreen app", which would cause the taskbars to
137 // disappear.
138 HMONITOR monitor = MonitorFromWindow(GetHWND(), MONITOR_DEFAULTTONEAREST);
139 if (win_util::EdgeHasAutoHideTaskbar(ABE_LEFT, monitor))
140 client_rect->left += win_util::kAutoHideTaskbarThicknessPx;
141 if (win_util::EdgeHasAutoHideTaskbar(ABE_RIGHT, monitor))
142 client_rect->right -= win_util::kAutoHideTaskbarThicknessPx;
143 if (win_util::EdgeHasAutoHideTaskbar(ABE_BOTTOM, monitor)) {
144 client_rect->bottom -= win_util::kAutoHideTaskbarThicknessPx;
145 } else if (win_util::EdgeHasAutoHideTaskbar(ABE_TOP, monitor)) {
146 // Tricky bit. Due to a bug in DwmDefWindowProc()'s handling of
147 // WM_NCHITTEST, having any nonclient area atop the window causes the
148 // caption buttons to draw onscreen but not respond to mouse hover/clicks.
149 // So for a taskbar at the screen top, we can't push the client_rect->top
150 // down; instead, we move the bottom up by one pixel, which is the
151 // smallest change we can make and still get a client area less than the
152 // screen size. This is visibly ugly, but there seems to be no better
153 // solution.
154 --client_rect->bottom;
155 }
156 } else if (!browser_view_->IsFullscreen()) {
157 // We draw our own client edge over part of the default frame would be.
158 border_thickness = GetSystemMetrics(SM_CXSIZEFRAME) - kClientEdgeThickness;
133 } 159 }
160 client_rect->left += border_thickness;
161 client_rect->right -= border_thickness;
162 client_rect->bottom -= border_thickness;
134 163
135 UpdateDWMFrame(); 164 UpdateDWMFrame();
136 165
137 SetMsgHandled(TRUE); 166 // We'd like to return WVR_REDRAW in some cases here, but because we almost
167 // always have nonclient area (except in fullscreen mode, where it doesn't
168 // matter), we can't. See comments in window.cc:OnNCCalcSize() for more info.
138 return 0; 169 return 0;
139 } 170 }
140 171
141 LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) { 172 LRESULT BrowserFrame::OnNCHitTest(const CPoint& pt) {
142 // Only do DWM hit-testing when we are using the native frame. 173 // Only do DWM hit-testing when we are using the native frame.
143 if (non_client_view_->UseNativeFrame()) { 174 if (non_client_view_->UseNativeFrame()) {
144 LRESULT result; 175 LRESULT result;
145 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y), 176 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y),
146 &result)) { 177 &result))
147 return result; 178 return result;
148 }
149 } 179 }
150 return Window::OnNCHitTest(pt); 180 return Window::OnNCHitTest(pt);
151 } 181 }
152 182
153 /////////////////////////////////////////////////////////////////////////////// 183 ///////////////////////////////////////////////////////////////////////////////
154 // BrowserFrame, views::CustomFrameWindow overrides: 184 // BrowserFrame, views::CustomFrameWindow overrides:
155 185
156 int BrowserFrame::GetShowState() const { 186 int BrowserFrame::GetShowState() const {
157 return browser_view_->GetShowState(); 187 return browser_view_->GetShowState();
158 } 188 }
(...skipping 16 matching lines...) Expand all
175 205
176 void BrowserFrame::UpdateDWMFrame() { 206 void BrowserFrame::UpdateDWMFrame() {
177 // Nothing to do yet. 207 // Nothing to do yet.
178 if (!client_view() || !browser_view_->IsBrowserTypeNormal()) 208 if (!client_view() || !browser_view_->IsBrowserTypeNormal())
179 return; 209 return;
180 210
181 // In fullscreen mode, we don't extend glass into the client area at all, 211 // In fullscreen mode, we don't extend glass into the client area at all,
182 // because the GDI-drawn text in the web content composited over it will 212 // because the GDI-drawn text in the web content composited over it will
183 // become semi-transparent over any glass area. 213 // become semi-transparent over any glass area.
184 MARGINS margins = { 0 }; 214 MARGINS margins = { 0 };
185 if (!browser_view_->IsFullscreen()) { 215 if (browser_view_->CanCurrentlyResize()) {
186 margins.cxLeftWidth = kClientEdgeThickness + 1; 216 margins.cxLeftWidth = kClientEdgeThickness + 1;
187 margins.cxRightWidth = kClientEdgeThickness + 1; 217 margins.cxRightWidth = kClientEdgeThickness + 1;
218 margins.cyBottomHeight = kClientEdgeThickness + 1;
219 }
220 // In maximized mode, we only have a titlebar strip of glass, no side/bottom
221 // borders.
222 if (!browser_view_->IsFullscreen()) {
188 margins.cyTopHeight = 223 margins.cyTopHeight =
189 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); 224 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom();
190 margins.cyBottomHeight = kClientEdgeThickness + 1;
191 } 225 }
192 DwmExtendFrameIntoClientArea(GetHWND(), &margins); 226 DwmExtendFrameIntoClientArea(GetHWND(), &margins);
193 } 227 }
194 228
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/browser_frame.h ('k') | chrome/browser/views/frame/glass_browser_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698