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/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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 bounds.set_x(work_area.x() + (work_area.width() - bounds.width()) / 2); | 139 bounds.set_x(work_area.x() + (work_area.width() - bounds.width()) / 2); |
140 } | 140 } |
141 | 141 |
142 if (animated) | 142 if (animated) |
143 SetBoundsAnimated(window, bounds); | 143 SetBoundsAnimated(window, bounds); |
144 else | 144 else |
145 window->SetBounds(bounds); | 145 window->SetBounds(bounds); |
146 } | 146 } |
147 | 147 |
148 // Get the first open (non minimized) window which is on the screen defined. | 148 // Get the first open (non minimized) window which is on the screen defined. |
149 aura::Window* GetReferenceWindow(const aura::RootWindow* root_window, | 149 aura::Window* GetReferenceWindow(const aura::Window* root_window, |
150 const aura::Window* exclude, | 150 const aura::Window* exclude, |
151 bool *single_window) { | 151 bool *single_window) { |
152 if (single_window) | 152 if (single_window) |
153 *single_window = true; | 153 *single_window = true; |
154 // Get the active window. | 154 // Get the active window. |
155 aura::Window* active = ash::wm::GetActiveWindow(); | 155 aura::Window* active = ash::wm::GetActiveWindow(); |
156 if (active && active->GetRootWindow() != root_window) | 156 if (active && active->GetRootWindow() != root_window) |
157 active = NULL; | 157 active = NULL; |
158 | 158 |
159 // Get a list of all windows. | 159 // Get a list of all windows. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // static | 213 // static |
214 void WindowPositioner::GetBoundsAndShowStateForNewWindow( | 214 void WindowPositioner::GetBoundsAndShowStateForNewWindow( |
215 const gfx::Screen* screen, | 215 const gfx::Screen* screen, |
216 const aura::Window* new_window, | 216 const aura::Window* new_window, |
217 bool is_saved_bounds, | 217 bool is_saved_bounds, |
218 ui::WindowShowState show_state_in, | 218 ui::WindowShowState show_state_in, |
219 gfx::Rect* bounds_in_out, | 219 gfx::Rect* bounds_in_out, |
220 ui::WindowShowState* show_state_out) { | 220 ui::WindowShowState* show_state_out) { |
221 | 221 |
222 // Always open new window in the target display. | 222 // Always open new window in the target display. |
223 aura::RootWindow* target = Shell::GetTargetRootWindow(); | 223 aura::Window* target = Shell::GetTargetRootWindow(); |
224 | 224 |
225 aura::Window* top_window = GetReferenceWindow(target, NULL, NULL); | 225 aura::Window* top_window = GetReferenceWindow(target, NULL, NULL); |
226 // Our window should not have any impact if we are already on top. | 226 // Our window should not have any impact if we are already on top. |
227 if (top_window == new_window) | 227 if (top_window == new_window) |
228 top_window = NULL; | 228 top_window = NULL; |
229 | 229 |
230 // If there is no valid other window we take the coordinates as is. | 230 // If there is no valid other window we take the coordinates as is. |
231 if (!top_window) { | 231 if (!top_window) { |
232 gfx::Rect work_area = screen->GetDisplayNearestWindow(target).work_area(); | 232 gfx::Rect work_area = screen->GetDisplayNearestWindow(target).work_area(); |
233 | 233 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // If the alignment was pushing the window out of the screen, we ignore the | 521 // If the alignment was pushing the window out of the screen, we ignore the |
522 // alignment for that call. | 522 // alignment for that call. |
523 if (abs(pos.right() - work_area.right()) < grid) | 523 if (abs(pos.right() - work_area.right()) < grid) |
524 x = work_area.right() - w; | 524 x = work_area.right() - w; |
525 if (abs(pos.bottom() - work_area.bottom()) < grid) | 525 if (abs(pos.bottom() - work_area.bottom()) < grid) |
526 y = work_area.bottom() - h; | 526 y = work_area.bottom() - h; |
527 return gfx::Rect(x, y, w, h); | 527 return gfx::Rect(x, y, w, h); |
528 } | 528 } |
529 | 529 |
530 } // namespace ash | 530 } // namespace ash |
OLD | NEW |