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/views/ash/window_positioner.h" | 5 #include "chrome/browser/ui/views/ash/window_positioner.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_resizer.h" | 9 #include "ash/wm/window_resizer.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 last_popup_position_y_ += pop_position_offset_increment_y; | 94 last_popup_position_y_ += pop_position_offset_increment_y; |
95 } | 95 } |
96 return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); | 96 return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); |
97 } | 97 } |
98 | 98 |
99 gfx::Rect WindowPositioner::SmartPopupPosition( | 99 gfx::Rect WindowPositioner::SmartPopupPosition( |
100 const gfx::Rect& old_pos, | 100 const gfx::Rect& old_pos, |
101 const gfx::Rect& work_area, | 101 const gfx::Rect& work_area, |
102 int grid) { | 102 int grid) { |
103 const std::vector<aura::Window*> windows = | 103 const std::vector<aura::Window*> windows = |
104 ash::WindowCycleController::BuildWindowList(); | 104 ash::WindowCycleController::BuildWindowList(NULL); |
105 | 105 |
106 std::vector<const gfx::Rect*> regions; | 106 std::vector<const gfx::Rect*> regions; |
107 // Process the window list and check if we can bail immediately. | 107 // Process the window list and check if we can bail immediately. |
108 for (size_t i = 0; i < windows.size(); i++) { | 108 for (size_t i = 0; i < windows.size(); i++) { |
109 // We only include opaque and visible windows. | 109 // We only include opaque and visible windows. |
110 if (windows[i] && windows[i]->IsVisible() && windows[i]->layer() && | 110 if (windows[i] && windows[i]->IsVisible() && windows[i]->layer() && |
111 (!windows[i]->transparent() || | 111 (!windows[i]->transparent() || |
112 windows[i]->layer()->GetTargetOpacity() == 1.0)) { | 112 windows[i]->layer()->GetTargetOpacity() == 1.0)) { |
113 // When any window is maximized we cannot find any free space. | 113 // When any window is maximized we cannot find any free space. |
114 if (ash::wm::IsWindowMaximized(windows[i]) || | 114 if (ash::wm::IsWindowMaximized(windows[i]) || |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 int h = pos.height(); | 181 int h = pos.height(); |
182 | 182 |
183 // If the alignment was pushing the window out of the screen, we ignore the | 183 // If the alignment was pushing the window out of the screen, we ignore the |
184 // alignment for that call. | 184 // alignment for that call. |
185 if (abs(pos.right() - work_area.right()) < grid) | 185 if (abs(pos.right() - work_area.right()) < grid) |
186 x = work_area.right() - w; | 186 x = work_area.right() - w; |
187 if (abs(pos.bottom() - work_area.bottom()) < grid) | 187 if (abs(pos.bottom() - work_area.bottom()) < grid) |
188 y = work_area.bottom() - h; | 188 y = work_area.bottom() - h; |
189 return gfx::Rect(x, y, w, h); | 189 return gfx::Rect(x, y, w, h); |
190 } | 190 } |
OLD | NEW |