| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/default_state.h" | 5 #include "ash/wm/default_state.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_port.h" | 10 #include "ash/shell_port.h" |
| 11 #include "ash/wm/screen_pinning_controller.h" | 11 #include "ash/wm/screen_pinning_controller.h" |
| 12 #include "ash/wm/window_animation_types.h" | 12 #include "ash/wm/window_animation_types.h" |
| 13 #include "ash/wm/window_parenting_utils.h" | 13 #include "ash/wm/window_parenting_utils.h" |
| 14 #include "ash/wm/window_positioning_utils.h" | 14 #include "ash/wm/window_positioning_utils.h" |
| 15 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
| 16 #include "ash/wm/window_state_delegate.h" | 16 #include "ash/wm/window_state_delegate.h" |
| 17 #include "ash/wm/window_state_util.h" | 17 #include "ash/wm/window_state_util.h" |
| 18 #include "ash/wm/wm_event.h" | 18 #include "ash/wm/wm_event.h" |
| 19 #include "ash/wm/wm_screen_util.h" | 19 #include "ash/wm/wm_screen_util.h" |
| 20 #include "ash/wm_window.h" | 20 #include "ash/wm_window.h" |
| 21 #include "ui/aura/window.h" |
| 21 #include "ui/display/display.h" | 22 #include "ui/display/display.h" |
| 22 #include "ui/display/screen.h" | 23 #include "ui/display/screen.h" |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| 25 namespace wm { | 26 namespace wm { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // This specifies how much percent (30%) of a window rect | 29 // This specifies how much percent (30%) of a window rect |
| 29 // must be visible when the window is added to the workspace. | 30 // must be visible when the window is added to the workspace. |
| 30 const float kMinimumPercentOnScreenArea = 0.3f; | 31 const float kMinimumPercentOnScreenArea = 0.3f; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 // display it should be restored, so this is best guess. | 49 // display it should be restored, so this is best guess. |
| 49 // TODO(oshima): Restore information should contain the | 50 // TODO(oshima): Restore information should contain the |
| 50 // work area information like WindowResizer does for the | 51 // work area information like WindowResizer does for the |
| 51 // last window location. | 52 // last window location. |
| 52 gfx::Rect display_area = | 53 gfx::Rect display_area = |
| 53 window_state->window()->GetDisplayNearestWindow().bounds(); | 54 window_state->window()->GetDisplayNearestWindow().bounds(); |
| 54 | 55 |
| 55 if (!display_area.Intersects(restore_bounds)) { | 56 if (!display_area.Intersects(restore_bounds)) { |
| 56 const display::Display& display = | 57 const display::Display& display = |
| 57 display::Screen::GetScreen()->GetDisplayMatching(restore_bounds); | 58 display::Screen::GetScreen()->GetDisplayMatching(restore_bounds); |
| 58 WmWindow* new_root = | 59 RootWindowController* new_root_controller = |
| 59 ShellPort::Get()->GetRootWindowForDisplayId(display.id()); | 60 Shell::Get()->GetRootWindowControllerWithDisplayId(display.id()); |
| 60 if (new_root != window_state->window()->GetRootWindow()) { | 61 if (new_root_controller->GetRootWindow() != |
| 61 WmWindow* new_container = new_root->GetChildByShellWindowId( | 62 window_state->window()->GetRootWindow()->aura_window()) { |
| 62 window_state->window()->GetParent()->GetShellWindowId()); | 63 aura::Window* new_container = |
| 63 new_container->AddChild(window_state->window()); | 64 new_root_controller->GetRootWindow()->GetChildById( |
| 65 window_state->window()->GetParent()->aura_window()->id()); |
| 66 new_container->AddChild(window_state->window()->aura_window()); |
| 64 } | 67 } |
| 65 } | 68 } |
| 66 } | 69 } |
| 67 | 70 |
| 68 void CycleSnap(WindowState* window_state, WMEventType event) { | 71 void CycleSnap(WindowState* window_state, WMEventType event) { |
| 69 wm::WindowStateType desired_snap_state = | 72 wm::WindowStateType desired_snap_state = |
| 70 event == WM_EVENT_CYCLE_SNAP_LEFT ? wm::WINDOW_STATE_TYPE_LEFT_SNAPPED | 73 event == WM_EVENT_CYCLE_SNAP_LEFT ? wm::WINDOW_STATE_TYPE_LEFT_SNAPPED |
| 71 : wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED; | 74 : wm::WINDOW_STATE_TYPE_RIGHT_SNAPPED; |
| 72 | 75 |
| 73 if (window_state->CanSnap() && | 76 if (window_state->CanSnap() && |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); | 691 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); |
| 689 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); | 692 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); |
| 690 window_state->SetBoundsDirectAnimated(center_in_parent); | 693 window_state->SetBoundsDirectAnimated(center_in_parent); |
| 691 } | 694 } |
| 692 // Centering window is treated as if a user moved and resized the window. | 695 // Centering window is treated as if a user moved and resized the window. |
| 693 window_state->set_bounds_changed_by_user(true); | 696 window_state->set_bounds_changed_by_user(true); |
| 694 } | 697 } |
| 695 | 698 |
| 696 } // namespace wm | 699 } // namespace wm |
| 697 } // namespace ash | 700 } // namespace ash |
| OLD | NEW |