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/gfx/display_observer.h"
20 class MaximizeModeWindowState;
23 // A window manager which - when created - will force all windows into maximized
24 // mode. Exception are panels and windows which cannot be maximized.
25 // Windows which cannot be maximized / resized are centered with a layer placed
26 // behind the window so that no other windows are visible and/or obscured.
27 // With the destruction of the manager all windows will be restored to their
29 class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
30 public gfx::DisplayObserver,
31 public ShellObserver {
33 // This should only be deleted by the creator (ash::Shell).
34 virtual ~MaximizeModeWindowManager();
36 // Returns the number of maximized & tracked windows by this manager.
37 int GetNumberOfManagedWindows();
39 // Called from a window state object when it gets destroyed.
40 void WindowStateDestroyed(aura::Window* window);
42 // Overridden from WindowObserver:
43 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
44 virtual void OnWindowAdded(aura::Window* window) OVERRIDE;
45 virtual void OnWindowBoundsChanged(aura::Window* window,
46 const gfx::Rect& old_bounds,
47 const gfx::Rect& new_bounds) OVERRIDE;
49 // aura::DisplayObserver overrides:
50 virtual void OnDisplayBoundsChanged(
51 const gfx::Display& display) OVERRIDE;
52 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
53 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
55 // ShellObserver overrides:
56 virtual void OnOverviewModeStarting() OVERRIDE;
57 virtual void OnOverviewModeEnding() OVERRIDE;
60 friend class ash::Shell;
62 // The object should only be created by the ash::Shell.
63 MaximizeModeWindowManager();
66 typedef std::map<aura::Window*, MaximizeModeWindowState*> WindowToState;
68 // Maximize all windows and restore their current state.
69 void MaximizeAllWindows();
71 // Restore all windows to their previous state.
72 void RestoreAllWindows();
74 // If the given window should be handled by us, this function will maximize it
75 // and add it to the list of known windows (remembering the initial show
77 // Note: If the given window cannot be handled by us the function will return
79 void MaximizeAndTrackWindow(aura::Window* window);
81 // Remove a window from our tracking list.
82 void ForgetWindow(aura::Window* window);
84 // Returns true when the given window should be modified in any way by us.
85 bool ShouldHandleWindow(aura::Window* window);
87 // Add window creation observers to track creation of new windows.
88 void AddWindowCreationObservers();
90 // Remove Window creation observers.
91 void RemoveWindowCreationObservers();
93 // Change the internal state (e.g. observers) when the display configuration
95 void DisplayConfigurationChanged();
97 // Returns true when the |window| is a container window.
98 bool IsContainerWindow(aura::Window* window);
100 // Add a backdrop behind the currently active window on each desktop.
101 void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
103 // Every window which got touched by our window manager gets added here.
104 WindowToState window_state_map_;
106 // All container windows which have to be tracked.
107 std::set<aura::Window*> observed_container_windows_;
109 // True if all backdrops are hidden.
110 bool backdrops_hidden_;
112 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager);
117 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_