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/ash/window_positioner.h" | 5 #include "chrome/browser/ui/ash/window_positioner.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/wm/mru_window_tracker.h" | 8 #include "ash/wm/mru_window_tracker.h" |
9 #include "ash/wm/window_resizer.h" | 9 #include "ash/wm/window_resizer.h" |
| 10 #include "ash/wm/window_state.h" |
10 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
11 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
12 #include "ui/aura/window_delegate.h" | 13 #include "ui/aura/window_delegate.h" |
13 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
14 #include "ui/gfx/screen.h" | 15 #include "ui/gfx/screen.h" |
15 | 16 |
16 namespace ash { | 17 namespace ash { |
17 | 18 |
18 // statics | 19 // statics |
19 | 20 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 const std::vector<aura::Window*> windows = | 103 const std::vector<aura::Window*> windows = |
103 ash::MruWindowTracker::BuildWindowList(false); | 104 ash::MruWindowTracker::BuildWindowList(false); |
104 | 105 |
105 std::vector<const gfx::Rect*> regions; | 106 std::vector<const gfx::Rect*> regions; |
106 // Process the window list and check if we can bail immediately. | 107 // Process the window list and check if we can bail immediately. |
107 for (size_t i = 0; i < windows.size(); i++) { | 108 for (size_t i = 0; i < windows.size(); i++) { |
108 // We only include opaque and visible windows. | 109 // We only include opaque and visible windows. |
109 if (windows[i] && windows[i]->IsVisible() && windows[i]->layer() && | 110 if (windows[i] && windows[i]->IsVisible() && windows[i]->layer() && |
110 (!windows[i]->transparent() || | 111 (!windows[i]->transparent() || |
111 windows[i]->layer()->GetTargetOpacity() == 1.0)) { | 112 windows[i]->layer()->GetTargetOpacity() == 1.0)) { |
| 113 ash::wm::WindowState* window_state = ash::wm::GetWindowState(windows[i]); |
112 // When any window is maximized we cannot find any free space. | 114 // When any window is maximized we cannot find any free space. |
113 if (ash::wm::IsWindowMaximized(windows[i]) || | 115 if (window_state->IsMaximizedOrFullscreen()) |
114 ash::wm::IsWindowFullscreen(windows[i])) | |
115 return gfx::Rect(0, 0, 0, 0); | 116 return gfx::Rect(0, 0, 0, 0); |
116 if (ash::wm::IsWindowNormal(windows[i])) | 117 if (window_state->IsNormalShowState()) |
117 regions.push_back(&windows[i]->bounds()); | 118 regions.push_back(&windows[i]->bounds()); |
118 } | 119 } |
119 } | 120 } |
120 | 121 |
121 if (regions.empty()) | 122 if (regions.empty()) |
122 return gfx::Rect(0, 0, 0, 0); | 123 return gfx::Rect(0, 0, 0, 0); |
123 | 124 |
124 int w = old_pos.width(); | 125 int w = old_pos.width(); |
125 int h = old_pos.height(); | 126 int h = old_pos.height(); |
126 int x_end = work_area.width() / 2; | 127 int x_end = work_area.width() / 2; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // If the alignment was pushing the window out of the screen, we ignore the | 179 // If the alignment was pushing the window out of the screen, we ignore the |
179 // alignment for that call. | 180 // alignment for that call. |
180 if (abs(pos.right() - work_area.right()) < grid) | 181 if (abs(pos.right() - work_area.right()) < grid) |
181 x = work_area.right() - w; | 182 x = work_area.right() - w; |
182 if (abs(pos.bottom() - work_area.bottom()) < grid) | 183 if (abs(pos.bottom() - work_area.bottom()) < grid) |
183 y = work_area.bottom() - h; | 184 y = work_area.bottom() - h; |
184 return gfx::Rect(x, y, w, h); | 185 return gfx::Rect(x, y, w, h); |
185 } | 186 } |
186 | 187 |
187 } // namespace ash | 188 } // namespace ash |
OLD | NEW |