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

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

Issue 2886253002: mash: remove more shell/shelf WmWindow usage. (Closed)
Patch Set: Fix WmShelf::ForWindow. Created 3 years, 7 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/wm/window_cycle_list.cc ('k') | ash/wm/window_positioner_unittest.cc » ('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/wm/window_positioner.h" 5 #include "ash/wm/window_positioner.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_port.h" 9 #include "ash/shell_port.h"
10 #include "ash/wm/mru_window_tracker.h" 10 #include "ash/wm/mru_window_tracker.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 // static 214 // static
215 void WindowPositioner::GetBoundsAndShowStateForNewWindow( 215 void WindowPositioner::GetBoundsAndShowStateForNewWindow(
216 const WmWindow* new_window, 216 const WmWindow* 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 // Always open new window in the target display. 221 // Always open new window in the target display.
222 WmWindow* target = Shell::GetWmRootWindowForNewWindows(); 222 aura::Window* target = Shell::GetRootWindowForNewWindows();
223 223
224 WmWindow* top_window = GetReferenceWindow(target, nullptr, nullptr); 224 WmWindow* top_window =
225 GetReferenceWindow(WmWindow::Get(target), nullptr, nullptr);
225 // 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.
226 if (top_window == new_window) 227 if (top_window == new_window)
227 top_window = nullptr; 228 top_window = nullptr;
228 229
229 // If there is no valid other window we take and adjust the passed coordinates 230 // If there is no valid other window we take and adjust the passed coordinates
230 // and show state. 231 // and show state.
231 if (!top_window) { 232 if (!top_window) {
232 gfx::Rect work_area = target->GetDisplayNearestWindow().work_area(); 233 gfx::Rect work_area = display::Screen::GetScreen()
234 ->GetDisplayNearestWindow(target)
235 .work_area();
233 236
234 bounds_in_out->AdjustToFit(work_area); 237 bounds_in_out->AdjustToFit(work_area);
235 // Use adjusted saved bounds, if there is one. 238 // Use adjusted saved bounds, if there is one.
236 if (is_saved_bounds) 239 if (is_saved_bounds)
237 return; 240 return;
238 241
239 if (show_state_in == ui::SHOW_STATE_DEFAULT) { 242 if (show_state_in == ui::SHOW_STATE_DEFAULT) {
240 const bool maximize_first_window_on_first_run = 243 const bool maximize_first_window_on_first_run =
241 ShellPort::Get()->IsForceMaximizeOnFirstRun(); 244 ShellPort::Get()->IsForceMaximizeOnFirstRun();
242 // We want to always open maximized on "small screens" or when policy 245 // We want to always open maximized on "small screens" or when policy
(...skipping 24 matching lines...) Expand all
267 if (has_restore_bounds) { 270 if (has_restore_bounds) {
268 // For a maximized/fullscreen window ignore the real bounds of 271 // For a maximized/fullscreen window ignore the real bounds of
269 // the top level window and use its restore bounds 272 // the top level window and use its restore bounds
270 // instead. Offset the bounds to prevent the windows from 273 // instead. Offset the bounds to prevent the windows from
271 // overlapping exactly when restored. 274 // overlapping exactly when restored.
272 *bounds_in_out = 275 *bounds_in_out =
273 top_window_state->GetRestoreBoundsInScreen() + 276 top_window_state->GetRestoreBoundsInScreen() +
274 gfx::Vector2d(kMinimumWindowOffset, kMinimumWindowOffset); 277 gfx::Vector2d(kMinimumWindowOffset, kMinimumWindowOffset);
275 } 278 }
276 if (is_saved_bounds || has_restore_bounds) { 279 if (is_saved_bounds || has_restore_bounds) {
277 gfx::Rect work_area = target->GetDisplayNearestWindow().work_area(); 280 gfx::Rect work_area = display::Screen::GetScreen()
281 ->GetDisplayNearestWindow(target)
282 .work_area();
278 bounds_in_out->AdjustToFit(work_area); 283 bounds_in_out->AdjustToFit(work_area);
279 // Use adjusted saved bounds or restore bounds, if there is one. 284 // Use adjusted saved bounds or restore bounds, if there is one.
280 return; 285 return;
281 } 286 }
282 } 287 }
283 288
284 // Use the size of the other window. The window's bound will be rearranged 289 // Use the size of the other window. The window's bound will be rearranged
285 // in ash::WorkspaceLayoutManager using this location. 290 // in ash::WorkspaceLayoutManager using this location.
286 *bounds_in_out = top_window->GetBoundsInScreen(); 291 *bounds_in_out = top_window->GetBoundsInScreen();
287 } 292 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 // If the alignment was pushing the window out of the screen, we ignore the 563 // If the alignment was pushing the window out of the screen, we ignore the
559 // alignment for that call. 564 // alignment for that call.
560 if (abs(pos.right() - work_area.right()) < grid) 565 if (abs(pos.right() - work_area.right()) < grid)
561 x = work_area.right() - w; 566 x = work_area.right() - w;
562 if (abs(pos.bottom() - work_area.bottom()) < grid) 567 if (abs(pos.bottom() - work_area.bottom()) < grid)
563 y = work_area.bottom() - h; 568 y = work_area.bottom() - h;
564 return gfx::Rect(x, y, w, h); 569 return gfx::Rect(x, y, w, h);
565 } 570 }
566 571
567 } // namespace ash 572 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_cycle_list.cc ('k') | ash/wm/window_positioner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698