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 "ash/wm/workspace/snap_sizer.h" | 5 #include "ash/wm/workspace/snap_sizer.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
10 #include "ash/wm/window_resizer.h" | 10 #include "ash/wm/window_resizer.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 gfx::Rect work_area(ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(window_)); | 93 gfx::Rect work_area(ScreenAsh::GetUnmaximizedWorkAreaBoundsInParent(window_)); |
94 int y = work_area.y(); | 94 int y = work_area.y(); |
95 // We don't align to the bottom of the grid as the launcher may not | 95 // We don't align to the bottom of the grid as the launcher may not |
96 // necessarily align to the grid (happens when auto-hidden). | 96 // necessarily align to the grid (happens when auto-hidden). |
97 int max_y = work_area.bottom(); | 97 int max_y = work_area.bottom(); |
98 int width = kSizes[size_index]; | 98 int width = kSizes[size_index]; |
99 if (resize_disabled_) { | 99 if (resize_disabled_) { |
100 width = std::max(1024, work_area.width() / 2); | 100 width = std::max(1024, work_area.width() / 2); |
101 } else { | 101 } else { |
102 while (width >= work_area.width()) { | 102 while (width >= work_area.width()) { |
| 103 ++size_index; |
103 if (size_index >= arraysize(kSizes)) | 104 if (size_index >= arraysize(kSizes)) |
104 break; | 105 break; |
105 width = kSizes[++size_index]; | 106 width = kSizes[size_index]; |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 // Make sure that we keep the size of the window smaller then a certain | 110 // Make sure that we keep the size of the window smaller then a certain |
110 // fraction of the screen space. | 111 // fraction of the screen space. |
111 width = std::min(width, kMinimumScreenPercent * work_area.width() / 100); | 112 width = std::min(width, kMinimumScreenPercent * work_area.width() / 100); |
112 | 113 |
113 if (edge_ == LEFT_EDGE) { | 114 if (edge_ == LEFT_EDGE) { |
114 int x = work_area.x(); | 115 int x = work_area.x(); |
115 int mid_x = x + width; | 116 int mid_x = x + width; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return GetTargetBoundsForSize(size_index_); | 152 return GetTargetBoundsForSize(size_index_); |
152 } | 153 } |
153 | 154 |
154 bool SnapSizer::AlongEdge(int x) const { | 155 bool SnapSizer::AlongEdge(int x) const { |
155 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window_)); | 156 gfx::Rect area(ScreenAsh::GetDisplayBoundsInParent(window_)); |
156 return (x <= area.x()) || (x >= area.right() - 1); | 157 return (x <= area.x()) || (x >= area.right() - 1); |
157 } | 158 } |
158 | 159 |
159 } // namespace internal | 160 } // namespace internal |
160 } // namespace ash | 161 } // namespace ash |
OLD | NEW |