OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/common/wm/window_positioner.h" | 5 #include "ash/common/wm/window_positioner.h" |
6 | 6 |
7 #include "ash/common/wm/mru_window_tracker.h" | 7 #include "ash/common/wm/mru_window_tracker.h" |
8 #include "ash/common/wm/window_positioning_utils.h" | 8 #include "ash/common/wm/window_positioning_utils.h" |
9 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
10 #include "ash/common/wm/wm_screen_util.h" | 10 #include "ash/common/wm/wm_screen_util.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 bool* single_window) { | 156 bool* single_window) { |
157 if (single_window) | 157 if (single_window) |
158 *single_window = true; | 158 *single_window = true; |
159 // Get the active window. | 159 // Get the active window. |
160 WmWindow* active = root_window->GetShell()->GetActiveWindow(); | 160 WmWindow* active = root_window->GetShell()->GetActiveWindow(); |
161 if (active && active->GetRootWindow() != root_window) | 161 if (active && active->GetRootWindow() != root_window) |
162 active = NULL; | 162 active = NULL; |
163 | 163 |
164 // Get a list of all windows. | 164 // Get a list of all windows. |
165 const std::vector<WmWindow*> windows = root_window->GetShell() | 165 const std::vector<WmWindow*> windows = root_window->GetShell() |
166 ->GetMruWindowTracker() | 166 ->mru_window_tracker() |
167 ->BuildWindowListIgnoreModal(); | 167 ->BuildWindowListIgnoreModal(); |
168 | 168 |
169 if (windows.empty()) | 169 if (windows.empty()) |
170 return nullptr; | 170 return nullptr; |
171 | 171 |
172 int index = 0; | 172 int index = 0; |
173 // Find the index of the current active window. | 173 // Find the index of the current active window. |
174 if (active) | 174 if (active) |
175 index = std::find(windows.begin(), windows.end(), active) - windows.begin(); | 175 index = std::find(windows.begin(), windows.end(), active) - windows.begin(); |
176 | 176 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 last_popup_position_x_ += pop_position_offset_increment_x; | 471 last_popup_position_x_ += pop_position_offset_increment_x; |
472 last_popup_position_y_ += pop_position_offset_increment_y; | 472 last_popup_position_y_ += pop_position_offset_increment_y; |
473 } | 473 } |
474 return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); | 474 return gfx::Rect(x + work_area.x(), y + work_area.y(), w, h); |
475 } | 475 } |
476 | 476 |
477 gfx::Rect WindowPositioner::SmartPopupPosition(const gfx::Rect& old_pos, | 477 gfx::Rect WindowPositioner::SmartPopupPosition(const gfx::Rect& old_pos, |
478 const gfx::Rect& work_area, | 478 const gfx::Rect& work_area, |
479 int grid) { | 479 int grid) { |
480 const std::vector<WmWindow*> windows = | 480 const std::vector<WmWindow*> windows = |
481 shell_->GetMruWindowTracker()->BuildWindowListIgnoreModal(); | 481 shell_->mru_window_tracker()->BuildWindowListIgnoreModal(); |
482 | 482 |
483 std::vector<const gfx::Rect*> regions; | 483 std::vector<const gfx::Rect*> regions; |
484 // Process the window list and check if we can bail immediately. | 484 // Process the window list and check if we can bail immediately. |
485 for (size_t i = 0; i < windows.size(); i++) { | 485 for (size_t i = 0; i < windows.size(); i++) { |
486 // We only include opaque and visible windows. | 486 // We only include opaque and visible windows. |
487 if (windows[i] && windows[i]->IsVisible() && windows[i]->GetLayer() && | 487 if (windows[i] && windows[i]->IsVisible() && windows[i]->GetLayer() && |
488 (windows[i]->GetLayer()->fills_bounds_opaquely() || | 488 (windows[i]->GetLayer()->fills_bounds_opaquely() || |
489 windows[i]->GetLayer()->GetTargetOpacity() == 1.0)) { | 489 windows[i]->GetLayer()->GetTargetOpacity() == 1.0)) { |
490 wm::WindowState* window_state = windows[i]->GetWindowState(); | 490 wm::WindowState* window_state = windows[i]->GetWindowState(); |
491 // When any window is maximized we cannot find any free space. | 491 // When any window is maximized we cannot find any free space. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 // If the alignment was pushing the window out of the screen, we ignore the | 555 // If the alignment was pushing the window out of the screen, we ignore the |
556 // alignment for that call. | 556 // alignment for that call. |
557 if (abs(pos.right() - work_area.right()) < grid) | 557 if (abs(pos.right() - work_area.right()) < grid) |
558 x = work_area.right() - w; | 558 x = work_area.right() - w; |
559 if (abs(pos.bottom() - work_area.bottom()) < grid) | 559 if (abs(pos.bottom() - work_area.bottom()) < grid) |
560 y = work_area.bottom() - h; | 560 y = work_area.bottom() - h; |
561 return gfx::Rect(x, y, w, h); | 561 return gfx::Rect(x, y, w, h); |
562 } | 562 } |
563 | 563 |
564 } // namespace ash | 564 } // namespace ash |
OLD | NEW |