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_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_ |
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_ | 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_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 { |
| 21 class Window; |
| 22 } |
| 23 |
20 namespace ash { | 24 namespace ash { |
21 class MaximizeModeController; | 25 class MaximizeModeController; |
22 class MaximizeModeWindowState; | 26 class MaximizeModeWindowState; |
23 | 27 |
24 namespace wm { | 28 namespace wm { |
25 class MaximizeModeEventHandler; | 29 class MaximizeModeEventHandler; |
26 } | 30 } |
27 | 31 |
28 // A window manager which - when created - will force all windows into maximized | 32 // A window manager which - when created - will force all windows into maximized |
29 // mode. Exception are panels and windows which cannot be maximized. | 33 // mode. Exception are panels and windows which cannot be maximized. |
30 // 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 |
31 // 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. |
32 // 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 |
33 // original state. | 37 // original state. |
34 class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver, | 38 class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver, |
35 public display::DisplayObserver, | 39 public display::DisplayObserver, |
36 public ShellObserver { | 40 public ShellObserver { |
37 public: | 41 public: |
38 // This should only be deleted by the creator (ash::Shell). | 42 // This should only be deleted by the creator (ash::Shell). |
39 ~MaximizeModeWindowManager() override; | 43 ~MaximizeModeWindowManager() override; |
40 | 44 |
41 // Returns the number of maximized & tracked windows by this manager. | 45 // Returns the number of maximized & tracked windows by this manager. |
42 int GetNumberOfManagedWindows(); | 46 int GetNumberOfManagedWindows(); |
43 | 47 |
44 // 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 |
45 // 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 |
46 // changes. | 50 // changes. |
47 // 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. |
48 void AddWindow(WmWindow* window); | 52 void AddWindow(aura::Window* window); |
49 | 53 |
50 // Called from a window state object when it gets destroyed. | 54 // Called from a window state object when it gets destroyed. |
51 void WindowStateDestroyed(WmWindow* window); | 55 void WindowStateDestroyed(aura::Window* window); |
52 | 56 |
53 // ShellObserver overrides: | 57 // ShellObserver overrides: |
54 void OnOverviewModeStarting() override; | 58 void OnOverviewModeStarting() override; |
55 void OnOverviewModeEnded() override; | 59 void OnOverviewModeEnded() override; |
56 | 60 |
57 // Overridden from WindowObserver: | 61 // Overridden from WindowObserver: |
58 void OnWindowDestroying(aura::Window* window) override; | 62 void OnWindowDestroying(aura::Window* window) override; |
59 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; | 63 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
60 void OnWindowPropertyChanged(aura::Window* window, | 64 void OnWindowPropertyChanged(aura::Window* window, |
61 const void* key, | 65 const void* key, |
(...skipping 12 matching lines...) Expand all Loading... |
74 // Tell all managing windows not to handle WM events. | 78 // Tell all managing windows not to handle WM events. |
75 void SetIgnoreWmEventsForExit(); | 79 void SetIgnoreWmEventsForExit(); |
76 | 80 |
77 protected: | 81 protected: |
78 friend class MaximizeModeController; | 82 friend class MaximizeModeController; |
79 | 83 |
80 // The object should only be created by the ash::Shell. | 84 // The object should only be created by the ash::Shell. |
81 MaximizeModeWindowManager(); | 85 MaximizeModeWindowManager(); |
82 | 86 |
83 private: | 87 private: |
84 using WindowToState = std::map<WmWindow*, MaximizeModeWindowState*>; | 88 using WindowToState = std::map<aura::Window*, MaximizeModeWindowState*>; |
85 | 89 |
86 // Maximize all windows and restore their current state. | 90 // Maximize all windows and restore their current state. |
87 void MaximizeAllWindows(); | 91 void MaximizeAllWindows(); |
88 | 92 |
89 // Restore all windows to their previous state. | 93 // Restore all windows to their previous state. |
90 void RestoreAllWindows(); | 94 void RestoreAllWindows(); |
91 | 95 |
92 // 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 |
93 // false bounds will be updated as they may be stale. | 97 // false bounds will be updated as they may be stale. |
94 void SetDeferBoundsUpdates(bool defer_bounds_updates); | 98 void SetDeferBoundsUpdates(bool defer_bounds_updates); |
95 | 99 |
96 // If the given window should be handled by us, this function will maximize it | 100 // If the given window should be handled by us, this function will maximize it |
97 // and add it to the list of known windows (remembering the initial show | 101 // and add it to the list of known windows (remembering the initial show |
98 // state). | 102 // state). |
99 // Note: If the given window cannot be handled by us the function will return | 103 // Note: If the given window cannot be handled by us the function will return |
100 // immediately. | 104 // immediately. |
101 void MaximizeAndTrackWindow(WmWindow* window); | 105 void MaximizeAndTrackWindow(aura::Window* window); |
102 | 106 |
103 // Remove a window from our tracking list. | 107 // Remove a window from our tracking list. |
104 void ForgetWindow(WmWindow* window); | 108 void ForgetWindow(aura::Window* window); |
105 | 109 |
106 // Returns true when the given window should be modified in any way by us. | 110 // Returns true when the given window should be modified in any way by us. |
107 bool ShouldHandleWindow(WmWindow* window); | 111 bool ShouldHandleWindow(aura::Window* window); |
108 | 112 |
109 // Add window creation observers to track creation of new windows. | 113 // Add window creation observers to track creation of new windows. |
110 void AddWindowCreationObservers(); | 114 void AddWindowCreationObservers(); |
111 | 115 |
112 // Remove Window creation observers. | 116 // Remove Window creation observers. |
113 void RemoveWindowCreationObservers(); | 117 void RemoveWindowCreationObservers(); |
114 | 118 |
115 // Change the internal state (e.g. observers) when the display configuration | 119 // Change the internal state (e.g. observers) when the display configuration |
116 // changes. | 120 // changes. |
117 void DisplayConfigurationChanged(); | 121 void DisplayConfigurationChanged(); |
(...skipping 14 matching lines...) Expand all Loading... |
132 std::unordered_set<aura::Window*> added_windows_; | 136 std::unordered_set<aura::Window*> added_windows_; |
133 | 137 |
134 std::unique_ptr<wm::MaximizeModeEventHandler> event_handler_; | 138 std::unique_ptr<wm::MaximizeModeEventHandler> event_handler_; |
135 | 139 |
136 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager); | 140 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager); |
137 }; | 141 }; |
138 | 142 |
139 } // namespace ash | 143 } // namespace ash |
140 | 144 |
141 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_ | 145 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_ |
OLD | NEW |