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 case WM_EVENT_TRUSTED_PIN: | |
208 // If there already is a pinned window, it is not allowed to set it | 209 // If there already is a pinned window, it is not allowed to set it |
209 // to this window. | 210 // to this window. |
210 // TODO(hidehiko): If a system modal window is openening, the pinning | 211 // TODO(hidehiko): If a system modal window is openening, the pinning |
211 // probably should fail. | 212 // probably should fail. |
212 if (WmShell::Get()->IsPinned()) { | 213 if (WmShell::Get()->IsPinned()) { |
213 LOG(ERROR) << "An PIN event is triggered, while another window is " | 214 LOG(ERROR) << "An PIN event is triggered, while another window is " |
214 << "already in pinned mode."; | 215 << "already in pinned mode."; |
oshima
2016/09/09 07:18:02
nit: can you update the log message to make it cle
hirono
2016/09/14 00:54:41
Done.
| |
215 next_state_type = current_state_type; | 216 next_state_type = current_state_type; |
216 } else { | 217 } else { |
217 next_state_type = WINDOW_STATE_TYPE_PINNED; | 218 next_state_type = event->type() == WM_EVENT_PIN |
219 ? WINDOW_STATE_TYPE_PINNED | |
220 : WINDOW_STATE_TYPE_TRUSTED_PINNED; | |
218 } | 221 } |
219 break; | 222 break; |
220 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: | 223 case WM_EVENT_TOGGLE_MAXIMIZE_CAPTION: |
221 case WM_EVENT_TOGGLE_MAXIMIZE: | 224 case WM_EVENT_TOGGLE_MAXIMIZE: |
222 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: | 225 case WM_EVENT_TOGGLE_VERTICAL_MAXIMIZE: |
223 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: | 226 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: |
224 case WM_EVENT_TOGGLE_FULLSCREEN: | 227 case WM_EVENT_TOGGLE_FULLSCREEN: |
225 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: | 228 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: |
226 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: | 229 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: |
227 case WM_EVENT_CENTER: | 230 case WM_EVENT_CENTER: |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 CycleSnapDock(window_state, event->type()); | 378 CycleSnapDock(window_state, event->type()); |
376 return true; | 379 return true; |
377 case WM_EVENT_CENTER: | 380 case WM_EVENT_CENTER: |
378 CenterWindow(window_state); | 381 CenterWindow(window_state); |
379 return true; | 382 return true; |
380 case WM_EVENT_NORMAL: | 383 case WM_EVENT_NORMAL: |
381 case WM_EVENT_MAXIMIZE: | 384 case WM_EVENT_MAXIMIZE: |
382 case WM_EVENT_MINIMIZE: | 385 case WM_EVENT_MINIMIZE: |
383 case WM_EVENT_FULLSCREEN: | 386 case WM_EVENT_FULLSCREEN: |
384 case WM_EVENT_PIN: | 387 case WM_EVENT_PIN: |
388 case WM_EVENT_TRUSTED_PIN: | |
385 case WM_EVENT_SNAP_LEFT: | 389 case WM_EVENT_SNAP_LEFT: |
386 case WM_EVENT_SNAP_RIGHT: | 390 case WM_EVENT_SNAP_RIGHT: |
387 case WM_EVENT_SET_BOUNDS: | 391 case WM_EVENT_SET_BOUNDS: |
388 case WM_EVENT_SHOW_INACTIVE: | 392 case WM_EVENT_SHOW_INACTIVE: |
389 case WM_EVENT_DOCK: | 393 case WM_EVENT_DOCK: |
390 break; | 394 break; |
391 case WM_EVENT_ADDED_TO_WORKSPACE: | 395 case WM_EVENT_ADDED_TO_WORKSPACE: |
392 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: | 396 case WM_EVENT_WORKAREA_BOUNDS_CHANGED: |
393 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: | 397 case WM_EVENT_DISPLAY_BOUNDS_CHANGED: |
394 NOTREACHED() << "Workspace event should not reach here:" << event; | 398 NOTREACHED() << "Workspace event should not reach here:" << event; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: | 490 case WM_EVENT_TOGGLE_HORIZONTAL_MAXIMIZE: |
487 case WM_EVENT_TOGGLE_FULLSCREEN: | 491 case WM_EVENT_TOGGLE_FULLSCREEN: |
488 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: | 492 case WM_EVENT_CYCLE_SNAP_DOCK_LEFT: |
489 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: | 493 case WM_EVENT_CYCLE_SNAP_DOCK_RIGHT: |
490 case WM_EVENT_CENTER: | 494 case WM_EVENT_CENTER: |
491 case WM_EVENT_NORMAL: | 495 case WM_EVENT_NORMAL: |
492 case WM_EVENT_MAXIMIZE: | 496 case WM_EVENT_MAXIMIZE: |
493 case WM_EVENT_MINIMIZE: | 497 case WM_EVENT_MINIMIZE: |
494 case WM_EVENT_FULLSCREEN: | 498 case WM_EVENT_FULLSCREEN: |
495 case WM_EVENT_PIN: | 499 case WM_EVENT_PIN: |
500 case WM_EVENT_TRUSTED_PIN: | |
496 case WM_EVENT_SNAP_LEFT: | 501 case WM_EVENT_SNAP_LEFT: |
497 case WM_EVENT_SNAP_RIGHT: | 502 case WM_EVENT_SNAP_RIGHT: |
498 case WM_EVENT_SET_BOUNDS: | 503 case WM_EVENT_SET_BOUNDS: |
499 case WM_EVENT_SHOW_INACTIVE: | 504 case WM_EVENT_SHOW_INACTIVE: |
500 case WM_EVENT_DOCK: | 505 case WM_EVENT_DOCK: |
501 break; | 506 break; |
502 } | 507 } |
503 return false; | 508 return false; |
504 } | 509 } |
505 | 510 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 // Normal state should have no restore bounds unless it's | 584 // Normal state should have no restore bounds unless it's |
580 // unminimized. | 585 // unminimized. |
581 if (!restore_bounds_in_screen.IsEmpty()) | 586 if (!restore_bounds_in_screen.IsEmpty()) |
582 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); | 587 window_state->SetRestoreBoundsInScreen(restore_bounds_in_screen); |
583 else if (window_state->IsNormalStateType()) | 588 else if (window_state->IsNormalStateType()) |
584 window_state->ClearRestoreBounds(); | 589 window_state->ClearRestoreBounds(); |
585 } | 590 } |
586 window_state->NotifyPostStateTypeChange(previous_state_type); | 591 window_state->NotifyPostStateTypeChange(previous_state_type); |
587 | 592 |
588 if (next_state_type == WINDOW_STATE_TYPE_PINNED || | 593 if (next_state_type == WINDOW_STATE_TYPE_PINNED || |
589 previous_state_type == WINDOW_STATE_TYPE_PINNED) { | 594 previous_state_type == WINDOW_STATE_TYPE_PINNED || |
595 next_state_type == WINDOW_STATE_TYPE_TRUSTED_PINNED || | |
596 previous_state_type == WINDOW_STATE_TYPE_TRUSTED_PINNED) { | |
590 WmShell::Get()->SetPinnedWindow(window_state->window()); | 597 WmShell::Get()->SetPinnedWindow(window_state->window()); |
591 } | 598 } |
592 } | 599 } |
593 | 600 |
594 void DefaultState::ReenterToCurrentState( | 601 void DefaultState::ReenterToCurrentState( |
595 WindowState* window_state, | 602 WindowState* window_state, |
596 WindowState::State* state_in_previous_mode) { | 603 WindowState::State* state_in_previous_mode) { |
597 WindowStateType previous_state_type = state_in_previous_mode->GetType(); | 604 WindowStateType previous_state_type = state_in_previous_mode->GetType(); |
598 | 605 |
599 // A state change should not move a window into or out of full screen or | 606 // A state change should not move a window into or out of full screen or |
600 // pinned since these are "special mode" the user wanted to be in and | 607 // pinned since these are "special mode" the user wanted to be in and |
601 // should be respected as such. | 608 // should be respected as such. |
602 if (previous_state_type == wm::WINDOW_STATE_TYPE_FULLSCREEN || | 609 if (previous_state_type == wm::WINDOW_STATE_TYPE_FULLSCREEN || |
603 previous_state_type == wm::WINDOW_STATE_TYPE_PINNED) { | 610 previous_state_type == wm::WINDOW_STATE_TYPE_PINNED || |
611 previous_state_type == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED) { | |
604 state_type_ = previous_state_type; | 612 state_type_ = previous_state_type; |
605 } else if (state_type_ == wm::WINDOW_STATE_TYPE_FULLSCREEN || | 613 } else if (state_type_ == wm::WINDOW_STATE_TYPE_FULLSCREEN || |
606 state_type_ == wm::WINDOW_STATE_TYPE_PINNED) { | 614 state_type_ == wm::WINDOW_STATE_TYPE_PINNED || |
615 state_type_ == wm::WINDOW_STATE_TYPE_TRUSTED_PINNED) { | |
607 state_type_ = previous_state_type; | 616 state_type_ = previous_state_type; |
608 } | 617 } |
609 | 618 |
610 window_state->UpdateWindowShowStateFromStateType(); | 619 window_state->UpdateWindowShowStateFromStateType(); |
611 window_state->NotifyPreStateTypeChange(previous_state_type); | 620 window_state->NotifyPreStateTypeChange(previous_state_type); |
612 | 621 |
613 if ((state_type_ == wm::WINDOW_STATE_TYPE_NORMAL || | 622 if ((state_type_ == wm::WINDOW_STATE_TYPE_NORMAL || |
614 state_type_ == wm::WINDOW_STATE_TYPE_DEFAULT) && | 623 state_type_ == wm::WINDOW_STATE_TYPE_DEFAULT) && |
615 !stored_bounds_.IsEmpty()) { | 624 !stored_bounds_.IsEmpty()) { |
616 // Use the restore mechanism to set the bounds for | 625 // Use the restore mechanism to set the bounds for |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_in_parent, | 685 wm::AdjustBoundsToEnsureMinimumWindowVisibility(work_area_in_parent, |
677 &bounds_in_parent); | 686 &bounds_in_parent); |
678 break; | 687 break; |
679 } | 688 } |
680 case WINDOW_STATE_TYPE_MAXIMIZED: | 689 case WINDOW_STATE_TYPE_MAXIMIZED: |
681 bounds_in_parent = GetMaximizedWindowBoundsInParent(window); | 690 bounds_in_parent = GetMaximizedWindowBoundsInParent(window); |
682 break; | 691 break; |
683 | 692 |
684 case WINDOW_STATE_TYPE_FULLSCREEN: | 693 case WINDOW_STATE_TYPE_FULLSCREEN: |
685 case WINDOW_STATE_TYPE_PINNED: | 694 case WINDOW_STATE_TYPE_PINNED: |
695 case WINDOW_STATE_TYPE_TRUSTED_PINNED: | |
686 bounds_in_parent = GetDisplayBoundsInParent(window); | 696 bounds_in_parent = GetDisplayBoundsInParent(window); |
687 break; | 697 break; |
688 | 698 |
689 case WINDOW_STATE_TYPE_DOCKED_MINIMIZED: | 699 case WINDOW_STATE_TYPE_DOCKED_MINIMIZED: |
690 case WINDOW_STATE_TYPE_MINIMIZED: | 700 case WINDOW_STATE_TYPE_MINIMIZED: |
691 break; | 701 break; |
692 case WINDOW_STATE_TYPE_INACTIVE: | 702 case WINDOW_STATE_TYPE_INACTIVE: |
693 case WINDOW_STATE_TYPE_END: | 703 case WINDOW_STATE_TYPE_END: |
694 case WINDOW_STATE_TYPE_AUTO_POSITIONED: | 704 case WINDOW_STATE_TYPE_AUTO_POSITIONED: |
695 return; | 705 return; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); | 763 gfx::Rect center_in_parent = GetDisplayWorkAreaBoundsInParent(window); |
754 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); | 764 center_in_parent.ClampToCenteredSize(window->GetBounds().size()); |
755 window_state->SetBoundsDirectAnimated(center_in_parent); | 765 window_state->SetBoundsDirectAnimated(center_in_parent); |
756 } | 766 } |
757 // Centering window is treated as if a user moved and resized the window. | 767 // Centering window is treated as if a user moved and resized the window. |
758 window_state->set_bounds_changed_by_user(true); | 768 window_state->set_bounds_changed_by_user(true); |
759 } | 769 } |
760 | 770 |
761 } // namespace wm | 771 } // namespace wm |
762 } // namespace ash | 772 } // namespace ash |
OLD | NEW |