| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ASH_WM_SCREEN_PINNING_CONTROLLER_H_ | 5 #ifndef ASH_WM_SCREEN_PINNING_CONTROLLER_H_ |
| 6 #define ASH_WM_SCREEN_PINNING_CONTROLLER_H_ | 6 #define ASH_WM_SCREEN_PINNING_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 | 15 |
| 16 class WindowDimmer; |
| 16 class WindowTreeHostManager; | 17 class WindowTreeHostManager; |
| 17 class WmWindow; | 18 class WmWindow; |
| 18 | 19 |
| 20 template <typename UserData> |
| 21 class WmWindowUserData; |
| 22 |
| 19 // Handles pinned state. | 23 // Handles pinned state. |
| 20 class ScreenPinningController : public WindowTreeHostManager::Observer { | 24 class ScreenPinningController : public WindowTreeHostManager::Observer { |
| 21 public: | 25 public: |
| 22 explicit ScreenPinningController( | 26 explicit ScreenPinningController( |
| 23 WindowTreeHostManager* window_tree_host_manager); | 27 WindowTreeHostManager* window_tree_host_manager); |
| 24 ~ScreenPinningController() override; | 28 ~ScreenPinningController() override; |
| 25 | 29 |
| 26 // Sets a pinned window. It is not allowed to call this when there already | 30 // Sets a pinned window. It is not allowed to call this when there already |
| 27 // is a pinned window. | 31 // is a pinned window. |
| 28 void SetPinnedWindow(WmWindow* pinned_window); | 32 void SetPinnedWindow(WmWindow* pinned_window); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 | 51 |
| 48 // Called when a new window is added to a system modal container. | 52 // Called when a new window is added to a system modal container. |
| 49 void OnWindowAddedToSystemModalContainer(WmWindow* new_window); | 53 void OnWindowAddedToSystemModalContainer(WmWindow* new_window); |
| 50 | 54 |
| 51 // Called when a window will be removed from a system modal container. | 55 // Called when a window will be removed from a system modal container. |
| 52 void OnWillRemoveWindowFromSystemModalContainer(WmWindow* window); | 56 void OnWillRemoveWindowFromSystemModalContainer(WmWindow* window); |
| 53 | 57 |
| 54 // Called when a window stacking is changed in a system modal container. | 58 // Called when a window stacking is changed in a system modal container. |
| 55 void OnSystemModalContainerWindowStackingChanged(WmWindow* window); | 59 void OnSystemModalContainerWindowStackingChanged(WmWindow* window); |
| 56 | 60 |
| 57 // Called when a dim window in the system modal container is destroying. | |
| 58 void OnDimWindowDestroying(WmWindow* window); | |
| 59 | |
| 60 private: | 61 private: |
| 61 class PinnedContainerWindowObserver; | 62 class PinnedContainerWindowObserver; |
| 62 class PinnedContainerChildWindowObserver; | 63 class PinnedContainerChildWindowObserver; |
| 63 class SystemModalContainerWindowObserver; | 64 class SystemModalContainerWindowObserver; |
| 64 class SystemModalContainerChildWindowObserver; | 65 class SystemModalContainerChildWindowObserver; |
| 65 class DimWindowObserver; | |
| 66 | 66 |
| 67 // Keeps the pinned window on top of the siblings. | 67 // Keeps the pinned window on top of the siblings. |
| 68 void KeepPinnedWindowOnTop(); | 68 void KeepPinnedWindowOnTop(); |
| 69 | 69 |
| 70 // Keeps the dim window at bottom of the container. | 70 // Keeps the dim window at bottom of the container. |
| 71 void KeepDimWindowAtBottom(WmWindow* container); | 71 void KeepDimWindowAtBottom(WmWindow* container); |
| 72 | 72 |
| 73 // Creates a WindowDimmer for |container| and places it in |window_dimmers_|. |
| 74 // Returns the window from WindowDimmer. |
| 75 WmWindow* CreateWindowDimmer(WmWindow* container); |
| 76 |
| 73 // WindowTreeHostManager::Observer: | 77 // WindowTreeHostManager::Observer: |
| 74 void OnDisplayConfigurationChanged() override; | 78 void OnDisplayConfigurationChanged() override; |
| 75 | 79 |
| 76 // Pinned window should be on top in the parent window. | 80 // Pinned window should be on top in the parent window. |
| 77 WmWindow* pinned_window_ = nullptr; | 81 WmWindow* pinned_window_ = nullptr; |
| 78 | 82 |
| 79 // Dim background window just behind of the pinned window. | 83 // Owns the WindowDimmers. There is one WindowDimmer for the parent of |
| 80 // Not owned. The parent has its ownership. | 84 // |pinned_window_| and one for each display other than the display |
| 81 WmWindow* background_window_ = nullptr; | 85 // |pinned_window_| is on. |
| 82 | 86 std::unique_ptr<WmWindowUserData<WindowDimmer>> window_dimmers_; |
| 83 // In pinned mode, all displays other than the one where pinned_window_ is. | |
| 84 // Similar to background_window_, not owned. | |
| 85 std::vector<WmWindow*> dim_windows_; | |
| 86 | 87 |
| 87 // Set true only when restacking done by this controller. | 88 // Set true only when restacking done by this controller. |
| 88 bool in_restacking_ = false; | 89 bool in_restacking_ = false; |
| 89 | 90 |
| 90 // Keep references to remove this as a observer. | 91 // Keep references to remove this as a observer. |
| 91 // While this controller is alive, it needs to be ensured that the instances | 92 // While this controller is alive, it needs to be ensured that the instances |
| 92 // refered from the pointers should be alive. | 93 // refered from the pointers should be alive. |
| 93 WindowTreeHostManager* window_tree_host_manager_; | 94 WindowTreeHostManager* window_tree_host_manager_; |
| 94 | 95 |
| 95 // Window observers to translate events for the window to this controller. | 96 // Window observers to translate events for the window to this controller. |
| 96 std::unique_ptr<PinnedContainerWindowObserver> | 97 std::unique_ptr<PinnedContainerWindowObserver> |
| 97 pinned_container_window_observer_; | 98 pinned_container_window_observer_; |
| 98 std::unique_ptr<PinnedContainerChildWindowObserver> | 99 std::unique_ptr<PinnedContainerChildWindowObserver> |
| 99 pinned_container_child_window_observer_; | 100 pinned_container_child_window_observer_; |
| 100 std::unique_ptr<SystemModalContainerWindowObserver> | 101 std::unique_ptr<SystemModalContainerWindowObserver> |
| 101 system_modal_container_window_observer_; | 102 system_modal_container_window_observer_; |
| 102 std::unique_ptr<SystemModalContainerChildWindowObserver> | 103 std::unique_ptr<SystemModalContainerChildWindowObserver> |
| 103 system_modal_container_child_window_observer_; | 104 system_modal_container_child_window_observer_; |
| 104 std::unique_ptr<DimWindowObserver> dim_window_observer_; | |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(ScreenPinningController); | 106 DISALLOW_COPY_AND_ASSIGN(ScreenPinningController); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace ash | 109 } // namespace ash |
| 110 | 110 |
| 111 #endif // ASH_WM_SCREEN_PINNING_CONTROLLER_H_ | 111 #endif // ASH_WM_SCREEN_PINNING_CONTROLLER_H_ |
| OLD | NEW |