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 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_ | 5 #ifndef ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_MANAGER_H_ |
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_ | 6 #define ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <unordered_set> | 11 #include <unordered_set> |
12 | 12 |
13 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
14 #include "ash/shell_observer.h" | 14 #include "ash/shell_observer.h" |
15 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
18 #include "ui/display/display_observer.h" | 18 #include "ui/display/display_observer.h" |
19 | 19 |
20 namespace aura { | 20 namespace aura { |
21 class Window; | 21 class Window; |
22 } | 22 } |
23 | 23 |
24 namespace ash { | 24 namespace ash { |
25 class MaximizeModeController; | 25 class TabletModeController; |
26 class MaximizeModeWindowState; | 26 class TabletModeWindowState; |
27 | 27 |
28 namespace wm { | 28 namespace wm { |
29 class MaximizeModeEventHandler; | 29 class TabletModeEventHandler; |
30 } | 30 } |
31 | 31 |
32 // A window manager which - when created - will force all windows into maximized | 32 // A window manager which - when created - will force all windows into tablet |
33 // mode. Exception are panels and windows which cannot be maximized. | 33 // mode. Exception are panels and windows which cannot be maximized. |
34 // Windows which cannot be maximized / resized are centered with a layer placed | 34 // Windows which cannot be maximized / resized are centered with a layer placed |
35 // behind the window so that no other windows are visible and/or obscured. | 35 // behind the window so that no other windows are visible and/or obscured. |
36 // With the destruction of the manager all windows will be restored to their | 36 // With the destruction of the manager all windows will be restored to their |
37 // original state. | 37 // original state. |
38 class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver, | 38 class ASH_EXPORT TabletModeWindowManager : public aura::WindowObserver, |
39 public display::DisplayObserver, | 39 public display::DisplayObserver, |
40 public ShellObserver { | 40 public ShellObserver { |
41 public: | 41 public: |
42 // This should only be deleted by the creator (ash::Shell). | 42 // This should only be deleted by the creator (ash::Shell). |
43 ~MaximizeModeWindowManager() override; | 43 ~TabletModeWindowManager() override; |
44 | 44 |
45 // Returns the number of maximized & tracked windows by this manager. | 45 // Returns the number of maximized & tracked windows by this manager. |
46 int GetNumberOfManagedWindows(); | 46 int GetNumberOfManagedWindows(); |
47 | 47 |
48 // Adds a window which needs to be maximized. This is used by other window | 48 // Adds a window which needs to be maximized. This is used by other window |
49 // managers for windows which needs to get tracked due to (upcoming) state | 49 // managers for windows which needs to get tracked due to (upcoming) state |
50 // changes. | 50 // changes. |
51 // The call gets ignored if the window was already or should not be handled. | 51 // The call gets ignored if the window was already or should not be handled. |
52 void AddWindow(aura::Window* window); | 52 void AddWindow(aura::Window* window); |
53 | 53 |
(...skipping 18 matching lines...) Expand all Loading... |
72 // display::DisplayObserver overrides: | 72 // display::DisplayObserver overrides: |
73 void OnDisplayAdded(const display::Display& display) override; | 73 void OnDisplayAdded(const display::Display& display) override; |
74 void OnDisplayRemoved(const display::Display& display) override; | 74 void OnDisplayRemoved(const display::Display& display) override; |
75 void OnDisplayMetricsChanged(const display::Display& display, | 75 void OnDisplayMetricsChanged(const display::Display& display, |
76 uint32_t metrics) override; | 76 uint32_t metrics) override; |
77 | 77 |
78 // Tell all managing windows not to handle WM events. | 78 // Tell all managing windows not to handle WM events. |
79 void SetIgnoreWmEventsForExit(); | 79 void SetIgnoreWmEventsForExit(); |
80 | 80 |
81 protected: | 81 protected: |
82 friend class MaximizeModeController; | 82 friend class TabletModeController; |
83 | 83 |
84 // The object should only be created by the ash::Shell. | 84 // The object should only be created by the ash::Shell. |
85 MaximizeModeWindowManager(); | 85 TabletModeWindowManager(); |
86 | 86 |
87 private: | 87 private: |
88 using WindowToState = std::map<aura::Window*, MaximizeModeWindowState*>; | 88 using WindowToState = std::map<aura::Window*, TabletModeWindowState*>; |
89 | 89 |
90 // Maximize all windows and restore their current state. | 90 // Maximize all windows and restore their current state. |
91 void MaximizeAllWindows(); | 91 void MaximizeAllWindows(); |
92 | 92 |
93 // Restore all windows to their previous state. | 93 // Restore all windows to their previous state. |
94 void RestoreAllWindows(); | 94 void RestoreAllWindows(); |
95 | 95 |
96 // Set whether to defer bounds updates on all tracked windows. When set to | 96 // Set whether to defer bounds updates on all tracked windows. When set to |
97 // false bounds will be updated as they may be stale. | 97 // false bounds will be updated as they may be stale. |
98 void SetDeferBoundsUpdates(bool defer_bounds_updates); | 98 void SetDeferBoundsUpdates(bool defer_bounds_updates); |
(...skipping 29 matching lines...) Expand all Loading... |
128 | 128 |
129 // Every window which got touched by our window manager gets added here. | 129 // Every window which got touched by our window manager gets added here. |
130 WindowToState window_state_map_; | 130 WindowToState window_state_map_; |
131 | 131 |
132 // All container windows which have to be tracked. | 132 // All container windows which have to be tracked. |
133 std::unordered_set<aura::Window*> observed_container_windows_; | 133 std::unordered_set<aura::Window*> observed_container_windows_; |
134 | 134 |
135 // Windows added to the container, but not yet shown. | 135 // Windows added to the container, but not yet shown. |
136 std::unordered_set<aura::Window*> added_windows_; | 136 std::unordered_set<aura::Window*> added_windows_; |
137 | 137 |
138 std::unique_ptr<wm::MaximizeModeEventHandler> event_handler_; | 138 std::unique_ptr<wm::TabletModeEventHandler> event_handler_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager); | 140 DISALLOW_COPY_AND_ASSIGN(TabletModeWindowManager); |
141 }; | 141 }; |
142 | 142 |
143 } // namespace ash | 143 } // namespace ash |
144 | 144 |
145 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_ | 145 #endif // ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_MANAGER_H_ |
OLD | NEW |