| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/window_sizer/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/mru_window_tracker.h" | 9 #include "ash/wm/mru_window_tracker.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (!GetSavedWindowBounds(bounds_in_screen, show_state)) { | 175 if (!GetSavedWindowBounds(bounds_in_screen, show_state)) { |
| 176 has_saved_bounds = false; | 176 has_saved_bounds = false; |
| 177 GetDefaultWindowBounds(bounds_in_screen); | 177 GetDefaultWindowBounds(bounds_in_screen); |
| 178 } | 178 } |
| 179 | 179 |
| 180 if (browser_ && browser_->is_type_tabbed()) { | 180 if (browser_ && browser_->is_type_tabbed()) { |
| 181 aura::RootWindow* active = ash::Shell::GetActiveRootWindow(); | 181 aura::RootWindow* active = ash::Shell::GetActiveRootWindow(); |
| 182 // Always open new window in the active display. | 182 // Always open new window in the active display. |
| 183 gfx::Rect active_area = active->GetBoundsInScreen(); | 183 gfx::Rect active_area = active->GetBoundsInScreen(); |
| 184 gfx::Rect work_area = | 184 gfx::Rect work_area = |
| 185 monitor_info_provider_->GetMonitorWorkAreaMatching(active_area); | 185 screen_->GetDisplayMatching(active_area).work_area(); |
| 186 | 186 |
| 187 // This is a window / app. See if there is no window and try to place it. | 187 // This is a window / app. See if there is no window and try to place it. |
| 188 int count = GetNumberOfValidTopLevelBrowserWindows(work_area); | 188 int count = GetNumberOfValidTopLevelBrowserWindows(work_area); |
| 189 aura::Window* top_window = GetTopWindow(work_area); | 189 aura::Window* top_window = GetTopWindow(work_area); |
| 190 // Our window should not have any impact if we are already on top. | 190 // Our window should not have any impact if we are already on top. |
| 191 if (browser_->window() && | 191 if (browser_->window() && |
| 192 top_window == browser_->window()->GetNativeWindow()) | 192 top_window == browser_->window()->GetNativeWindow()) |
| 193 top_window = NULL; | 193 top_window = NULL; |
| 194 | 194 |
| 195 // If there is no valid other window we take the coordinates as is. | 195 // If there is no valid other window we take the coordinates as is. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 MoveRect(work_area, *bounds_in_screen, move_right); | 231 MoveRect(work_area, *bounds_in_screen, move_right); |
| 232 bounds_in_screen->AdjustToFit(work_area); | 232 bounds_in_screen->AdjustToFit(work_area); |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 | 238 |
| 239 void WindowSizer::GetDefaultWindowBoundsAsh(gfx::Rect* default_bounds) const { | 239 void WindowSizer::GetDefaultWindowBoundsAsh(gfx::Rect* default_bounds) const { |
| 240 DCHECK(default_bounds); | 240 DCHECK(default_bounds); |
| 241 DCHECK(monitor_info_provider_.get()); | |
| 242 | 241 |
| 243 gfx::Rect work_area = monitor_info_provider_->GetPrimaryDisplayWorkArea(); | 242 gfx::Rect work_area = screen_->GetPrimaryDisplay().work_area(); |
| 244 | 243 |
| 245 // There should be a 'desktop' border around the window at the left and right | 244 // There should be a 'desktop' border around the window at the left and right |
| 246 // side. | 245 // side. |
| 247 int default_width = work_area.width() - 2 * kDesktopBorderSize; | 246 int default_width = work_area.width() - 2 * kDesktopBorderSize; |
| 248 // There should also be a 'desktop' border around the window at the top. | 247 // There should also be a 'desktop' border around the window at the top. |
| 249 // Since the workspace excludes the tray area we only need one border size. | 248 // Since the workspace excludes the tray area we only need one border size. |
| 250 int default_height = work_area.height() - kDesktopBorderSize; | 249 int default_height = work_area.height() - kDesktopBorderSize; |
| 251 // We align the size to the grid size to avoid any surprise when the | 250 // We align the size to the grid size to avoid any surprise when the |
| 252 // monitor height isn't divide-able by our alignment factor. | 251 // monitor height isn't divide-able by our alignment factor. |
| 253 default_width -= default_width % kDesktopBorderSize; | 252 default_width -= default_width % kDesktopBorderSize; |
| 254 default_height -= default_height % kDesktopBorderSize; | 253 default_height -= default_height % kDesktopBorderSize; |
| 255 int offset_x = kDesktopBorderSize; | 254 int offset_x = kDesktopBorderSize; |
| 256 if (default_width > kMaximumWindowWidth) { | 255 if (default_width > kMaximumWindowWidth) { |
| 257 // The window should get centered on the screen and not follow the grid. | 256 // The window should get centered on the screen and not follow the grid. |
| 258 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; | 257 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; |
| 259 default_width = kMaximumWindowWidth; | 258 default_width = kMaximumWindowWidth; |
| 260 } | 259 } |
| 261 default_bounds->SetRect(work_area.x() + offset_x, | 260 default_bounds->SetRect(work_area.x() + offset_x, |
| 262 work_area.y() + kDesktopBorderSize, | 261 work_area.y() + kDesktopBorderSize, |
| 263 default_width, | 262 default_width, |
| 264 default_height); | 263 default_height); |
| 265 } | 264 } |
| OLD | NEW |