• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
6 #define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
7 
8 #include <set>
9 
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/base/ui_base_types.h"
15 #include "ui/aura/window_observer.h"
16 #include "ui/gfx/rect.h"
17 
18 namespace aura {
19 class RootWindow;
20 class Window;
21 }
22 
23 namespace ui {
24 class Layer;
25 }
26 
27 namespace ash {
28 
29 namespace internal {
30 
31 class ShelfLayoutManager;
32 
33 // LayoutManager used on the window created for a workspace.
34 class ASH_EXPORT WorkspaceLayoutManager : public BaseLayoutManager {
35  public:
36   explicit WorkspaceLayoutManager(aura::Window* window);
37   virtual ~WorkspaceLayoutManager();
38 
39   void SetShelf(internal::ShelfLayoutManager* shelf);
40 
41   // Overridden from aura::LayoutManager:
OnWindowResized()42   virtual void OnWindowResized() OVERRIDE {}
43   virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
44   virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
45   virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE;
46   virtual void OnChildWindowVisibilityChanged(aura::Window* child,
47                                               bool visibile) OVERRIDE;
48   virtual void SetChildBounds(aura::Window* child,
49                               const gfx::Rect& requested_bounds) OVERRIDE;
50 
51   // ash::ShellObserver overrides:
52   virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE;
53 
54   // Overriden from WindowObserver:
55   virtual void OnWindowPropertyChanged(aura::Window* window,
56                                        const void* key,
57                                        intptr_t old) OVERRIDE;
58   virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE;
59 
60   // WindowStateObserver overrides:
61   virtual void OnWindowShowTypeChanged(wm::WindowState* window_state,
62                                        wm::WindowShowType old_type) OVERRIDE;
63 
64  private:
65   // Overridden from BaseLayoutManager:
66   virtual void ShowStateChanged(wm::WindowState* window_state,
67                                 ui::WindowShowState last_show_state) OVERRIDE;
68   virtual void AdjustAllWindowsBoundsForWorkAreaChange(
69       AdjustWindowReason reason) OVERRIDE;
70   virtual void AdjustWindowBoundsForWorkAreaChange(
71       wm::WindowState* window_state,
72       AdjustWindowReason reason) OVERRIDE;
73 
74   void AdjustWindowBoundsWhenAdded(wm::WindowState* window_state);
75 
76   // Updates the visibility state of the shelf.
77   void UpdateShelfVisibility();
78 
79   // Updates the fullscreen state of the workspace and notifies Shell if it
80   // has changed.
81   void UpdateFullscreenState();
82 
83   // Updates the bounds of the window for a show state change from
84   // |last_show_state|.
85   void UpdateBoundsFromShowState(wm::WindowState* window_state,
86                                  ui::WindowShowState last_show_state);
87 
88   // If |window_state| is maximized or fullscreen the bounds of the
89   // window are set and true is returned. Does nothing otherwise.
90   bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state);
91 
92   // Adjusts the |bounds| so that they are flush with the edge of the
93   // workspace if the window represented by |window_state| is side snapped.
94   void AdjustSnappedBounds(wm::WindowState* window_state, gfx::Rect* bounds);
95 
96   // Animates the window bounds to |bounds|.
97   void SetChildBoundsAnimated(aura::Window* child, const gfx::Rect& bounds);
98 
99   internal::ShelfLayoutManager* shelf_;
100   aura::Window* window_;
101 
102   // The work area. Cached to avoid unnecessarily moving windows during a
103   // workspace switch.
104   gfx::Rect work_area_in_parent_;
105 
106   // True if this workspace is currently in fullscreen mode.
107   bool is_fullscreen_;
108 
109   DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager);
110 };
111 
112 }  // namespace internal
113 }  // namespace ash
114 
115 #endif  // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_
116