| 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/common/default_state.h" | 5 #include "ash/wm/common/default_state.h" |
| 6 | 6 |
| 7 #include "ash/wm/common/dock/docked_window_layout_manager.h" | 7 #include "ash/wm/common/dock/docked_window_layout_manager.h" |
| 8 #include "ash/wm/common/window_animation_types.h" | 8 #include "ash/wm/common/window_animation_types.h" |
| 9 #include "ash/wm/common/window_parenting_utils.h" | 9 #include "ash/wm/common/window_parenting_utils.h" |
| 10 #include "ash/wm/common/window_positioning_utils.h" | 10 #include "ash/wm/common/window_positioning_utils.h" |
| 11 #include "ash/wm/common/window_state.h" | 11 #include "ash/wm/common/window_state.h" |
| 12 #include "ash/wm/common/window_state_delegate.h" | 12 #include "ash/wm/common/window_state_delegate.h" |
| 13 #include "ash/wm/common/window_state_util.h" | 13 #include "ash/wm/common/window_state_util.h" |
| 14 #include "ash/wm/common/wm_event.h" | 14 #include "ash/wm/common/wm_event.h" |
| 15 #include "ash/wm/common/wm_globals.h" | 15 #include "ash/wm/common/wm_globals.h" |
| 16 #include "ash/wm/common/wm_root_window_controller.h" | 16 #include "ash/wm/common/wm_root_window_controller.h" |
| 17 #include "ash/wm/common/wm_screen_util.h" | 17 #include "ash/wm/common/wm_screen_util.h" |
| 18 #include "ash/wm/common/wm_shell_window_ids.h" | 18 #include "ash/wm/common/wm_shell_window_ids.h" |
| 19 #include "ash/wm/common/wm_window.h" | 19 #include "ash/wm/common/wm_window.h" |
| 20 #include "ui/gfx/display.h" | 20 #include "ui/display/display.h" |
| 21 #include "ui/gfx/screen.h" | 21 #include "ui/display/screen.h" |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 namespace wm { | 24 namespace wm { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // This specifies how much percent (30%) of a window rect | 27 // This specifies how much percent (30%) of a window rect |
| 28 // must be visible when the window is added to the workspace. | 28 // must be visible when the window is added to the workspace. |
| 29 const float kMinimumPercentOnScreenArea = 0.3f; | 29 const float kMinimumPercentOnScreenArea = 0.3f; |
| 30 | 30 |
| 31 // When a window that has restore bounds at least as large as a work area is | 31 // When a window that has restore bounds at least as large as a work area is |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 // Move only if the restore bounds is outside of | 46 // Move only if the restore bounds is outside of |
| 47 // the display. There is no information about in which | 47 // the display. There is no information about in which |
| 48 // display it should be restored, so this is best guess. | 48 // display it should be restored, so this is best guess. |
| 49 // TODO(oshima): Restore information should contain the | 49 // TODO(oshima): Restore information should contain the |
| 50 // work area information like WindowResizer does for the | 50 // work area information like WindowResizer does for the |
| 51 // last window location. | 51 // last window location. |
| 52 gfx::Rect display_area = | 52 gfx::Rect display_area = |
| 53 window_state->window()->GetDisplayNearestWindow().bounds(); | 53 window_state->window()->GetDisplayNearestWindow().bounds(); |
| 54 | 54 |
| 55 if (!display_area.Intersects(restore_bounds)) { | 55 if (!display_area.Intersects(restore_bounds)) { |
| 56 const gfx::Display& display = | 56 const display::Display& display = |
| 57 gfx::Screen::GetScreen()->GetDisplayMatching(restore_bounds); | 57 display::Screen::GetScreen()->GetDisplayMatching(restore_bounds); |
| 58 WmGlobals* globals = window_state->window()->GetGlobals(); | 58 WmGlobals* globals = window_state->window()->GetGlobals(); |
| 59 WmWindow* new_root = globals->GetRootWindowForDisplayId(display.id()); | 59 WmWindow* new_root = globals->GetRootWindowForDisplayId(display.id()); |
| 60 if (new_root != window_state->window()->GetRootWindow()) { | 60 if (new_root != window_state->window()->GetRootWindow()) { |
| 61 WmWindow* new_container = new_root->GetChildByShellWindowId( | 61 WmWindow* new_container = new_root->GetChildByShellWindowId( |
| 62 window_state->window()->GetParent()->GetShellWindowId()); | 62 window_state->window()->GetParent()->GetShellWindowId()); |
| 63 new_container->AddChild(window_state->window()); | 63 new_container->AddChild(window_state->window()); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 | 240 |
| 241 void DefaultState::AttachState(WindowState* window_state, | 241 void DefaultState::AttachState(WindowState* window_state, |
| 242 WindowState::State* state_in_previous_mode) { | 242 WindowState::State* state_in_previous_mode) { |
| 243 DCHECK_EQ(stored_window_state_, window_state); | 243 DCHECK_EQ(stored_window_state_, window_state); |
| 244 | 244 |
| 245 ReenterToCurrentState(window_state, state_in_previous_mode); | 245 ReenterToCurrentState(window_state, state_in_previous_mode); |
| 246 | 246 |
| 247 // If the display has changed while in the another mode, | 247 // If the display has changed while in the another mode, |
| 248 // we need to let windows know the change. | 248 // we need to let windows know the change. |
| 249 gfx::Display current_display = | 249 display::Display current_display = |
| 250 window_state->window()->GetDisplayNearestWindow(); | 250 window_state->window()->GetDisplayNearestWindow(); |
| 251 if (stored_display_state_.bounds() != current_display.bounds()) { | 251 if (stored_display_state_.bounds() != current_display.bounds()) { |
| 252 const WMEvent event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); | 252 const WMEvent event(wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED); |
| 253 window_state->OnWMEvent(&event); | 253 window_state->OnWMEvent(&event); |
| 254 } else if (stored_display_state_.work_area() != current_display.work_area()) { | 254 } else if (stored_display_state_.work_area() != current_display.work_area()) { |
| 255 const WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); | 255 const WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); |
| 256 window_state->OnWMEvent(&event); | 256 window_state->OnWMEvent(&event); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); | 727 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); |
| 728 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); | 728 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); |
| 729 window_state->SetBoundsDirectAnimated(center_in_parent); | 729 window_state->SetBoundsDirectAnimated(center_in_parent); |
| 730 } | 730 } |
| 731 // Centering window is treated as if a user moved and resized the window. | 731 // Centering window is treated as if a user moved and resized the window. |
| 732 window_state->set_bounds_changed_by_user(true); | 732 window_state->set_bounds_changed_by_user(true); |
| 733 } | 733 } |
| 734 | 734 |
| 735 } // namespace wm | 735 } // namespace wm |
| 736 } // namespace ash | 736 } // namespace ash |
| OLD | NEW |