Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / ash / wm / maximize_mode / maximize_mode_window_manager.h
blobbe64c6d4d9e40ff9a74c8bd6889e20725f84008c
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.
5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
8 #include <map>
9 #include <set>
11 #include "ash/ash_export.h"
12 #include "ash/shell_observer.h"
13 #include "ash/wm/window_state.h"
14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h"
16 #include "ui/aura/window_observer.h"
17 #include "ui/events/event_handler.h"
18 #include "ui/gfx/display_observer.h"
20 namespace ui {
21 class TouchEvent;
24 namespace ash {
25 class MaximizeModeController;
26 class MaximizeModeWindowState;
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 gfx::DisplayObserver,
36 public ShellObserver,
37 public ui::EventHandler {
38 public:
39 // This should only be deleted by the creator (ash::Shell).
40 ~MaximizeModeWindowManager() override;
42 // Returns the number of maximized & tracked windows by this manager.
43 int GetNumberOfManagedWindows();
45 // Adds a window which needs to be maximized. This is used by other window
46 // managers for windows which needs to get tracked due to (upcoming) state
47 // changes.
48 // The call gets ignored if the window was already or should not be handled.
49 void AddWindow(aura::Window* window);
51 // Called from a window state object when it gets destroyed.
52 void WindowStateDestroyed(aura::Window* window);
54 // ShellObserver overrides:
55 void OnOverviewModeStarting() override;
56 void OnOverviewModeEnded() override;
58 // Overridden from WindowObserver:
59 void OnWindowDestroying(aura::Window* window) override;
60 void OnWindowAdded(aura::Window* window) override;
61 void OnWindowPropertyChanged(aura::Window* window,
62 const void* key,
63 intptr_t old) override;
64 void OnWindowBoundsChanged(aura::Window* window,
65 const gfx::Rect& old_bounds,
66 const gfx::Rect& new_bounds) override;
68 // gfx::DisplayObserver overrides:
69 void OnDisplayAdded(const gfx::Display& display) override;
70 void OnDisplayRemoved(const gfx::Display& display) override;
71 void OnDisplayMetricsChanged(const gfx::Display& display,
72 uint32_t metrics) override;
74 // ui::EventHandler override:
75 void OnTouchEvent(ui::TouchEvent* event) override;
77 protected:
78 friend class MaximizeModeController;
80 // The object should only be created by the ash::Shell.
81 MaximizeModeWindowManager();
83 private:
84 typedef std::map<aura::Window*, MaximizeModeWindowState*> WindowToState;
86 // Maximize all windows and restore their current state.
87 void MaximizeAllWindows();
89 // Restore all windows to their previous state.
90 void RestoreAllWindows();
92 // Set whether to defer bounds updates on all tracked windows. When set to
93 // false bounds will be updated as they may be stale.
94 void SetDeferBoundsUpdates(bool defer_bounds_updates);
96 // 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
98 // state).
99 // Note: If the given window cannot be handled by us the function will return
100 // immediately.
101 void MaximizeAndTrackWindow(aura::Window* window);
103 // Remove a window from our tracking list.
104 void ForgetWindow(aura::Window* window);
106 // Returns true when the given window should be modified in any way by us.
107 bool ShouldHandleWindow(aura::Window* window);
109 // Add window creation observers to track creation of new windows.
110 void AddWindowCreationObservers();
112 // Remove Window creation observers.
113 void RemoveWindowCreationObservers();
115 // Change the internal state (e.g. observers) when the display configuration
116 // changes.
117 void DisplayConfigurationChanged();
119 // Returns true when the |window| is a container window.
120 bool IsContainerWindow(aura::Window* window);
122 // Add a backdrop behind the currently active window on each desktop.
123 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
125 // Every window which got touched by our window manager gets added here.
126 WindowToState window_state_map_;
128 // All container windows which have to be tracked.
129 std::set<aura::Window*> observed_container_windows_;
131 // True if all backdrops are hidden.
132 bool backdrops_hidden_;
134 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager);
137 } // namespace ash
139 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_