Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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)); | |
|
Peter Kasting
2009/06/19 06:21:14
So wait a minute. I'm thinking about these more a
| |
| 154 bounds->Offset(kWindowTilePixels, kWindowTilePixels); | 155 bounds->Offset(kWindowTilePixels, kWindowTilePixels); |
| 155 AdjustBoundsToBeVisibleOnMonitorContaining(last_window_bounds, bounds); | 156 AdjustBoundsToBeVisibleOnMonitorContaining(last_window_bounds, bounds); |
| 156 return true; | 157 return true; |
| 157 } | 158 } |
| 158 | 159 |
| 159 bool WindowSizer::GetSavedWindowBounds(gfx::Rect* bounds, | 160 bool WindowSizer::GetSavedWindowBounds(gfx::Rect* bounds, |
| 160 bool* maximized) const { | 161 bool* maximized) const { |
| 161 DCHECK(bounds && maximized); | 162 DCHECK(bounds && maximized); |
| 162 if (!state_provider_ || | 163 if (!state_provider_ || |
| 163 !state_provider_->GetPersistentState(bounds, maximized)) | 164 !state_provider_->GetPersistentState(bounds, maximized)) |
| 164 return false; | 165 return false; |
| 165 const gfx::Point& taskbar_offset = | 166 bounds->Offset(monitor_info_provider_->GetBoundsOffsetMatching(*bounds)); |
| 166 monitor_info_provider_->GetBoundsOffsetMatching(*bounds); | |
| 167 bounds->Offset(taskbar_offset.x(), taskbar_offset.y()); | |
| 168 AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, bounds); | 167 AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, bounds); |
| 169 return true; | 168 return true; |
| 170 } | 169 } |
| 171 | 170 |
| 172 void WindowSizer::GetDefaultWindowBounds(gfx::Rect* default_bounds) const { | 171 void WindowSizer::GetDefaultWindowBounds(gfx::Rect* default_bounds) const { |
| 173 DCHECK(default_bounds); | 172 DCHECK(default_bounds); |
| 174 DCHECK(monitor_info_provider_); | 173 DCHECK(monitor_info_provider_); |
| 175 | 174 |
| 176 gfx::Rect work_area = monitor_info_provider_->GetPrimaryMonitorWorkArea(); | 175 gfx::Rect work_area = monitor_info_provider_->GetPrimaryMonitorWorkArea(); |
| 177 | 176 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 bounds->set_width(std::max(kMinVisibleWidth, bounds->width())); | 257 bounds->set_width(std::max(kMinVisibleWidth, bounds->width())); |
| 259 | 258 |
| 260 // Ensure at least kMinVisibleWidth * kMinVisibleHeight is visible. | 259 // Ensure at least kMinVisibleWidth * kMinVisibleHeight is visible. |
| 261 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height(); | 260 const int min_y = work_area.y() + kMinVisibleHeight - bounds->height(); |
| 262 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width(); | 261 const int min_x = work_area.x() + kMinVisibleWidth - bounds->width(); |
| 263 const int max_y = work_area.bottom() - kMinVisibleHeight; | 262 const int max_y = work_area.bottom() - kMinVisibleHeight; |
| 264 const int max_x = work_area.right() - kMinVisibleWidth; | 263 const int max_x = work_area.right() - kMinVisibleWidth; |
| 265 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y()))); | 264 bounds->set_y(std::max(min_y, std::min(max_y, bounds->y()))); |
| 266 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x()))); | 265 bounds->set_x(std::max(min_x, std::min(max_x, bounds->x()))); |
| 267 } | 266 } |
| OLD | NEW |