Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / wm / workspace / workspace_layout_manager.h
blob06cc9b9249e4d0796290ced1784aa11c332a0fe9
1 // Copyright (c) 2012 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_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
6 #define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
8 #include <set>
10 #include "ash/ash_export.h"
11 #include "ash/shell_observer.h"
12 #include "ash/wm/window_state_observer.h"
13 #include "ash/wm/wm_types.h"
14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "ui/aura/layout_manager.h"
18 #include "ui/aura/window_observer.h"
19 #include "ui/gfx/geometry/rect.h"
20 #include "ui/keyboard/keyboard_controller_observer.h"
21 #include "ui/wm/public/activation_change_observer.h"
23 namespace aura {
24 class RootWindow;
25 class Window;
28 namespace ui {
29 class Layer;
32 namespace ash {
33 class ShelfLayoutManager;
34 class WorkspaceLayoutManagerDelegate;
36 namespace wm {
37 class WindowState;
38 class WMEvent;
41 // LayoutManager used on the window created for a workspace.
42 class ASH_EXPORT WorkspaceLayoutManager
43 : public aura::LayoutManager,
44 public aura::WindowObserver,
45 public aura::client::ActivationChangeObserver,
46 public keyboard::KeyboardControllerObserver,
47 public ShellObserver,
48 public wm::WindowStateObserver {
49 public:
50 explicit WorkspaceLayoutManager(aura::Window* window);
51 ~WorkspaceLayoutManager() override;
53 void SetShelf(ShelfLayoutManager* shelf);
55 // A delegate which can be set to add a backdrop behind the top most visible
56 // window. With the call the ownership of the delegate will be transferred to
57 // the WorkspaceLayoutManager.
58 void SetMaximizeBackdropDelegate(
59 scoped_ptr<WorkspaceLayoutManagerDelegate> delegate);
61 // Overridden from aura::LayoutManager:
62 void OnWindowResized() override {}
63 void OnWindowAddedToLayout(aura::Window* child) override;
64 void OnWillRemoveWindowFromLayout(aura::Window* child) override;
65 void OnWindowRemovedFromLayout(aura::Window* child) override;
66 void OnChildWindowVisibilityChanged(aura::Window* child,
67 bool visibile) override;
68 void SetChildBounds(aura::Window* child,
69 const gfx::Rect& requested_bounds) override;
71 // ash::ShellObserver overrides:
72 void OnDisplayWorkAreaInsetsChanged() override;
73 void OnFullscreenStateChanged(bool is_fullscreen,
74 aura::Window* root_window) override;
76 // Overriden from WindowObserver:
77 void OnWindowHierarchyChanged(
78 const WindowObserver::HierarchyChangeParams& params) override;
79 void OnWindowPropertyChanged(aura::Window* window,
80 const void* key,
81 intptr_t old) override;
82 void OnWindowStackingChanged(aura::Window* window) override;
83 void OnWindowDestroying(aura::Window* window) override;
84 void OnWindowBoundsChanged(aura::Window* window,
85 const gfx::Rect& old_bounds,
86 const gfx::Rect& new_bounds) override;
88 // aura::client::ActivationChangeObserver overrides:
89 void OnWindowActivated(
90 aura::client::ActivationChangeObserver::ActivationReason reason,
91 aura::Window* gained_active,
92 aura::Window* lost_active) override;
94 // keyboard::KeyboardControllerObserver overrides:
95 void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) override;
97 // WindowStateObserver overrides:
98 void OnPostWindowStateTypeChange(wm::WindowState* window_state,
99 wm::WindowStateType old_type) override;
101 private:
102 typedef std::set<aura::Window*> WindowSet;
104 // Adjusts the bounds of all managed windows when the display area changes.
105 // This happens when the display size, work area insets has changed.
106 // If this is called for a display size change (i.e. |event|
107 // is DISPLAY_RESIZED), the non-maximized/non-fullscreen
108 // windows are readjusted to make sure the window is completely within the
109 // display region. Otherwise, it makes sure at least some parts of the window
110 // is on display.
111 void AdjustAllWindowsBoundsForWorkAreaChange(const wm::WMEvent* event);
113 // Updates the visibility state of the shelf.
114 void UpdateShelfVisibility();
116 // Updates the fullscreen state of the workspace and notifies Shell if it
117 // has changed.
118 void UpdateFullscreenState();
120 // Updates the bounds of the window for a stte type change from
121 // |old_show_type|.
122 void UpdateBoundsFromStateType(wm::WindowState* window_state,
123 wm::WindowStateType old_state_type);
125 // If |window_state| is maximized or fullscreen the bounds of the
126 // window are set and true is returned. Does nothing otherwise.
127 bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state);
129 // Animates the window bounds to |bounds|.
130 void SetChildBoundsAnimated(aura::Window* child, const gfx::Rect& bounds);
132 ShelfLayoutManager* shelf_;
133 aura::Window* window_;
134 aura::Window* root_window_;
136 // Set of windows we're listening to.
137 WindowSet windows_;
139 // The work area in the coordinates of |window_|.
140 gfx::Rect work_area_in_parent_;
142 // True if this workspace is currently in fullscreen mode.
143 bool is_fullscreen_;
145 // A window which covers the full container and which gets inserted behind the
146 // topmost visible window.
147 scoped_ptr<WorkspaceLayoutManagerDelegate> backdrop_delegate_;
149 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager);
152 } // namespace ash
154 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_