Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: ash/common/wm/window_positioner.cc

Issue 2041423002: Moves MruWindowTracker to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_mru_window_tracker
Patch Set: wm Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/aura/wm_shell_aura.cc ('k') | ash/common/wm_shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/window_positioning_utils.h" 8 #include "ash/common/wm/window_positioning_utils.h"
8 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm/wm_screen_util.h" 10 #include "ash/common/wm/wm_screen_util.h"
10 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h" 12 #include "ash/common/wm_window.h"
12 #include "ui/compositor/layer.h" 13 #include "ui/compositor/layer.h"
13 #include "ui/display/display.h" 14 #include "ui/display/display.h"
14 #include "ui/display/screen.h" 15 #include "ui/display/screen.h"
15 #include "ui/gfx/geometry/insets.h" 16 #include "ui/gfx/geometry/insets.h"
16 17
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const WmWindow* exclude, 155 const WmWindow* exclude,
155 bool* single_window) { 156 bool* single_window) {
156 if (single_window) 157 if (single_window)
157 *single_window = true; 158 *single_window = true;
158 // Get the active window. 159 // Get the active window.
159 WmWindow* active = root_window->GetShell()->GetActiveWindow(); 160 WmWindow* active = root_window->GetShell()->GetActiveWindow();
160 if (active && active->GetRootWindow() != root_window) 161 if (active && active->GetRootWindow() != root_window)
161 active = NULL; 162 active = NULL;
162 163
163 // Get a list of all windows. 164 // Get a list of all windows.
164 const std::vector<WmWindow*> windows = 165 const std::vector<WmWindow*> windows = root_window->GetShell()
165 root_window->GetShell()->GetMruWindowListIgnoreModals(); 166 ->GetMruWindowTracker()
167 ->BuildWindowListIgnoreModal();
166 168
167 if (windows.empty()) 169 if (windows.empty())
168 return nullptr; 170 return nullptr;
169 171
170 int index = 0; 172 int index = 0;
171 // Find the index of the current active window. 173 // Find the index of the current active window.
172 if (active) 174 if (active)
173 index = std::find(windows.begin(), windows.end(), active) - windows.begin(); 175 index = std::find(windows.begin(), windows.end(), active) - windows.begin();
174 176
175 // Scan the cycle list backwards to see which is the second topmost window 177 // Scan the cycle list backwards to see which is the second topmost window
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 if (!reset) { 470 if (!reset) {
469 last_popup_position_x_ += pop_position_offset_increment_x; 471 last_popup_position_x_ += pop_position_offset_increment_x;
470 last_popup_position_y_ += pop_position_offset_increment_y; 472 last_popup_position_y_ += pop_position_offset_increment_y;
471 } 473 }
472 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);
473 } 475 }
474 476
475 gfx::Rect WindowPositioner::SmartPopupPosition(const gfx::Rect& old_pos, 477 gfx::Rect WindowPositioner::SmartPopupPosition(const gfx::Rect& old_pos,
476 const gfx::Rect& work_area, 478 const gfx::Rect& work_area,
477 int grid) { 479 int grid) {
478 const std::vector<WmWindow*> windows = shell_->GetMruWindowListIgnoreModals(); 480 const std::vector<WmWindow*> windows =
481 shell_->GetMruWindowTracker()->BuildWindowListIgnoreModal();
479 482
480 std::vector<const gfx::Rect*> regions; 483 std::vector<const gfx::Rect*> regions;
481 // Process the window list and check if we can bail immediately. 484 // Process the window list and check if we can bail immediately.
482 for (size_t i = 0; i < windows.size(); i++) { 485 for (size_t i = 0; i < windows.size(); i++) {
483 // We only include opaque and visible windows. 486 // We only include opaque and visible windows.
484 if (windows[i] && windows[i]->IsVisible() && windows[i]->GetLayer() && 487 if (windows[i] && windows[i]->IsVisible() && windows[i]->GetLayer() &&
485 (windows[i]->GetLayer()->fills_bounds_opaquely() || 488 (windows[i]->GetLayer()->fills_bounds_opaquely() ||
486 windows[i]->GetLayer()->GetTargetOpacity() == 1.0)) { 489 windows[i]->GetLayer()->GetTargetOpacity() == 1.0)) {
487 wm::WindowState* window_state = windows[i]->GetWindowState(); 490 wm::WindowState* window_state = windows[i]->GetWindowState();
488 // 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
552 // 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
553 // alignment for that call. 556 // alignment for that call.
554 if (abs(pos.right() - work_area.right()) < grid) 557 if (abs(pos.right() - work_area.right()) < grid)
555 x = work_area.right() - w; 558 x = work_area.right() - w;
556 if (abs(pos.bottom() - work_area.bottom()) < grid) 559 if (abs(pos.bottom() - work_area.bottom()) < grid)
557 y = work_area.bottom() - h; 560 y = work_area.bottom() - h;
558 return gfx::Rect(x, y, w, h); 561 return gfx::Rect(x, y, w, h);
559 } 562 }
560 563
561 } // namespace ash 564 } // namespace ash
OLDNEW
« no previous file with comments | « ash/aura/wm_shell_aura.cc ('k') | ash/common/wm_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698