Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / wm / maximize_mode / maximize_mode_window_manager.h
blob08146210bb43770cb64efa87fd4bea8c10b1912e
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 virtual ~MaximizeModeWindowManager();
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 virtual void OnOverviewModeStarting() OVERRIDE;
56 virtual void OnOverviewModeEnding() OVERRIDE;
58 // Overridden from WindowObserver:
59 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
60 virtual void OnWindowAdded(aura::Window* window) OVERRIDE;
61 virtual void OnWindowBoundsChanged(aura::Window* window,
62 const gfx::Rect& old_bounds,
63 const gfx::Rect& new_bounds) OVERRIDE;
65 // gfx::DisplayObserver overrides:
66 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
67 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
68 virtual void OnDisplayMetricsChanged(const gfx::Display& display,
69 uint32_t metrics) OVERRIDE;
71 // ui::EventHandler override:
72 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
74 protected:
75 friend class MaximizeModeController;
77 // The object should only be created by the ash::Shell.
78 MaximizeModeWindowManager();
80 private:
81 typedef std::map<aura::Window*, MaximizeModeWindowState*> WindowToState;
83 // Maximize all windows and restore their current state.
84 void MaximizeAllWindows();
86 // Restore all windows to their previous state.
87 void RestoreAllWindows();
89 // If the given window should be handled by us, this function will maximize it
90 // and add it to the list of known windows (remembering the initial show
91 // state).
92 // Note: If the given window cannot be handled by us the function will return
93 // immediately.
94 void MaximizeAndTrackWindow(aura::Window* window);
96 // Remove a window from our tracking list.
97 void ForgetWindow(aura::Window* window);
99 // Returns true when the given window should be modified in any way by us.
100 bool ShouldHandleWindow(aura::Window* window);
102 // Add window creation observers to track creation of new windows.
103 void AddWindowCreationObservers();
105 // Remove Window creation observers.
106 void RemoveWindowCreationObservers();
108 // Change the internal state (e.g. observers) when the display configuration
109 // changes.
110 void DisplayConfigurationChanged();
112 // Returns true when the |window| is a container window.
113 bool IsContainerWindow(aura::Window* window);
115 // Add a backdrop behind the currently active window on each desktop.
116 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
118 // Every window which got touched by our window manager gets added here.
119 WindowToState window_state_map_;
121 // All container windows which have to be tracked.
122 std::set<aura::Window*> observed_container_windows_;
124 // True if all backdrops are hidden.
125 bool backdrops_hidden_;
127 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager);
130 } // namespace ash
132 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_