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

Side by Side Diff: chrome/browser/window_sizer.cc

Issue 141039: For consistency, stop using the workarea coordinate in... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/window_sizer_unittest.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/window_sizer.h" 5 #include "chrome/browser/window_sizer.h"
6 6
7 #include "chrome/browser/browser.h" 7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_list.h" 8 #include "chrome/browser/browser_list.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/browser_window.h" 10 #include "chrome/browser/browser_window.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 } 145 }
146 } 146 }
147 } 147 }
148 148
149 bool WindowSizer::GetLastWindowBounds(gfx::Rect* bounds) const { 149 bool WindowSizer::GetLastWindowBounds(gfx::Rect* bounds) const {
150 DCHECK(bounds); 150 DCHECK(bounds);
151 if (!state_provider_ || !state_provider_->GetLastActiveWindowState(bounds)) 151 if (!state_provider_ || !state_provider_->GetLastActiveWindowState(bounds))
152 return false; 152 return false;
153 gfx::Rect last_window_bounds = *bounds; 153 gfx::Rect last_window_bounds = *bounds;
154 bounds->Offset(monitor_info_provider_->GetBoundsOffsetMatching(*bounds));
155 bounds->Offset(kWindowTilePixels, kWindowTilePixels); 154 bounds->Offset(kWindowTilePixels, kWindowTilePixels);
156 AdjustBoundsToBeVisibleOnMonitorContaining(last_window_bounds, bounds); 155 AdjustBoundsToBeVisibleOnMonitorContaining(last_window_bounds, bounds);
157 return true; 156 return true;
158 } 157 }
159 158
160 bool WindowSizer::GetSavedWindowBounds(gfx::Rect* bounds, 159 bool WindowSizer::GetSavedWindowBounds(gfx::Rect* bounds,
161 bool* maximized) const { 160 bool* maximized) const {
162 DCHECK(bounds && maximized); 161 DCHECK(bounds && maximized);
163 if (!state_provider_ || 162 if (!state_provider_ ||
164 !state_provider_->GetPersistentState(bounds, maximized)) 163 !state_provider_->GetPersistentState(bounds, maximized))
165 return false; 164 return false;
166 bounds->Offset(monitor_info_provider_->GetBoundsOffsetMatching(*bounds));
167 AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, bounds); 165 AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, bounds);
168 return true; 166 return true;
169 } 167 }
170 168
171 void WindowSizer::GetDefaultWindowBounds(gfx::Rect* default_bounds) const { 169 void WindowSizer::GetDefaultWindowBounds(gfx::Rect* default_bounds) const {
172 DCHECK(default_bounds); 170 DCHECK(default_bounds);
173 DCHECK(monitor_info_provider_); 171 DCHECK(monitor_info_provider_);
174 172
175 gfx::Rect work_area = monitor_info_provider_->GetPrimaryMonitorWorkArea(); 173 gfx::Rect work_area = monitor_info_provider_->GetPrimaryMonitorWorkArea();
176 174
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 bounds->set_width(std::max(kMinVisibleWidth, bounds->width())); 255 bounds->set_width(std::max(kMinVisibleWidth, bounds->width()));
258 256
259 // Ensure at least kMinVisibleWidth * kMinVisibleHeight is visible. 257 // Ensure at least kMinVisibleWidth * kMinVisibleHeight is visible.
260 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height(); 258 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height();
261 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width(); 259 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width();
262 const int max_y = work_area.bottom() - kMinVisibleHeight; 260 const int max_y = work_area.bottom() - kMinVisibleHeight;
263 const int max_x = work_area.right() - kMinVisibleWidth; 261 const int max_x = work_area.right() - kMinVisibleWidth;
264 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y()))); 262 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y())));
265 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x()))); 263 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x())));
266 } 264 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/window_sizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698