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_
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 "ui/aura/client/activation_change_observer.h"
17 #include "ui/aura/layout_manager.h"
18 #include "ui/aura/window_observer.h"
19 #include "ui/gfx/rect.h"
37 class ShelfLayoutManager
;
39 // LayoutManager used on the window created for a workspace.
40 class ASH_EXPORT WorkspaceLayoutManager
41 : public aura::LayoutManager
,
42 public aura::WindowObserver
,
43 public aura::client::ActivationChangeObserver
,
45 public wm::WindowStateObserver
{
47 explicit WorkspaceLayoutManager(aura::Window
* window
);
48 virtual ~WorkspaceLayoutManager();
50 void SetShelf(internal::ShelfLayoutManager
* shelf
);
52 // Overridden from aura::LayoutManager:
53 virtual void OnWindowResized() OVERRIDE
{}
54 virtual void OnWindowAddedToLayout(aura::Window
* child
) OVERRIDE
;
55 virtual void OnWillRemoveWindowFromLayout(aura::Window
* child
) OVERRIDE
;
56 virtual void OnWindowRemovedFromLayout(aura::Window
* child
) OVERRIDE
;
57 virtual void OnChildWindowVisibilityChanged(aura::Window
* child
,
58 bool visibile
) OVERRIDE
;
59 virtual void SetChildBounds(aura::Window
* child
,
60 const gfx::Rect
& requested_bounds
) OVERRIDE
;
62 // ash::ShellObserver overrides:
63 virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE
;
65 // Overriden from WindowObserver:
66 virtual void OnWindowHierarchyChanged(
67 const WindowObserver::HierarchyChangeParams
& params
) OVERRIDE
;
68 virtual void OnWindowPropertyChanged(aura::Window
* window
,
70 intptr_t old
) OVERRIDE
;
71 virtual void OnWindowStackingChanged(aura::Window
* window
) OVERRIDE
;
72 virtual void OnWindowDestroying(aura::Window
* window
) OVERRIDE
;
73 virtual void OnWindowBoundsChanged(aura::Window
* window
,
74 const gfx::Rect
& old_bounds
,
75 const gfx::Rect
& new_bounds
) OVERRIDE
;
77 // aura::client::ActivationChangeObserver overrides:
78 virtual void OnWindowActivated(aura::Window
* gained_active
,
79 aura::Window
* lost_active
) OVERRIDE
;
81 // WindowStateObserver overrides:
82 virtual void OnPostWindowShowTypeChange(wm::WindowState
* window_state
,
83 wm::WindowShowType old_type
) OVERRIDE
;
86 typedef std::set
<aura::Window
*> WindowSet
;
88 // Adjusts the bounds of all managed windows when the display area changes.
89 // This happens when the display size, work area insets has changed.
90 // If this is called for a display size change (i.e. |event|
91 // is DISPLAY_RESIZED), the non-maximized/non-fullscreen
92 // windows are readjusted to make sure the window is completely within the
93 // display region. Otherwise, it makes sure at least some parts of the window
95 void AdjustAllWindowsBoundsForWorkAreaChange(wm::WMEvent event
);
97 // Updates the visibility state of the shelf.
98 void UpdateShelfVisibility();
100 // Updates the fullscreen state of the workspace and notifies Shell if it
102 void UpdateFullscreenState();
104 // Updates the bounds of the window for a show type change from
106 void UpdateBoundsFromShowType(wm::WindowState
* window_state
,
107 wm::WindowShowType old_show_type
);
109 // If |window_state| is maximized or fullscreen the bounds of the
110 // window are set and true is returned. Does nothing otherwise.
111 bool SetMaximizedOrFullscreenBounds(wm::WindowState
* window_state
);
113 // Animates the window bounds to |bounds|.
114 void SetChildBoundsAnimated(aura::Window
* child
, const gfx::Rect
& bounds
);
116 internal::ShelfLayoutManager
* shelf_
;
117 aura::Window
* window_
;
118 aura::Window
* root_window_
;
120 // Set of windows we're listening to.
123 // The work area in the coordinates of |window_|.
124 gfx::Rect work_area_in_parent_
;
126 // True if this workspace is currently in fullscreen mode.
129 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager
);
132 } // namespace internal
135 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_