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

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

Issue 21116: Support custom border widths. Allow user to resize the window (instead of do... (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
« no previous file with comments | « no previous file | chrome/browser/views/frame/aero_glass_non_client_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
19 static const int kResizeBorder = 8;
20 // The width of the client edge to the left and right of the window. 18 // The width of the client edge to the left and right of the window.
21 static const int kWindowHorizontalClientEdgeWidth = 3; 19 static const int kClientEdgeWidth = 3;
22 // The height of the client edge to the bottom of the window. 20 // The height of the client edge to the bottom of the window.
23 static const int kWindowBottomClientEdgeHeight = 2; 21 static const int kClientEdgeHeight = 2;
24 // By how much the toolbar overlaps with the tab strip.
25 static const int kToolbarOverlapVertOffset = 5;
26 22
27 HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount]; 23 HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount];
28 24
29 /////////////////////////////////////////////////////////////////////////////// 25 ///////////////////////////////////////////////////////////////////////////////
30 // AeroGlassFrame, public: 26 // AeroGlassFrame, public:
31 27
32 AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view) 28 AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view)
33 : Window(browser_view), 29 : Window(browser_view),
34 browser_view_(browser_view), 30 browser_view_(browser_view),
35 frame_initialized_(false), 31 frame_initialized_(false),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 119
124 void AeroGlassFrame::OnMoving(UINT param, const RECT* new_bounds) { 120 void AeroGlassFrame::OnMoving(UINT param, const RECT* new_bounds) {
125 browser_view_->WindowMoved(); 121 browser_view_->WindowMoved();
126 } 122 }
127 123
128 LRESULT AeroGlassFrame::OnNCActivate(BOOL active) { 124 LRESULT AeroGlassFrame::OnNCActivate(BOOL active) {
129 if (browser_view_->ActivateAppModalDialog()) 125 if (browser_view_->ActivateAppModalDialog())
130 return TRUE; 126 return TRUE;
131 127
132 if (!frame_initialized_) { 128 if (!frame_initialized_) {
133 ::SetWindowPos(GetHWND(), NULL, 0, 0, 0, 0, 129 if (browser_view_->IsTabStripVisible()) {
134 SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED); 130 ::SetWindowPos(GetHWND(), NULL, 0, 0, 0, 0,
135 UpdateDWMFrame(); 131 SWP_NOSIZE | SWP_NOMOVE | SWP_FRAMECHANGED);
132 UpdateDWMFrame();
133 }
136 frame_initialized_ = true; 134 frame_initialized_ = true;
137 } 135 }
138 browser_view_->ActivationChanged(!!active); 136 browser_view_->ActivationChanged(!!active);
139 SetMsgHandled(false); 137 SetMsgHandled(false);
140 return TRUE; 138 return TRUE;
141 } 139 }
142 140
143 LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) { 141 LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) {
144 // By default the client side is set to the window size which is what 142 if (!browser_view_->IsTabStripVisible() || !mode) {
145 // we want. 143 SetMsgHandled(FALSE);
146 if (browser_view_->IsTabStripVisible() && mode == TRUE) {
147 // Calculate new NCCALCSIZE_PARAMS based on custom NCA inset.
148 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param);
149
150 // Hack necessary to stop black background flicker, we cut out
151 // resizeborder here to save us from having to do too much
152 // addition and subtraction in Layout(). We don't cut off the
153 // top + titlebar as that prevents the window controls from
154 // highlighting.
155 params->rgrc[0].left +=
156 (kResizeBorder - kWindowHorizontalClientEdgeWidth);
157 params->rgrc[0].right -=
158 (kResizeBorder - kWindowHorizontalClientEdgeWidth);
159 params->rgrc[0].bottom -=
160 (kResizeBorder - kWindowBottomClientEdgeHeight);
161
162 SetMsgHandled(TRUE);
163
164 // We need to reset the frame, as Vista resets it whenever it changes
165 // composition modes (and NCCALCSIZE is the closest thing we get to
166 // a reliable message about the change).
167 UpdateDWMFrame();
168
169 return 0; 144 return 0;
170 } 145 }
171 SetMsgHandled(FALSE); 146
147 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param);
148 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
149 params->rgrc[0].left += (border_thickness - kClientEdgeWidth);
150 params->rgrc[0].right -= (border_thickness - kClientEdgeWidth);
151 params->rgrc[0].bottom -= (border_thickness - kClientEdgeHeight);
152
153 UpdateDWMFrame();
154
155 SetMsgHandled(TRUE);
172 return 0; 156 return 0;
173 } 157 }
174 158
175 LRESULT AeroGlassFrame::OnNCHitTest(const CPoint& pt) { 159 LRESULT AeroGlassFrame::OnNCHitTest(const CPoint& pt) {
176 LRESULT result; 160 LRESULT result;
177 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y), 161 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y),
178 &result)) { 162 &result)) {
179 return result; 163 return result;
180 } 164 }
181 return Window::OnNCHitTest(pt); 165 return Window::OnNCHitTest(pt);
182 } 166 }
183 167
184 /////////////////////////////////////////////////////////////////////////////// 168 ///////////////////////////////////////////////////////////////////////////////
185 // AeroGlassFrame, views::CustomFrameWindow overrides: 169 // AeroGlassFrame, views::CustomFrameWindow overrides:
186 170
187 int AeroGlassFrame::GetShowState() const { 171 int AeroGlassFrame::GetShowState() const {
188 return browser_view_->GetShowState(); 172 return browser_view_->GetShowState();
189 } 173 }
190 174
191 /////////////////////////////////////////////////////////////////////////////// 175 ///////////////////////////////////////////////////////////////////////////////
192 // AeroGlassFrame, private: 176 // AeroGlassFrame, private:
193 177
194 void AeroGlassFrame::UpdateDWMFrame() { 178 void AeroGlassFrame::UpdateDWMFrame() {
195 // Nothing to do yet. 179 // Nothing to do yet.
196 if (!client_view()) 180 if (!client_view())
197 return; 181 return;
198 182
199 // We only adjust the DWM's glass rendering when we're a browser window. 183 MARGINS margins = { kClientEdgeWidth + 1,
200 // Popups and app windows get the standard client edge. 184 kClientEdgeWidth + 1,
201 if (browser_view_->IsTabStripVisible()) { 185 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(),
202 // By default, we just want to adjust the glass by the width of the inner 186 kClientEdgeHeight + 1 };
203 // bevel that aero renders to demarcate the client area. We supply our own 187 // Note: we don't use DwmEnableBlurBehindWindow because any region not
204 // client edge for the browser window and detached popups, so we don't want 188 // included in the glass region is composited source over. This means
205 // to show the default one. 189 // that anything drawn directly with GDI appears fully transparent.
206 int client_edge_left_width = kWindowHorizontalClientEdgeWidth + 1; 190 DwmExtendFrameIntoClientArea(GetHWND(), &margins);
207 int client_edge_right_width = kWindowHorizontalClientEdgeWidth + 1;
208 int client_edge_bottom_height = kWindowBottomClientEdgeHeight + 1;
209 int client_edge_top_height = kWindowBottomClientEdgeHeight;
210 if (browser_view_->IsTabStripVisible()) {
211 gfx::Rect tabstrip_bounds =
212 GetBoundsForTabStrip(browser_view_->tabstrip());
213 client_edge_top_height = tabstrip_bounds.bottom();
214 }
215
216 // Now poke the DWM.
217 MARGINS margins = { client_edge_left_width, client_edge_right_width,
218 client_edge_top_height, client_edge_bottom_height };
219 // Note: we don't use DwmEnableBlurBehindWindow because any region not
220 // included in the glass region is composited source over. This means
221 // that anything drawn directly with GDI appears fully transparent.
222 DwmExtendFrameIntoClientArea(GetHWND(), &margins);
223 }
224 } 191 }
225 192
226 AeroGlassNonClientView* AeroGlassFrame::GetAeroGlassNonClientView() const { 193 AeroGlassNonClientView* AeroGlassFrame::GetAeroGlassNonClientView() const {
227 // We can safely assume that this conversion is true. 194 // We can safely assume that this conversion is true.
228 return static_cast<AeroGlassNonClientView*>(non_client_view_); 195 return static_cast<AeroGlassNonClientView*>(non_client_view_);
229 } 196 }
230 197
231 void AeroGlassFrame::StartThrobber() { 198 void AeroGlassFrame::StartThrobber() {
232 if (!throbber_running_) { 199 if (!throbber_running_) {
233 throbber_running_ = true; 200 throbber_running_ = true;
(...skipping 20 matching lines...) Expand all
254 static bool initialized = false; 221 static bool initialized = false;
255 if (!initialized) { 222 if (!initialized) {
256 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); 223 ResourceBundle &rb = ResourceBundle::GetSharedInstance();
257 for (int i = 0; i < kThrobberIconCount; ++i) { 224 for (int i = 0; i < kThrobberIconCount; ++i) {
258 throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i); 225 throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i);
259 DCHECK(throbber_icons_[i]); 226 DCHECK(throbber_icons_[i]);
260 } 227 }
261 initialized = true; 228 initialized = true;
262 } 229 }
263 } 230 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/views/frame/aero_glass_non_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698