| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 bool WindowPositioner::DisableAutoPositioning(bool ignore) { | 276 bool WindowPositioner::DisableAutoPositioning(bool ignore) { |
| 277 bool old_state = disable_auto_positioning; | 277 bool old_state = disable_auto_positioning; |
| 278 disable_auto_positioning = ignore; | 278 disable_auto_positioning = ignore; |
| 279 return old_state; | 279 return old_state; |
| 280 } | 280 } |
| 281 | 281 |
| 282 // static | 282 // static |
| 283 void WindowPositioner::RearrangeVisibleWindowOnShow( | 283 void WindowPositioner::RearrangeVisibleWindowOnShow( |
| 284 aura::Window* added_window) { | 284 aura::Window* added_window) { |
| 285 wm::WindowState* added_window_state = wm::GetWindowState(added_window); | 285 wm::WindowState* added_window_state = wm::GetWindowState(added_window); |
| 286 if (!added_window->TargetVisibility()) |
| 287 return; |
| 286 | 288 |
| 287 if (!UseAutoWindowManager(added_window) || | 289 if (!UseAutoWindowManager(added_window) || |
| 288 added_window_state->bounds_changed_by_user() || | 290 added_window_state->bounds_changed_by_user()) { |
| 289 !added_window->TargetVisibility()) | 291 if (added_window_state->minimum_visibility()) { |
| 292 // Guarante minimum visibility within the work area. |
| 293 gfx::Rect work_area = GetWorkAreaForWindowInParent(added_window); |
| 294 gfx::Rect bounds = added_window->bounds(); |
| 295 gfx::Rect new_bounds = bounds; |
| 296 ash::wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area, |
| 297 &new_bounds); |
| 298 if (new_bounds != bounds) |
| 299 added_window->SetBounds(new_bounds); |
| 300 } |
| 290 return; | 301 return; |
| 302 } |
| 291 // Find a single open managed window. | 303 // Find a single open managed window. |
| 292 bool single_window; | 304 bool single_window; |
| 293 aura::Window* other_shown_window = GetReferenceWindow( | 305 aura::Window* other_shown_window = GetReferenceWindow( |
| 294 added_window->GetRootWindow(), added_window, &single_window); | 306 added_window->GetRootWindow(), added_window, &single_window); |
| 295 | 307 |
| 296 if (!other_shown_window) { | 308 if (!other_shown_window) { |
| 297 // It could be that this window is the first window joining the workspace. | 309 // It could be that this window is the first window joining the workspace. |
| 298 if (!WindowPositionCanBeManaged(added_window) || other_shown_window) | 310 if (!WindowPositionCanBeManaged(added_window) || other_shown_window) |
| 299 return; | 311 return; |
| 300 // Since we might be going from 0 to 1 window, we have to arrange the new | 312 // Since we might be going from 0 to 1 window, we have to arrange the new |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // If the alignment was pushing the window out of the screen, we ignore the | 531 // If the alignment was pushing the window out of the screen, we ignore the |
| 520 // alignment for that call. | 532 // alignment for that call. |
| 521 if (abs(pos.right() - work_area.right()) < grid) | 533 if (abs(pos.right() - work_area.right()) < grid) |
| 522 x = work_area.right() - w; | 534 x = work_area.right() - w; |
| 523 if (abs(pos.bottom() - work_area.bottom()) < grid) | 535 if (abs(pos.bottom() - work_area.bottom()) < grid) |
| 524 y = work_area.bottom() - h; | 536 y = work_area.bottom() - h; |
| 525 return gfx::Rect(x, y, w, h); | 537 return gfx::Rect(x, y, w, h); |
| 526 } | 538 } |
| 527 | 539 |
| 528 } // namespace ash | 540 } // namespace ash |
| OLD | NEW |