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

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

Issue 19548: Fix some of the most egregious problems with Aero glass frames. These change... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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/aero_glass_frame.h" 5 #include "chrome/browser/views/frame/aero_glass_frame.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 8
9 #include "chrome/app/theme/theme_resources.h" 9 #include "chrome/app/theme/theme_resources.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
11 #include "chrome/browser/views/frame/browser_view.h" 11 #include "chrome/browser/views/frame/browser_view.h"
12 #include "chrome/browser/views/frame/aero_glass_non_client_view.h" 12 #include "chrome/browser/views/frame/aero_glass_non_client_view.h"
13 #include "chrome/common/resource_bundle.h" 13 #include "chrome/common/resource_bundle.h"
14 #include "chrome/views/window_delegate.h" 14 #include "chrome/views/window_delegate.h"
15 15
16 // static 16 // static
17 17
18 // The width of the sizing borders. 18 // The width of the sizing borders.
19 static const int kResizeBorder = 8; 19 static const int kResizeBorder = 8;
20 // The width of the client edge to the left and right of the window.
21 static const int kWindowHorizontalClientEdgeWidth = 3;
22 // The height of the client edge to the bottom of the window.
23 static const int kWindowBottomClientEdgeHeight = 2;
20 // By how much the toolbar overlaps with the tab strip. 24 // By how much the toolbar overlaps with the tab strip.
21 static const int kToolbarOverlapVertOffset = 5; 25 static const int kToolbarOverlapVertOffset = 5;
22 // This is the width of the default client edge provided by Windows. In some
23 // circumstances we provide our own client edge, so we use this width to
24 // remove it.
25 static const int kWindowsDWMBevelSize = 2;
26 26
27 HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount]; 27 HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount];
28 28
29 /////////////////////////////////////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////////////
30 // AeroGlassFrame, public: 30 // AeroGlassFrame, public:
31 31
32 AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view) 32 AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view)
33 : Window(browser_view), 33 : Window(browser_view),
34 browser_view_(browser_view), 34 browser_view_(browser_view),
35 frame_initialized_(false), 35 frame_initialized_(false),
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (browser_view_->ActivateAppModalDialog()) 129 if (browser_view_->ActivateAppModalDialog())
130 return TRUE; 130 return TRUE;
131 131
132 if (!frame_initialized_) { 132 if (!frame_initialized_) {
133 ::SetWindowPos(GetHWND(), NULL, 0, 0, 0, 0, 133 ::SetWindowPos(GetHWND(), NULL, 0, 0, 0, 0,
134 SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED); 134 SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
135 UpdateDWMFrame(); 135 UpdateDWMFrame();
136 frame_initialized_ = true; 136 frame_initialized_ = true;
137 } 137 }
138 browser_view_->ActivationChanged(!!active); 138 browser_view_->ActivationChanged(!!active);
139 SetMsgHandled(false);
139 return TRUE; 140 return TRUE;
140 } 141 }
141 142
142 LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) { 143 LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
143 // By default the client side is set to the window size which is what 144 // By default the client side is set to the window size which is what
144 // we want. 145 // we want.
145 if (browser_view_->IsToolbarVisible() && mode == TRUE) { 146 if (browser_view_->IsToolbarVisible() && mode == TRUE) {
146 // To be on the safe side and avoid side-effects, we only adjust the client 147 // To be on the safe side and avoid side-effects, we only adjust the client
147 // size to non-standard values when we must - i.e. when we're showing a 148 // size to non-standard values when we must - i.e. when we're showing a
148 // TabStrip. 149 // TabStrip.
149 if (browser_view_->IsTabStripVisible()) { 150 if (browser_view_->IsTabStripVisible()) {
150 // Calculate new NCCALCSIZE_PARAMS based on custom NCA inset. 151 // Calculate new NCCALCSIZE_PARAMS based on custom NCA inset.
151 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param); 152 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param);
152 153
153 // Hack necessary to stop black background flicker, we cut out 154 // Hack necessary to stop black background flicker, we cut out
154 // resizeborder here to save us from having to do too much 155 // resizeborder here to save us from having to do too much
155 // addition and subtraction in Layout(). We don't cut off the 156 // addition and subtraction in Layout(). We don't cut off the
156 // top + titlebar as that prevents the window controls from 157 // top + titlebar as that prevents the window controls from
157 // highlighting. 158 // highlighting.
158 params->rgrc[0].left += kResizeBorder; 159 params->rgrc[0].left +=
159 params->rgrc[0].right -= kResizeBorder; 160 (kResizeBorder - kWindowHorizontalClientEdgeWidth);
160 params->rgrc[0].bottom -= kResizeBorder; 161 params->rgrc[0].right -=
162 (kResizeBorder - kWindowHorizontalClientEdgeWidth);
163 params->rgrc[0].bottom -=
164 (kResizeBorder - kWindowBottomClientEdgeHeight);
161 165
162 SetMsgHandled(TRUE); 166 SetMsgHandled(TRUE);
163 } else { 167 } else {
164 // We don't adjust the client size for detached popups, so we need to 168 // We don't adjust the client size for detached popups, so we need to
165 // tell Windows we didn't handle the message here so that it doesn't 169 // tell Windows we didn't handle the message here so that it doesn't
166 // screw up the non-client area. 170 // screw up the non-client area.
167 SetMsgHandled(FALSE); 171 SetMsgHandled(FALSE);
168 } 172 }
169 173
170 // We need to reset the frame, as Vista resets it whenever it changes 174 // We need to reset the frame, as Vista resets it whenever it changes
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return; 207 return;
204 208
205 // We only adjust the DWM's glass rendering when we're a browser window or a 209 // We only adjust the DWM's glass rendering when we're a browser window or a
206 // detached popup. App windows get the standard client edge. 210 // detached popup. App windows get the standard client edge.
207 if (browser_view_->IsTabStripVisible() || 211 if (browser_view_->IsTabStripVisible() ||
208 browser_view_->IsToolbarVisible()) { 212 browser_view_->IsToolbarVisible()) {
209 // By default, we just want to adjust the glass by the width of the inner 213 // By default, we just want to adjust the glass by the width of the inner
210 // bevel that aero renders to demarcate the client area. We supply our own 214 // bevel that aero renders to demarcate the client area. We supply our own
211 // client edge for the browser window and detached popups, so we don't want 215 // client edge for the browser window and detached popups, so we don't want
212 // to show the default one. 216 // to show the default one.
213 int client_edge_left_width = kWindowsDWMBevelSize; 217 int client_edge_left_width = kWindowHorizontalClientEdgeWidth + 1;
214 int client_edge_right_width = kWindowsDWMBevelSize; 218 int client_edge_right_width = kWindowHorizontalClientEdgeWidth + 1;
215 int client_edge_bottom_height = kWindowsDWMBevelSize; 219 int client_edge_bottom_height = kWindowBottomClientEdgeHeight + 1;
216 int client_edge_top_height = kWindowsDWMBevelSize; 220 int client_edge_top_height = kWindowBottomClientEdgeHeight;
217 if (browser_view_->IsTabStripVisible()) { 221 if (browser_view_->IsTabStripVisible()) {
218 gfx::Rect tabstrip_bounds = 222 gfx::Rect tabstrip_bounds =
219 GetBoundsForTabStrip(browser_view_->tabstrip()); 223 GetBoundsForTabStrip(browser_view_->tabstrip());
220 client_edge_top_height = 224 client_edge_top_height = tabstrip_bounds.bottom();
221 client_view()->y() + tabstrip_bounds.bottom();
222 } 225 }
223 226
224 // Now poke the DWM. 227 // Now poke the DWM.
225 MARGINS margins = { client_edge_left_width, client_edge_right_width, 228 MARGINS margins = { client_edge_left_width, client_edge_right_width,
226 client_edge_top_height, client_edge_bottom_height }; 229 client_edge_top_height, client_edge_bottom_height };
227 // Note: we don't use DwmEnableBlurBehindWindow because any region not 230 // Note: we don't use DwmEnableBlurBehindWindow because any region not
228 // included in the glass region is composited source over. This means 231 // included in the glass region is composited source over. This means
229 // that anything drawn directly with GDI appears fully transparent. 232 // that anything drawn directly with GDI appears fully transparent.
230 DwmExtendFrameIntoClientArea(GetHWND(), &margins); 233 DwmExtendFrameIntoClientArea(GetHWND(), &margins);
231 } 234 }
(...skipping 30 matching lines...) Expand all
262 static bool initialized = false; 265 static bool initialized = false;
263 if (!initialized) { 266 if (!initialized) {
264 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); 267 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
265 for (int i = 0; i < kThrobberIconCount; ++i) { 268 for (int i = 0; i < kThrobberIconCount; ++i) {
266 throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i); 269 throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i);
267 DCHECK(throbber_icons_[i]); 270 DCHECK(throbber_icons_[i]);
268 } 271 }
269 initialized = true; 272 initialized = true;
270 } 273 }
271 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698