Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Side by Side Diff: ash/common/wm/maximize_mode/maximize_mode_window_manager.h

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_COMMON_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
6 #define ASH_COMMON_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <unordered_set>
12
13 #include "ash/ash_export.h"
14 #include "ash/common/shell_observer.h"
15 #include "ash/common/wm/window_state.h"
16 #include "base/macros.h"
17 #include "ui/aura/window_observer.h"
18 #include "ui/display/display_observer.h"
19
20 namespace ash {
21 class MaximizeModeController;
22 class MaximizeModeWindowState;
23
24 namespace wm {
25 class MaximizeModeEventHandler;
26 }
27
28 // A window manager which - when created - will force all windows into maximized
29 // mode. Exception are panels and windows which cannot be maximized.
30 // 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.
32 // With the destruction of the manager all windows will be restored to their
33 // original state.
34 class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
35 public display::DisplayObserver,
36 public ShellObserver {
37 public:
38 // This should only be deleted by the creator (ash::Shell).
39 ~MaximizeModeWindowManager() override;
40
41 // Returns the number of maximized & tracked windows by this manager.
42 int GetNumberOfManagedWindows();
43
44 // 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
46 // changes.
47 // The call gets ignored if the window was already or should not be handled.
48 void AddWindow(WmWindow* window);
49
50 // Called from a window state object when it gets destroyed.
51 void WindowStateDestroyed(WmWindow* window);
52
53 // ShellObserver overrides:
54 void OnOverviewModeStarting() override;
55 void OnOverviewModeEnded() override;
56
57 // Overridden from WindowObserver:
58 void OnWindowDestroying(aura::Window* window) override;
59 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override;
60 void OnWindowPropertyChanged(aura::Window* window,
61 const void* key,
62 intptr_t old) override;
63 void OnWindowBoundsChanged(aura::Window* window,
64 const gfx::Rect& old_bounds,
65 const gfx::Rect& new_bounds) override;
66 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
67
68 // display::DisplayObserver overrides:
69 void OnDisplayAdded(const display::Display& display) override;
70 void OnDisplayRemoved(const display::Display& display) override;
71 void OnDisplayMetricsChanged(const display::Display& display,
72 uint32_t metrics) override;
73
74 protected:
75 friend class MaximizeModeController;
76
77 // The object should only be created by the ash::Shell.
78 MaximizeModeWindowManager();
79
80 private:
81 using WindowToState = std::map<WmWindow*, MaximizeModeWindowState*>;
82
83 // Maximize all windows and restore their current state.
84 void MaximizeAllWindows();
85
86 // Restore all windows to their previous state.
87 void RestoreAllWindows();
88
89 // Set whether to defer bounds updates on all tracked windows. When set to
90 // false bounds will be updated as they may be stale.
91 void SetDeferBoundsUpdates(bool defer_bounds_updates);
92
93 // If the given window should be handled by us, this function will maximize it
94 // and add it to the list of known windows (remembering the initial show
95 // state).
96 // Note: If the given window cannot be handled by us the function will return
97 // immediately.
98 void MaximizeAndTrackWindow(WmWindow* window);
99
100 // Remove a window from our tracking list.
101 void ForgetWindow(WmWindow* window);
102
103 // Returns true when the given window should be modified in any way by us.
104 bool ShouldHandleWindow(WmWindow* window);
105
106 // Add window creation observers to track creation of new windows.
107 void AddWindowCreationObservers();
108
109 // Remove Window creation observers.
110 void RemoveWindowCreationObservers();
111
112 // Change the internal state (e.g. observers) when the display configuration
113 // changes.
114 void DisplayConfigurationChanged();
115
116 // Returns true when the |window| is a container window.
117 bool IsContainerWindow(aura::Window* window);
118
119 // Add a backdrop behind the currently active window on each desktop.
120 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
121
122 // Every window which got touched by our window manager gets added here.
123 WindowToState window_state_map_;
124
125 // All container windows which have to be tracked.
126 std::unordered_set<aura::Window*> observed_container_windows_;
127
128 // Windows added to the container, but not yet shown.
129 std::unordered_set<aura::Window*> added_windows_;
130
131 // True if all backdrops are hidden.
132 bool backdrops_hidden_;
133
134 std::unique_ptr<wm::MaximizeModeEventHandler> event_handler_;
135
136 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager);
137 };
138
139 } // namespace ash
140
141 #endif // ASH_COMMON_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698