OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_WM_SCREEN_PINNING_CONTROLLER_H_ |
| 6 #define ASH_WM_SCREEN_PINNING_CONTROLLER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "ash/display/window_tree_host_manager.h" |
| 12 #include "base/macros.h" |
| 13 |
| 14 namespace ash { |
| 15 |
| 16 class WindowTreeHostManager; |
| 17 class WmShellCommon; |
| 18 class WmWindow; |
| 19 |
| 20 // Handles pinned state. |
| 21 class ScreenPinningController : public WindowTreeHostManager::Observer { |
| 22 public: |
| 23 ScreenPinningController(WmShellCommon* wm_shell_common, |
| 24 WindowTreeHostManager* window_tree_host_manager); |
| 25 ~ScreenPinningController() override; |
| 26 |
| 27 // Sets a pinned window. It is not allowed to call this when there already |
| 28 // is a pinned window. |
| 29 void SetPinnedWindow(WmWindow* pinned_window); |
| 30 |
| 31 // Returns true if in pinned mode, otherwise false. |
| 32 bool IsPinned() const; |
| 33 |
| 34 // Called when a new window is added to the container which has the pinned |
| 35 // window. |
| 36 void OnWindowAddedToPinnedContainer(WmWindow* new_window); |
| 37 |
| 38 // Called when a window will be removed from the container which has the |
| 39 // pinned window. |
| 40 void OnWillRemoveWindowFromPinnedContainer(WmWindow* window); |
| 41 |
| 42 // Called when a window stacking is changed in the container which has the |
| 43 // pinned window. |
| 44 void OnPinnedContainerWindowStackingChanged(WmWindow* window); |
| 45 |
| 46 // Called when a new window is added to a system modal container. |
| 47 void OnWindowAddedToSystemModalContainer(WmWindow* new_window); |
| 48 |
| 49 // Called when a window will be removed from a system modal container. |
| 50 void OnWillRemoveWindowFromSystemModalContainer(WmWindow* window); |
| 51 |
| 52 // Called when a window stacking is changed in a system modal container. |
| 53 void OnSystemModalContainerWindowStackingChanged(WmWindow* window); |
| 54 |
| 55 // Called when a dim window in the system modal container is destroying. |
| 56 void OnDimWindowDestroying(WmWindow* window); |
| 57 |
| 58 private: |
| 59 class PinnedContainerWindowObserver; |
| 60 class PinnedContainerChildWindowObserver; |
| 61 class SystemModalContainerWindowObserver; |
| 62 class SystemModalContainerChildWindowObserver; |
| 63 class DimWindowObserver; |
| 64 |
| 65 // Keeps the pinned window on top of the siblings. |
| 66 void KeepPinnedWindowOnTop(); |
| 67 |
| 68 // Keeps the dim window at bottom of the container. |
| 69 void KeepDimWindowAtBottom(WmWindow* container); |
| 70 |
| 71 // WindowTreeHostManager::Observer: |
| 72 void OnDisplayConfigurationChanged() override; |
| 73 |
| 74 // Pinned window should be on top in the parent window. |
| 75 WmWindow* pinned_window_ = nullptr; |
| 76 |
| 77 // Dim background window just behind of the pinned window. |
| 78 // Not owned. The parent has its ownership. |
| 79 WmWindow* background_window_ = nullptr; |
| 80 |
| 81 // In pinned mode, all displays other than the one where pinned_window_ is. |
| 82 // Similar to background_window_, not owned. |
| 83 std::vector<WmWindow*> dim_windows_; |
| 84 |
| 85 // Set true only when restacking done by this controller. |
| 86 bool in_restacking_ = false; |
| 87 |
| 88 // For OnPinnedStateChanged event notification. |
| 89 // While this controller is alive, it needs to be ensured that the instances |
| 90 // refered from the pointers should be alive. |
| 91 WmShellCommon* wm_shell_common_; |
| 92 |
| 93 // Keep references to remove this as a observer. |
| 94 // While this controller is alive, it needs to be ensured that the instances |
| 95 // refered from the pointers should be alive. |
| 96 WindowTreeHostManager* window_tree_host_manager_; |
| 97 |
| 98 // Window observers to translate events for the window to this controller. |
| 99 std::unique_ptr<PinnedContainerWindowObserver> |
| 100 pinned_container_window_observer_; |
| 101 std::unique_ptr<PinnedContainerChildWindowObserver> |
| 102 pinned_container_child_window_observer_; |
| 103 std::unique_ptr<SystemModalContainerWindowObserver> |
| 104 system_modal_container_window_observer_; |
| 105 std::unique_ptr<SystemModalContainerChildWindowObserver> |
| 106 system_modal_container_child_window_observer_; |
| 107 std::unique_ptr<DimWindowObserver> dim_window_observer_; |
| 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(ScreenPinningController); |
| 110 }; |
| 111 |
| 112 } // namespace ash |
| 113 |
| 114 #endif // ASH_WM_SCREEN_PINNING_CONTROLLER_H_ |
OLD | NEW |