Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ash / wm / maximize_mode / maximize_mode_window_manager.h
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_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_
7
8 #include <map>
9 #include <set>
10
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"
18
19 namespace ash {
20 class MaximizeModeWindowState;
21 class Shell;
22
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
28 // original state.
29 class ASH_EXPORT MaximizeModeWindowManager : public aura::WindowObserver,
30                                              public gfx::DisplayObserver,
31                                              public ShellObserver {
32  public:
33   // This should only be deleted by the creator (ash::Shell).
34   virtual ~MaximizeModeWindowManager();
35
36   // Returns the number of maximized & tracked windows by this manager.
37   int GetNumberOfManagedWindows();
38
39   // Called from a window state object when it gets destroyed.
40   void WindowStateDestroyed(aura::Window* window);
41
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;
48
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;
54
55   // ShellObserver overrides:
56   virtual void OnOverviewModeStarting() OVERRIDE;
57   virtual void OnOverviewModeEnding() OVERRIDE;
58
59  protected:
60   friend class ash::Shell;
61
62   // The object should only be created by the ash::Shell.
63   MaximizeModeWindowManager();
64
65  private:
66   typedef std::map<aura::Window*, MaximizeModeWindowState*> WindowToState;
67
68   // Maximize all windows and restore their current state.
69   void MaximizeAllWindows();
70
71   // Restore all windows to their previous state.
72   void RestoreAllWindows();
73
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
76   // state).
77   // Note: If the given window cannot be handled by us the function will return
78   // immediately.
79   void MaximizeAndTrackWindow(aura::Window* window);
80
81   // Remove a window from our tracking list.
82   void ForgetWindow(aura::Window* window);
83
84   // Returns true when the given window should be modified in any way by us.
85   bool ShouldHandleWindow(aura::Window* window);
86
87   // Add window creation observers to track creation of new windows.
88   void AddWindowCreationObservers();
89
90   // Remove Window creation observers.
91   void RemoveWindowCreationObservers();
92
93   // Change the internal state (e.g. observers) when the display configuration
94   // changes.
95   void DisplayConfigurationChanged();
96
97   // Returns true when the |window| is a container window.
98   bool IsContainerWindow(aura::Window* window);
99
100   // Add a backdrop behind the currently active window on each desktop.
101   void EnableBackdropBehindTopWindowOnEachDisplay(bool enable);
102
103   // Every window which got touched by our window manager gets added here.
104   WindowToState window_state_map_;
105
106   // All container windows which have to be tracked.
107   std::set<aura::Window*> observed_container_windows_;
108
109   // True if all backdrops are hidden.
110   bool backdrops_hidden_;
111
112   DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManager);
113 };
114
115 }  // namespace ash
116
117 #endif  // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_MANAGER_H_