Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ash / wm / workspace / workspace_layout_manager.h
blob50942682f7dbc7b7ceaca747630290a8dd33d1c2
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/shell_observer.h"
11 #include "ash/wm/base_layout_manager.h"
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "ui/aura/layout_manager.h"
15 #include "ui/aura/root_window_observer.h"
16 #include "ui/base/ui_base_types.h"
17 #include "ui/aura/window_observer.h"
18 #include "ui/gfx/rect.h"
20 namespace aura {
21 class RootWindow;
22 class Window;
25 namespace ui {
26 class Layer;
29 namespace ash {
31 namespace internal {
33 class Workspace;
34 class WorkspaceManager;
36 // LayoutManager used on the window created for a Workspace.
37 // TODO(sky): this code shares a fair amount of similarities with
38 // BaseLayoutManager, yet its different enough that subclassing is painful.
39 // See if I can refactor the code to make it easier to share common bits.
40 class ASH_EXPORT WorkspaceLayoutManager
41 : public aura::LayoutManager,
42 public aura::RootWindowObserver,
43 public ash::ShellObserver,
44 public aura::WindowObserver {
45 public:
46 public:
47 explicit WorkspaceLayoutManager(Workspace* workspace);
48 virtual ~WorkspaceLayoutManager();
50 // Overridden from BaseWorkspaceLayoutManager:
51 virtual void OnWindowResized() OVERRIDE {}
52 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
53 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
54 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
55 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
56 bool visibile) OVERRIDE;
57 virtual void SetChildBounds(aura::Window* child,
58 const gfx::Rect& requested_bounds) OVERRIDE;
60 // RootWindowObserver overrides:
61 virtual void OnRootWindowResized(const aura::RootWindow* root,
62 const gfx::Size& old_size) OVERRIDE;
64 // ash::ShellObserver overrides:
65 virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE;
67 // Overriden from WindowObserver:
68 virtual void OnWindowPropertyChanged(aura::Window* window,
69 const void* key,
70 intptr_t old) OVERRIDE;
71 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
73 private:
74 typedef std::set<aura::Window*> WindowSet;
76 // Invoked when the show state of a window changes. |cloned_layer| is a clone
77 // of the windows layer tree. |cloned_layer| is only non-NULL if a cross fade
78 // should happen between the states. This method takes ownership of
79 // |cloned_layer|.
80 void ShowStateChanged(aura::Window* window,
81 ui::WindowShowState last_show_state,
82 ui::Layer* cloned_layer);
84 enum AdjustWindowReason {
85 ADJUST_WINDOW_SCREEN_SIZE_CHANGED,
86 ADJUST_WINDOW_DISPLAY_INSETS_CHANGED,
87 ADJUST_WINDOW_WINDOW_ADDED
90 // Adjusts the sizes of the windows during a screen change. If this is called
91 // for a screen size change (i.e. |reason| is
92 // ADJUST_WINDOW_SCREEN_SIZE_CHANGED), the non-maximized/non-fullscreen
93 // windows are readjusted to make sure the window is completely within the
94 // display region. Otherwise, it makes sure at least some parts of the window
95 // is on display.
96 void AdjustWindowSizesForScreenChange(AdjustWindowReason reason);
98 // Adjusts the sizes of the specific window in respond to a screen change or
99 // display-area size change.
100 void AdjustWindowSizeForScreenChange(aura::Window* window,
101 AdjustWindowReason reason);
103 // Updates the bounds of the window from a show state change.
104 void UpdateBoundsFromShowState(aura::Window* window);
106 // If |window| is maximized or fullscreen the bounds of the window are set and
107 // true is returned. Does nothing otherwise.
108 bool SetMaximizedOrFullscreenBounds(aura::Window* window);
110 WorkspaceManager* workspace_manager();
112 aura::RootWindow* root_window_;
114 Workspace* workspace_;
116 // Set of windows we're listening to.
117 WindowSet windows_;
119 // The work area. Cached to avoid unnecessarily moving windows during a
120 // workspace switch.
121 gfx::Rect work_area_;
123 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager);
126 } // namespace internal
127 } // namespace ash
129 #endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_