OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_WM_BASE_LAYOUT_MANAGER_H_ | 5 #ifndef ASH_WM_BASE_LAYOUT_MANAGER_H_ |
6 #define ASH_WM_BASE_LAYOUT_MANAGER_H_ | 6 #define ASH_WM_BASE_LAYOUT_MANAGER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/shell_observer.h" | 11 #include "ash/shell_observer.h" |
12 #include "ash/wm/window_settings.h" | 12 #include "ash/wm/window_state.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "ui/aura/client/activation_change_observer.h" | 15 #include "ui/aura/client/activation_change_observer.h" |
16 #include "ui/aura/layout_manager.h" | 16 #include "ui/aura/layout_manager.h" |
17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
18 #include "ui/base/ui_base_types.h" | 18 #include "ui/base/ui_base_types.h" |
19 #include "ui/events/event_handler.h" | 19 #include "ui/events/event_handler.h" |
20 | 20 |
21 namespace aura { | 21 namespace aura { |
22 class RootWindow; | 22 class RootWindow; |
23 class Window; | 23 class Window; |
24 } | 24 } |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
| 27 namespace wm { |
| 28 class WindowState; |
| 29 } |
| 30 |
27 namespace internal { | 31 namespace internal { |
28 | 32 |
29 // BaseLayoutManager is the simplest possible implementation for a window | 33 // BaseLayoutManager is the simplest possible implementation for a window |
30 // layout manager. It listens for changes to kShowStateKey and resizes the | 34 // layout manager. It listens for changes to kShowStateKey and resizes the |
31 // window appropriately. Subclasses should be sure to invoke the base class | 35 // window appropriately. Subclasses should be sure to invoke the base class |
32 // for adding and removing windows, otherwise show state will not be tracked | 36 // for adding and removing windows, otherwise show state will not be tracked |
33 // properly. | 37 // properly. |
34 class ASH_EXPORT BaseLayoutManager | 38 class ASH_EXPORT BaseLayoutManager |
35 : public aura::LayoutManager, | 39 : public aura::LayoutManager, |
36 public aura::WindowObserver, | 40 public aura::WindowObserver, |
37 public aura::client::ActivationChangeObserver, | 41 public aura::client::ActivationChangeObserver, |
38 public ShellObserver, | 42 public ShellObserver, |
39 public wm::WindowSettings::Observer { | 43 public wm::WindowState::Observer { |
40 public: | 44 public: |
41 typedef std::set<aura::Window*> WindowSet; | 45 typedef std::set<aura::Window*> WindowSet; |
42 | 46 |
43 explicit BaseLayoutManager(aura::RootWindow* root_window); | 47 explicit BaseLayoutManager(aura::RootWindow* root_window); |
44 virtual ~BaseLayoutManager(); | 48 virtual ~BaseLayoutManager(); |
45 | 49 |
46 const WindowSet& windows() const { return windows_; } | 50 const WindowSet& windows() const { return windows_; } |
47 | 51 |
48 // Given a |window| and tentative |restore_bounds|, returns new bounds that | 52 // Given a |window| and tentative |restore_bounds|, returns new bounds that |
49 // ensure that at least a few pixels of the screen background are visible | 53 // ensure that at least a few pixels of the screen background are visible |
(...skipping 27 matching lines...) Expand all Loading... |
77 // ash::ShellObserver overrides: | 81 // ash::ShellObserver overrides: |
78 virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE; | 82 virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE; |
79 | 83 |
80 protected: | 84 protected: |
81 enum AdjustWindowReason { | 85 enum AdjustWindowReason { |
82 ADJUST_WINDOW_DISPLAY_SIZE_CHANGED, | 86 ADJUST_WINDOW_DISPLAY_SIZE_CHANGED, |
83 ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED, | 87 ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED, |
84 }; | 88 }; |
85 | 89 |
86 // Invoked from OnWindowPropertyChanged() if |kShowStateKey| changes. | 90 // Invoked from OnWindowPropertyChanged() if |kShowStateKey| changes. |
87 virtual void ShowStateChanged(aura::Window* window, | 91 virtual void ShowStateChanged(wm::WindowState* window_state, |
88 ui::WindowShowState last_show_state); | 92 ui::WindowShowState last_show_state); |
89 | 93 |
90 // Adjusts the window's bounds when the display area changes for given | 94 // Adjusts the window's bounds when the display area changes for given |
91 // window. This happens when the display size, work area insets or | 95 // window. This happens when the display size, work area insets or |
92 // the display on which the window exists has changed. | 96 // the display on which the window exists has changed. |
93 // If this is called for a display size change (i.e. |reason| | 97 // If this is called for a display size change (i.e. |reason| |
94 // is ADJUST_WINDOW_DISPLAY_SIZE_CHANGED), the non-maximized/non-fullscreen | 98 // is ADJUST_WINDOW_DISPLAY_SIZE_CHANGED), the non-maximized/non-fullscreen |
95 // windows are readjusted to make sure the window is completely within the | 99 // windows are readjusted to make sure the window is completely within the |
96 // display region. Otherwise, it makes sure at least some parts of the window | 100 // display region. Otherwise, it makes sure at least some parts of the window |
97 // is on display. | 101 // is on display. |
98 virtual void AdjustAllWindowsBoundsForWorkAreaChange( | 102 virtual void AdjustAllWindowsBoundsForWorkAreaChange( |
99 AdjustWindowReason reason); | 103 AdjustWindowReason reason); |
100 | 104 |
101 // Adjusts the sizes of the specific window in respond to a screen change or | 105 // Adjusts the sizes of the specific window in respond to a screen change or |
102 // display-area size change. | 106 // display-area size change. |
103 virtual void AdjustWindowBoundsForWorkAreaChange(aura::Window* window, | 107 virtual void AdjustWindowBoundsForWorkAreaChange( |
104 AdjustWindowReason reason); | 108 wm::WindowState* window_state, |
| 109 AdjustWindowReason reason); |
105 | 110 |
106 aura::RootWindow* root_window() { return root_window_; } | 111 aura::RootWindow* root_window() { return root_window_; } |
107 | 112 |
108 private: | 113 private: |
109 // Update window bounds based on a change in show state. | 114 // Update window bounds based on a change in show state. |
110 void UpdateBoundsFromShowState(aura::Window* window); | 115 void UpdateBoundsFromShowState(wm::WindowState* controller); |
111 | 116 |
112 // Set of windows we're listening to. | 117 // Set of windows we're listening to. |
113 WindowSet windows_; | 118 WindowSet windows_; |
114 | 119 |
115 aura::RootWindow* root_window_; | 120 aura::RootWindow* root_window_; |
116 | 121 |
117 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManager); | 122 DISALLOW_COPY_AND_ASSIGN(BaseLayoutManager); |
118 }; | 123 }; |
119 | 124 |
120 } // namespace internal | 125 } // namespace internal |
121 } // namespace ash | 126 } // namespace ash |
122 | 127 |
123 #endif // ASH_WM_BASE_LAYOUT_MANAGER_H_ | 128 #endif // ASH_WM_BASE_LAYOUT_MANAGER_H_ |
OLD | NEW |