| 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/common/wm/default_state.h" | 5 #include "ash/common/wm/default_state.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/window_animation_types.h" | 7 #include "ash/common/wm/window_animation_types.h" |
| 8 #include "ash/common/wm/window_parenting_utils.h" | 8 #include "ash/common/wm/window_parenting_utils.h" |
| 9 #include "ash/common/wm/window_positioning_utils.h" | 9 #include "ash/common/wm/window_positioning_utils.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 11 #include "ash/common/wm/window_state_delegate.h" | 11 #include "ash/common/wm/window_state_delegate.h" |
| 12 #include "ash/common/wm/window_state_util.h" | 12 #include "ash/common/wm/window_state_util.h" |
| 13 #include "ash/common/wm/wm_event.h" | 13 #include "ash/common/wm/wm_event.h" |
| 14 #include "ash/common/wm/wm_screen_util.h" | 14 #include "ash/common/wm/wm_screen_util.h" |
| 15 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
| 16 #include "ash/common/wm_window.h" | 16 #include "ash/common/wm_window.h" |
| 17 #include "ash/public/cpp/shell_window_ids.h" | 17 #include "ash/public/cpp/shell_window_ids.h" |
| 18 #include "ash/root_window_controller.h" | 18 #include "ash/root_window_controller.h" |
| 19 #include "ash/shell.h" |
| 20 #include "ash/wm/screen_pinning_controller.h" |
| 19 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
| 20 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 21 | 23 |
| 22 namespace ash { | 24 namespace ash { |
| 23 namespace wm { | 25 namespace wm { |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 // This specifies how much percent (30%) of a window rect | 28 // This specifies how much percent (30%) of a window rect |
| 27 // must be visible when the window is added to the workspace. | 29 // must be visible when the window is added to the workspace. |
| 28 const float kMinimumPercentOnScreenArea = 0.3f; | 30 const float kMinimumPercentOnScreenArea = 0.3f; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 return; | 131 return; |
| 130 case WM_EVENT_SHOW_INACTIVE: | 132 case WM_EVENT_SHOW_INACTIVE: |
| 131 next_state_type = WINDOW_STATE_TYPE_INACTIVE; | 133 next_state_type = WINDOW_STATE_TYPE_INACTIVE; |
| 132 break; | 134 break; |
| 133 case WM_EVENT_PIN: | 135 case WM_EVENT_PIN: |
| 134 case WM_EVENT_TRUSTED_PIN: | 136 case WM_EVENT_TRUSTED_PIN: |
| 135 // If there already is a pinned window, it is not allowed to set it | 137 // If there already is a pinned window, it is not allowed to set it |
| 136 // to this window. | 138 // to this window. |
| 137 // TODO(hidehiko): If a system modal window is openening, the pinning | 139 // TODO(hidehiko): If a system modal window is openening, the pinning |
| 138 // probably should fail. | 140 // probably should fail. |
| 139 if (WmShell::Get()->IsPinned()) { | 141 if (Shell::Get()->screen_pinning_controller()->IsPinned()) { |
| 140 LOG(ERROR) << "An PIN event will be failed since another window is " | 142 LOG(ERROR) << "An PIN event will be failed since another window is " |
| 141 << "already in pinned mode."; | 143 << "already in pinned mode."; |
| 142 next_state_type = current_state_type; | 144 next_state_type = current_state_type; |
| 143 } else { | 145 } else { |
| 144 next_state_type = event->type() == WM_EVENT_PIN | 146 next_state_type = event->type() == WM_EVENT_PIN |
| 145 ? WINDOW_STATE_TYPE_PINNED | 147 ? WINDOW_STATE_TYPE_PINNED |
| 146 : WINDOW_STATE_TYPE_TRUSTED_PINNED; | 148 : WINDOW_STATE_TYPE_TRUSTED_PINNED; |
| 147 } | 149 } |
| 148 break; | 150 break; |
| 149 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: | 151 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); | 518 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); |
| 517 else if (window_state->IsNormalStateType()) | 519 else if (window_state->IsNormalStateType()) |
| 518 window_state->ClearRestoreBounds(); | 520 window_state->ClearRestoreBounds(); |
| 519 } | 521 } |
| 520 window_state->NotifyPostStateTypeChange(previous_state_type); | 522 window_state->NotifyPostStateTypeChange(previous_state_type); |
| 521 | 523 |
| 522 if (next_state_type == WINDOW_STATE_TYPE_PINNED || | 524 if (next_state_type == WINDOW_STATE_TYPE_PINNED || |
| 523 previous_state_type == WINDOW_STATE_TYPE_PINNED || | 525 previous_state_type == WINDOW_STATE_TYPE_PINNED || |
| 524 next_state_type == WINDOW_STATE_TYPE_TRUSTED_PINNED || | 526 next_state_type == WINDOW_STATE_TYPE_TRUSTED_PINNED || |
| 525 previous_state_type == WINDOW_STATE_TYPE_TRUSTED_PINNED) { | 527 previous_state_type == WINDOW_STATE_TYPE_TRUSTED_PINNED) { |
| 526 WmShell::Get()->SetPinnedWindow(window_state->window()); | 528 Shell::Get()->screen_pinning_controller()->SetPinnedWindow( |
| 529 window_state->window()); |
| 527 } | 530 } |
| 528 } | 531 } |
| 529 | 532 |
| 530 void DefaultState::ReenterToCurrentState( | 533 void DefaultState::ReenterToCurrentState( |
| 531 WindowState* window_state, | 534 WindowState* window_state, |
| 532 WindowState::State* state_in_previous_mode) { | 535 WindowState::State* state_in_previous_mode) { |
| 533 WindowStateType previous_state_type = state_in_previous_mode->GetType(); | 536 WindowStateType previous_state_type = state_in_previous_mode->GetType(); |
| 534 | 537 |
| 535 // A state change should not move a window into or out of full screen or | 538 // A state change should not move a window into or out of full screen or |
| 536 // pinned since these are "special mode" the user wanted to be in and | 539 // pinned since these are "special mode" the user wanted to be in and |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); | 688 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); |
| 686 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); | 689 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); |
| 687 window_state->SetBoundsDirectAnimated(center_in_parent); | 690 window_state->SetBoundsDirectAnimated(center_in_parent); |
| 688 } | 691 } |
| 689 // Centering window is treated as if a user moved and resized the window. | 692 // Centering window is treated as if a user moved and resized the window. |
| 690 window_state->set_bounds_changed_by_user(true); | 693 window_state->set_bounds_changed_by_user(true); |
| 691 } | 694 } |
| 692 | 695 |
| 693 } // namespace wm | 696 } // namespace wm |
| 694 } // namespace ash | 697 } // namespace ash |
| OLD | NEW |