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

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

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First cut for review/trybots Created 7 years, 2 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 | Annotate | Revision Log
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/wm/window_positioner.h" 5 #include "ash/wm/window_positioner.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bounds.set_x(work_area.x() + (work_area.width() - bounds.width()) / 2); 131 bounds.set_x(work_area.x() + (work_area.width() - bounds.width()) / 2);
132 } 132 }
133 133
134 if (animated) 134 if (animated)
135 SetBoundsAnimated(window, bounds); 135 SetBoundsAnimated(window, bounds);
136 else 136 else
137 window->SetBounds(bounds); 137 window->SetBounds(bounds);
138 } 138 }
139 139
140 // Get the first open (non minimized) window which is on the screen defined. 140 // Get the first open (non minimized) window which is on the screen defined.
141 aura::Window* GetReferenceWindow(const aura::RootWindow* root_window, 141 aura::Window* GetReferenceWindow(const aura::Window* root_window,
142 const aura::Window* exclude, 142 const aura::Window* exclude,
143 bool *single_window) { 143 bool *single_window) {
144 if (single_window) 144 if (single_window)
145 *single_window = true; 145 *single_window = true;
146 // Get the active window. 146 // Get the active window.
147 aura::Window* active = ash::wm::GetActiveWindow(); 147 aura::Window* active = ash::wm::GetActiveWindow();
148 if (active && active->GetRootWindow() != root_window) 148 if (active && active->GetRootWindow() != root_window)
149 active = NULL; 149 active = NULL;
150 150
151 // Get a list of all windows. 151 // Get a list of all windows.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // static 205 // static
206 void WindowPositioner::GetBoundsAndShowStateForNewWindow( 206 void WindowPositioner::GetBoundsAndShowStateForNewWindow(
207 const gfx::Screen* screen, 207 const gfx::Screen* screen,
208 const aura::Window* new_window, 208 const aura::Window* new_window,
209 bool is_saved_bounds, 209 bool is_saved_bounds,
210 ui::WindowShowState show_state_in, 210 ui::WindowShowState show_state_in,
211 gfx::Rect* bounds_in_out, 211 gfx::Rect* bounds_in_out,
212 ui::WindowShowState* show_state_out) { 212 ui::WindowShowState* show_state_out) {
213 213
214 // Always open new window in the target display. 214 // Always open new window in the target display.
215 aura::RootWindow* target = Shell::GetTargetRootWindow(); 215 aura::Window* target = Shell::GetTargetRootWindow();
216 216
217 aura::Window* top_window = GetReferenceWindow(target, NULL, NULL); 217 aura::Window* top_window = GetReferenceWindow(target, NULL, NULL);
218 // Our window should not have any impact if we are already on top. 218 // Our window should not have any impact if we are already on top.
219 if (top_window == new_window) 219 if (top_window == new_window)
220 top_window = NULL; 220 top_window = NULL;
221 221
222 // If there is no valid other window we take the coordinates as is. 222 // If there is no valid other window we take the coordinates as is.
223 if (!top_window) { 223 if (!top_window) {
224 gfx::Rect work_area = screen->GetDisplayNearestWindow(target).work_area(); 224 gfx::Rect work_area = screen->GetDisplayNearestWindow(target).work_area();
225 225
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 // If the alignment was pushing the window out of the screen, we ignore the 506 // If the alignment was pushing the window out of the screen, we ignore the
507 // alignment for that call. 507 // alignment for that call.
508 if (abs(pos.right() - work_area.right()) < grid) 508 if (abs(pos.right() - work_area.right()) < grid)
509 x = work_area.right() - w; 509 x = work_area.right() - w;
510 if (abs(pos.bottom() - work_area.bottom()) < grid) 510 if (abs(pos.bottom() - work_area.bottom()) < grid)
511 y = work_area.bottom() - h; 511 y = work_area.bottom() - h;
512 return gfx::Rect(x, y, w, h); 512 return gfx::Rect(x, y, w, h);
513 } 513 }
514 514
515 } // namespace ash 515 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_manager_unittest.cc ('k') | ash/wm/window_util.cc » ('j') | ui/aura/root_window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698