| 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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/wm/window_cycle_controller.h" | 8 #include "ash/wm/window_cycle_controller.h" |
| 9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_list_impl.h" | 13 #include "chrome/browser/ui/browser_list_impl.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 15 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
| 16 #include "chrome/browser/ui/host_desktop.h" | 16 #include "chrome/browser/ui/host_desktop.h" |
| 17 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_delegate.h" | 19 #include "ui/aura/window_delegate.h" |
| 20 #include "ui/gfx/screen.h" | 20 #include "ui/gfx/screen.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // When a window gets opened in default mode and the screen is less then this | 24 // When a window gets opened in default mode and the screen is less then this |
| 25 // width, the window will get opened in maximized mode. | 25 // width, the window will get opened in maximized mode. |
| 26 const int kForceMaximizeWidthLimit = 1450; | 26 const int kForceMaximizeWidthLimit = 640; |
| 27 | 27 |
| 28 // Check if the given browser is 'valid': It is a tabbed, non minimized | 28 // Check if the given browser is 'valid': It is a tabbed, non minimized |
| 29 // window, which intersects with the |bounds_in_screen| area of a given screen. | 29 // window, which intersects with the |bounds_in_screen| area of a given screen. |
| 30 bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) { | 30 bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) { |
| 31 return (browser && browser->window() && | 31 return (browser && browser->window() && |
| 32 !(browser->is_type_popup() || browser->is_type_panel()) && | 32 !(browser->is_type_popup() || browser->is_type_panel()) && |
| 33 !browser->window()->IsMinimized() && | 33 !browser->window()->IsMinimized() && |
| 34 browser->window()->GetNativeWindow() && | 34 browser->window()->GetNativeWindow() && |
| 35 bounds_in_screen.Intersects( | 35 bounds_in_screen.Intersects( |
| 36 browser->window()->GetNativeWindow()->GetBoundsInScreen())); | 36 browser->window()->GetNativeWindow()->GetBoundsInScreen())); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 if (work_area.x() < bounds_in_screen.x()) { | 126 if (work_area.x() < bounds_in_screen.x()) { |
| 127 bounds_in_screen.set_x(work_area.x()); | 127 bounds_in_screen.set_x(work_area.x()); |
| 128 return true; | 128 return true; |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 return false; | 131 return false; |
| 132 } | 132 } |
| 133 | 133 |
| 134 } // namespace | 134 } // namespace |
| 135 | 135 |
| 136 // static |
| 137 int WindowSizer::GetForceMaximizedWidthLimit() { |
| 138 return kForceMaximizeWidthLimit; |
| 139 } |
| 140 |
| 136 bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, | 141 bool WindowSizer::GetBoundsOverrideAsh(gfx::Rect* bounds_in_screen, |
| 137 ui::WindowShowState* show_state) const { | 142 ui::WindowShowState* show_state) const { |
| 138 DCHECK(show_state); | 143 DCHECK(show_state); |
| 139 DCHECK(bounds_in_screen); | 144 DCHECK(bounds_in_screen); |
| 140 | 145 |
| 141 if (browser_ && | 146 if (browser_ && |
| 142 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { | 147 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH) { |
| 143 return false; | 148 return false; |
| 144 } | 149 } |
| 145 bounds_in_screen->SetRect(0, 0, 0, 0); | 150 bounds_in_screen->SetRect(0, 0, 0, 0); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (default_width > kMaximumWindowWidth) { | 227 if (default_width > kMaximumWindowWidth) { |
| 223 // The window should get centered on the screen and not follow the grid. | 228 // The window should get centered on the screen and not follow the grid. |
| 224 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; | 229 offset_x = (work_area.width() - kMaximumWindowWidth) / 2; |
| 225 default_width = kMaximumWindowWidth; | 230 default_width = kMaximumWindowWidth; |
| 226 } | 231 } |
| 227 default_bounds->SetRect(work_area.x() + offset_x, | 232 default_bounds->SetRect(work_area.x() + offset_x, |
| 228 work_area.y() + kDesktopBorderSize, | 233 work_area.y() + kDesktopBorderSize, |
| 229 default_width, | 234 default_width, |
| 230 default_height); | 235 default_height); |
| 231 } | 236 } |
| OLD | NEW |