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/auto_window_management.h" | 5 #include "ash/wm/workspace/auto_window_management.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/property_util.h" | 9 #include "ash/wm/property_util.h" |
10 #include "ash/wm/window_animations.h" | 10 #include "ash/wm/window_animations.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Bail if we find a second usable window. | 62 // Bail if we find a second usable window. |
63 if (*other_window) | 63 if (*other_window) |
64 return false; | 64 return false; |
65 *other_window = iterated_window; | 65 *other_window = iterated_window; |
66 } | 66 } |
67 } | 67 } |
68 return *other_window != NULL; | 68 return *other_window != NULL; |
69 } | 69 } |
70 | 70 |
71 // Get the work area for a given |window|. | 71 // Get the work area for a given |window|. |
72 gfx::Rect GetWorkAreaForWindow(aura::Window* window) { | 72 gfx::Rect GetWorkAreaForWindow(const aura::Window* window) { |
73 return Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 73 gfx::Rect work_area = gfx::Rect(window->parent()->bounds().size()); |
| 74 work_area.Inset(Shell::GetScreen()->GetDisplayMatching( |
| 75 work_area).GetWorkAreaInsets()); |
| 76 return work_area; |
74 } | 77 } |
75 | 78 |
76 // Move the given |bounds| on the available |parent_width| to the | 79 // Move the given |bounds| on the available |parent_width| to the |
77 // direction. If |move_right| is true, the rectangle gets moved to the right | 80 // direction. If |move_right| is true, the rectangle gets moved to the right |
78 // corner, otherwise to the left one. | 81 // corner, otherwise to the left one. |
79 bool MoveRectToOneSide(int parent_width, bool move_right, gfx::Rect* bounds) { | 82 bool MoveRectToOneSide(int parent_width, bool move_right, gfx::Rect* bounds) { |
80 if (move_right) { | 83 if (move_right) { |
81 if (parent_width > bounds->right()) { | 84 if (parent_width > bounds->right()) { |
82 bounds->set_x(parent_width - bounds->width()); | 85 bounds->set_x(parent_width - bounds->width()); |
83 return true; | 86 return true; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // Since it is just coming into view, we do not need to animate it. | 185 // Since it is just coming into view, we do not need to animate it. |
183 gfx::Rect added_bounds = added_window->bounds(); | 186 gfx::Rect added_bounds = added_window->bounds(); |
184 ash::wm::SetPreAutoManageWindowBounds(added_window, added_bounds); | 187 ash::wm::SetPreAutoManageWindowBounds(added_window, added_bounds); |
185 if (MoveRectToOneSide(work_area.width(), !move_right, &added_bounds)) | 188 if (MoveRectToOneSide(work_area.width(), !move_right, &added_bounds)) |
186 added_window->SetBounds(added_bounds); | 189 added_window->SetBounds(added_bounds); |
187 } | 190 } |
188 } | 191 } |
189 | 192 |
190 } // namespace internal | 193 } // namespace internal |
191 } // namespace ash | 194 } // namespace ash |
OLD | NEW |