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_
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"
25 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
34 class ASH_EXPORT MaximizeModeWindowManager
: public aura::WindowObserver
,
35 public gfx::DisplayObserver
,
37 public ui::EventHandler
{
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 // Called from a window state object when it gets destroyed.
46 void WindowStateDestroyed(aura::Window
* window
);
48 // ShellObserver overrides:
49 virtual void OnOverviewModeStarting() OVERRIDE
;
50 virtual void OnOverviewModeEnding() OVERRIDE
;
52 // Overridden from WindowObserver:
53 virtual void OnWindowDestroying(aura::Window
* window
) OVERRIDE
;
54 virtual void OnWindowAdded(aura::Window
* window
) OVERRIDE
;
55 virtual void OnWindowBoundsChanged(aura::Window
* window
,
56 const gfx::Rect
& old_bounds
,
57 const gfx::Rect
& new_bounds
) OVERRIDE
;
59 // aura::DisplayObserver overrides:
60 virtual void OnDisplayBoundsChanged(
61 const gfx::Display
& display
) OVERRIDE
;
62 virtual void OnDisplayAdded(const gfx::Display
& display
) OVERRIDE
;
63 virtual void OnDisplayRemoved(const gfx::Display
& display
) OVERRIDE
;
65 // ui::EventHandler override:
66 virtual void OnTouchEvent(ui::TouchEvent
* event
) OVERRIDE
;
69 friend class ash::Shell
;
71 // The object should only be created by the ash::Shell.
72 MaximizeModeWindowManager();
75 typedef std::map
<aura::Window
*, MaximizeModeWindowState
*> WindowToState
;
77 // Maximize all windows and restore their current state.
78 void MaximizeAllWindows();
80 // Restore all windows to their previous state.
81 void RestoreAllWindows();
83 // If the given window should be handled by us, this function will maximize it
84 // and add it to the list of known windows (remembering the initial show
86 // Note: If the given window cannot be handled by us the function will return
88 void MaximizeAndTrackWindow(aura::Window
* window
);
90 // Remove a window from our tracking list.
91 void ForgetWindow(aura::Window
* window
);
93 // Returns true when the given window should be modified in any way by us.
94 bool ShouldHandleWindow(aura::Window
* window
);
96 // Add window creation observers to track creation of new windows.
97 void AddWindowCreationObservers();
99 // Remove Window creation observers.
100 void RemoveWindowCreationObservers();
102 // Change the internal state (e.g. observers) when the display configuration
104 void DisplayConfigurationChanged();
106 // Returns true when the |window| is a container window.
107 bool IsContainerWindow(aura::Window
* window
);
109 // Add a backdrop behind the currently active window on each desktop.
110 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable
);
112 // Every window which got touched by our window manager gets added here.
113 WindowToState window_state_map_
;
115 // All container windows which have to be tracked.
116 std::set
<aura::Window
*> observed_container_windows_
;
118 // True if all backdrops are hidden.
119 bool backdrops_hidden_
;
121 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager
);
126 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_