| 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/shell_window_ids.h" | 7 #include "ash/common/shell_window_ids.h" |
| 8 #include "ash/common/wm/dock/docked_window_layout_manager.h" | 8 #include "ash/common/wm/dock/docked_window_layout_manager.h" |
| 9 #include "ash/common/wm/window_animation_types.h" | 9 #include "ash/common/wm/window_animation_types.h" |
| 10 #include "ash/common/wm/window_parenting_utils.h" | 10 #include "ash/common/wm/window_parenting_utils.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 case WM_EVENT_DOCK: | 198 case WM_EVENT_DOCK: |
| 199 next_state_type = WINDOW_STATE_TYPE_DOCKED; | 199 next_state_type = WINDOW_STATE_TYPE_DOCKED; |
| 200 break; | 200 break; |
| 201 case WM_EVENT_SET_BOUNDS: | 201 case WM_EVENT_SET_BOUNDS: |
| 202 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event)); | 202 SetBounds(window_state, static_cast<const SetBoundsEvent*>(event)); |
| 203 return; | 203 return; |
| 204 case WM_EVENT_SHOW_INACTIVE: | 204 case WM_EVENT_SHOW_INACTIVE: |
| 205 next_state_type = WINDOW_STATE_TYPE_INACTIVE; | 205 next_state_type = WINDOW_STATE_TYPE_INACTIVE; |
| 206 break; | 206 break; |
| 207 case WM_EVENT_PIN: | 207 case WM_EVENT_PIN: |
| 208 // TODO(hidehiko): Check if the window can be pinnable. If a system modal | 208 // If there already is a pinned window, it is not allowed to set it |
| 209 // window is openening, or if there already is another pinned window, | 209 // to this window. |
| 210 // the pinning should fail. | 210 // TODO(hidehiko): If a system modal window is openening, the pinning |
| 211 next_state_type = WINDOW_STATE_TYPE_PINNED; | 211 // probably should fail. |
| 212 if (WmShell::Get()->IsPinned()) { |
| 213 LOG(ERROR) << "An PIN event is triggered, while another window is " |
| 214 << "already in pinned mode."; |
| 215 next_state_type = current_state_type; |
| 216 } else { |
| 217 next_state_type = WINDOW_STATE_TYPE_PINNED; |
| 218 } |
| 212 break; | 219 break; |
| 213 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: | 220 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: |
| 214 case WM_EVENT_TOGGLE_MAXIMIZE: | 221 case WM_EVENT_TOGGLE_MAXIMIZE: |
| 215 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: | 222 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: |
| 216 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: | 223 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: |
| 217 case WM_EVENT_TOGGLE_FULLSCREEN: | 224 case WM_EVENT_TOGGLE_FULLSCREEN: |
| 218 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: | 225 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: |
| 219 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: | 226 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: |
| 220 case WM_EVENT_CENTER: | 227 case WM_EVENT_CENTER: |
| 221 NOTREACHED() << "Compound event should not reach here:" << event; | 228 NOTREACHED() << "Compound event should not reach here:" << event; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 // unminimized. | 579 // unminimized. |
| 573 if (!restore_bounds_in_screen.IsEmpty()) | 580 if (!restore_bounds_in_screen.IsEmpty()) |
| 574 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); | 581 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); |
| 575 else if (window_state->IsNormalStateType()) | 582 else if (window_state->IsNormalStateType()) |
| 576 window_state->ClearRestoreBounds(); | 583 window_state->ClearRestoreBounds(); |
| 577 } | 584 } |
| 578 window_state->NotifyPostStateTypeChange(previous_state_type); | 585 window_state->NotifyPostStateTypeChange(previous_state_type); |
| 579 | 586 |
| 580 if (next_state_type == WINDOW_STATE_TYPE_PINNED || | 587 if (next_state_type == WINDOW_STATE_TYPE_PINNED || |
| 581 previous_state_type == WINDOW_STATE_TYPE_PINNED) { | 588 previous_state_type == WINDOW_STATE_TYPE_PINNED) { |
| 582 WmShell::Get()->NotifyPinnedStateChanged(window_state->window()); | 589 WmShell::Get()->SetPinnedWindow(window_state->window()); |
| 583 } | 590 } |
| 584 } | 591 } |
| 585 | 592 |
| 586 void DefaultState::ReenterToCurrentState( | 593 void DefaultState::ReenterToCurrentState( |
| 587 WindowState* window_state, | 594 WindowState* window_state, |
| 588 WindowState::State* state_in_previous_mode) { | 595 WindowState::State* state_in_previous_mode) { |
| 589 WindowStateType previous_state_type = state_in_previous_mode->GetType(); | 596 WindowStateType previous_state_type = state_in_previous_mode->GetType(); |
| 590 | 597 |
| 591 // A state change should not move a window into or out of full screen since | 598 // A state change should not move a window into or out of full screen since |
| 592 // full screen is a "special mode" the user wanted to be in and should be | 599 // full screen is a "special mode" the user wanted to be in and should be |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); | 749 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); |
| 743 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); | 750 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); |
| 744 window_state->SetBoundsDirectAnimated(center_in_parent); | 751 window_state->SetBoundsDirectAnimated(center_in_parent); |
| 745 } | 752 } |
| 746 // Centering window is treated as if a user moved and resized the window. | 753 // Centering window is treated as if a user moved and resized the window. |
| 747 window_state->set_bounds_changed_by_user(true); | 754 window_state->set_bounds_changed_by_user(true); |
| 748 } | 755 } |
| 749 | 756 |
| 750 } // namespace wm | 757 } // namespace wm |
| 751 } // namespace ash | 758 } // namespace ash |
| OLD | NEW |