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.h" | 5 #include "chrome/browser/ui/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" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 gfx::Rect work_area = monitor_info_provider_->GetPrimaryMonitorWorkArea(); | 100 gfx::Rect work_area = monitor_info_provider_->GetPrimaryMonitorWorkArea(); |
101 | 101 |
102 DCHECK_EQ(kDesktopBorderSize, ash::Shell::GetInstance()->GetGridSize()); | 102 DCHECK_EQ(kDesktopBorderSize, ash::Shell::GetInstance()->GetGridSize()); |
103 | 103 |
104 // There should be a 'desktop' border around the window at the left and right | 104 // There should be a 'desktop' border around the window at the left and right |
105 // side. | 105 // side. |
106 int default_width = work_area.width() - 2 * kDesktopBorderSize; | 106 int default_width = work_area.width() - 2 * kDesktopBorderSize; |
107 // There should also be a 'desktop' border around the window at the top. | 107 // There should also be a 'desktop' border around the window at the top. |
108 // Since the workspace excludes the tray area we only need one border size. | 108 // Since the workspace excludes the tray area we only need one border size. |
109 int default_height = work_area.height() - kDesktopBorderSize; | 109 int default_height = work_area.height() - kDesktopBorderSize; |
| 110 // We align the size to the grid size to avoid any surprise when the |
| 111 // monitor height isn't divide-able by our alignment factor. |
| 112 default_width -= default_width % kDesktopBorderSize; |
| 113 default_height -= default_height % kDesktopBorderSize; |
110 int offset_x = kDesktopBorderSize; | 114 int offset_x = kDesktopBorderSize; |
111 int maximum_window_width = 1280; | 115 int maximum_window_width = 1280; |
112 if (default_width > maximum_window_width) { | 116 if (default_width > maximum_window_width) { |
113 // The window should get centered on the screen as well. | 117 // The window should get centered on the screen and not follow the grid. |
114 offset_x = (work_area.width() - maximum_window_width) / 2; | 118 offset_x = (work_area.width() - maximum_window_width) / 2; |
115 // Never make a window wider then 1280. | 119 // Never make a window wider then 1280. |
116 default_width = maximum_window_width; | 120 default_width = maximum_window_width; |
117 } | 121 } |
118 default_bounds->SetRect(work_area.x() + offset_x, | 122 default_bounds->SetRect(work_area.x() + offset_x, |
119 work_area.y() + kDesktopBorderSize, | 123 work_area.y() + kDesktopBorderSize, |
120 default_width, | 124 default_width, |
121 default_height); | 125 default_height); |
122 } | 126 } |
OLD | NEW |