Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: ash/wm/panels/panel_layout_manager.h

Issue 1918883002: Makes Panel related classes use ash/wm/common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@phantom_window_controller
Patch Set: fix windows Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_PANELS_PANEL_LAYOUT_MANAGER_H_ 5 #ifndef ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_
6 #define ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 6 #define ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/display/window_tree_host_manager.h"
13 #include "ash/shelf/shelf_icon_observer.h" 12 #include "ash/shelf/shelf_icon_observer.h"
14 #include "ash/shelf/shelf_layout_manager_observer.h" 13 #include "ash/shelf/shelf_layout_manager_observer.h"
15 #include "ash/shell_observer.h" 14 #include "ash/shell_observer.h"
15 #include "ash/wm/common/wm_activation_observer.h"
16 #include "ash/wm/common/wm_display_observer.h"
17 #include "ash/wm/common/wm_layout_manager.h"
18 #include "ash/wm/common/wm_overview_mode_observer.h"
19 #include "ash/wm/common/wm_root_window_controller_observer.h"
20 #include "ash/wm/common/wm_window_observer.h"
21 #include "ash/wm/common/wm_window_tracker.h"
16 #include "ash/wm/window_state_observer.h" 22 #include "ash/wm/window_state_observer.h"
17 #include "base/compiler_specific.h" 23 #include "base/compiler_specific.h"
18 #include "base/macros.h" 24 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
20 #include "ui/aura/layout_manager.h"
21 #include "ui/aura/window_observer.h"
22 #include "ui/aura/window_tracker.h"
23 #include "ui/keyboard/keyboard_controller.h" 26 #include "ui/keyboard/keyboard_controller.h"
24 #include "ui/keyboard/keyboard_controller_observer.h" 27 #include "ui/keyboard/keyboard_controller_observer.h"
25 #include "ui/wm/public/activation_change_observer.h"
26 28
27 namespace aura { 29 namespace aura {
28 class Window; 30 class Window;
29 } 31 }
30 32
31 namespace gfx { 33 namespace gfx {
32 class Rect; 34 class Rect;
33 } 35 }
34 36
35 namespace views { 37 namespace views {
36 class Widget; 38 class Widget;
37 } 39 }
38 40
39 namespace ash { 41 namespace ash {
40 class PanelCalloutWidget; 42 class PanelCalloutWidget;
41 class Shelf; 43 class Shelf;
42 class ShelfLayoutManager; 44 class ShelfLayoutManager;
43 45
46 namespace wm {
47 class WmRootWindowController;
48 }
49
44 // PanelLayoutManager is responsible for organizing panels within the 50 // PanelLayoutManager is responsible for organizing panels within the
45 // workspace. It is associated with a specific container window (i.e. 51 // workspace. It is associated with a specific container window (i.e.
46 // kShellWindowId_PanelContainer) and controls the layout of any windows 52 // kShellWindowId_PanelContainer) and controls the layout of any windows
47 // added to that container. 53 // added to that container.
48 // 54 //
49 // The constructor takes a |panel_container| argument which is expected to set 55 // The constructor takes a |panel_container| argument which is expected to set
50 // its layout manager to this instance, e.g.: 56 // its layout manager to this instance, e.g.:
51 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container)); 57 // panel_container->SetLayoutManager(new PanelLayoutManager(panel_container));
52 58
53 class ASH_EXPORT PanelLayoutManager 59 class ASH_EXPORT PanelLayoutManager
54 : public aura::LayoutManager, 60 : public wm::WmLayoutManager,
55 public ShelfIconObserver, 61 public ShelfIconObserver,
56 public ShellObserver,
57 public aura::WindowObserver,
58 public wm::WindowStateObserver, 62 public wm::WindowStateObserver,
59 public aura::client::ActivationChangeObserver, 63 public wm::WmActivationObserver,
64 public wm::WmDisplayObserver,
65 public wm::WmOverviewModeObserver,
66 public wm::WmRootWindowControllerObserver,
67 public wm::WmWindowObserver,
60 public keyboard::KeyboardControllerObserver, 68 public keyboard::KeyboardControllerObserver,
61 public WindowTreeHostManager::Observer,
62 public ShelfLayoutManagerObserver { 69 public ShelfLayoutManagerObserver {
63 public: 70 public:
64 explicit PanelLayoutManager(aura::Window* panel_container); 71 explicit PanelLayoutManager(wm::WmWindow* panel_container);
65 ~PanelLayoutManager() override; 72 ~PanelLayoutManager() override;
66 73
74 // Returns the PanelLayoutManager in the specified hierarchy. This searches
75 // from the root of |window|.
76 static PanelLayoutManager* Get(wm::WmWindow* window);
77
67 // Call Shutdown() before deleting children of panel_container. 78 // Call Shutdown() before deleting children of panel_container.
68 void Shutdown(); 79 void Shutdown();
69 80
70 void StartDragging(aura::Window* panel); 81 void StartDragging(wm::WmWindow* panel);
71 void FinishDragging(); 82 void FinishDragging();
72 83
73 void ToggleMinimize(aura::Window* panel); 84 void ToggleMinimize(wm::WmWindow* panel);
74 85
75 // Hide / Show the panel callout widgets. 86 // Hide / Show the panel callout widgets.
76 void SetShowCalloutWidgets(bool show); 87 void SetShowCalloutWidgets(bool show);
77 88
78 // Returns the callout widget (arrow) for |panel|. 89 // Returns the callout widget (arrow) for |panel|.
79 views::Widget* GetCalloutWidgetForPanel(aura::Window* panel); 90 views::Widget* GetCalloutWidgetForPanel(wm::WmWindow* panel);
80 91
81 Shelf* shelf() { return shelf_; } 92 Shelf* shelf() { return shelf_; }
82 void SetShelf(Shelf* shelf); 93 void SetShelf(Shelf* shelf);
83 94
84 // Overridden from aura::LayoutManager: 95 // Overridden from aura::LayoutManager:
85 void OnWindowResized() override; 96 void OnWindowResized() override;
86 void OnWindowAddedToLayout(aura::Window* child) override; 97 void OnWindowAddedToLayout(wm::WmWindow* child) override;
87 void OnWillRemoveWindowFromLayout(aura::Window* child) override; 98 void OnWillRemoveWindowFromLayout(wm::WmWindow* child) override;
88 void OnWindowRemovedFromLayout(aura::Window* child) override; 99 void OnWindowRemovedFromLayout(wm::WmWindow* child) override;
89 void OnChildWindowVisibilityChanged(aura::Window* child, 100 void OnChildWindowVisibilityChanged(wm::WmWindow* child,
90 bool visibile) override; 101 bool visibile) override;
91 void SetChildBounds(aura::Window* child, 102 void SetChildBounds(wm::WmWindow* child,
92 const gfx::Rect& requested_bounds) override; 103 const gfx::Rect& requested_bounds) override;
93 104
94 // Overridden from ShelfIconObserver 105 // Overridden from ShelfIconObserver
95 void OnShelfIconPositionsChanged() override; 106 void OnShelfIconPositionsChanged() override;
96 107
97 // Overridden from ShellObserver 108 // Overridden from wm::WmOverviewModeObserver
98 void OnOverviewModeEnded() override; 109 void OnOverviewModeEnded() override;
99 void OnShelfAlignmentChanged(aura::Window* root_window) override;
100 110
101 // Overridden from aura::WindowObserver 111 // Overridden from wm::WmRootWindowControllerObserver:
James Cook 2016/04/25 17:16:05 super-nit: Either all the "overridden" lines shoul
sky 2016/04/25 18:17:57 Done.
102 void OnWindowPropertyChanged(aura::Window* window, 112 void OnShelfAlignmentChanged() override;
103 const void* key, 113
114 // Overridden from wm::WmWindowObserver
115 void OnWindowPropertyChanged(wm::WmWindow* window,
116 wm::WmWindowProperty property,
James Cook 2016/04/25 17:16:05 Hooray for real types! :-)
104 intptr_t old) override; 117 intptr_t old) override;
105 118
106 // Overridden from ash::wm::WindowStateObserver 119 // Overridden from wm::WindowStateObserver
107 void OnPostWindowStateTypeChange(wm::WindowState* window_state, 120 void OnPostWindowStateTypeChange(wm::WindowState* window_state,
108 wm::WindowStateType old_type) override; 121 wm::WindowStateType old_type) override;
109 122
110 // Overridden from aura::client::ActivationChangeObserver 123 // Overridden from wm::WmActivationObserver
111 void OnWindowActivated( 124 void OnWindowActivated(wm::WmWindow* gained_active,
112 aura::client::ActivationChangeObserver::ActivationReason reason, 125 wm::WmWindow* lost_active) override;
113 aura::Window* gained_active,
114 aura::Window* lost_active) override;
115 126
116 // Overridden from WindowTreeHostManager::Observer 127 // Overridden from WindowTreeHostManager::Observer
117 void OnDisplayConfigurationChanged() override; 128 void OnDisplayConfigurationChanged() override;
118 129
119 // Overridden from ShelfLayoutManagerObserver 130 // Overridden from ShelfLayoutManagerObserver
120 void WillChangeVisibilityState(ShelfVisibilityState new_state) override; 131 void WillChangeVisibilityState(ShelfVisibilityState new_state) override;
121 132
122 private: 133 private:
123 friend class PanelLayoutManagerTest; 134 friend class PanelLayoutManagerTest;
124 friend class PanelWindowResizerTest; 135 friend class PanelWindowResizerTest;
125 friend class DockedWindowResizerTest; 136 friend class DockedWindowResizerTest;
126 friend class DockedWindowLayoutManagerTest; 137 friend class DockedWindowLayoutManagerTest;
127 friend class WorkspaceControllerTest; 138 friend class WorkspaceControllerTest;
128 friend class AcceleratorControllerTest; 139 friend class AcceleratorControllerTest;
129 140
130 views::Widget* CreateCalloutWidget(); 141 views::Widget* CreateCalloutWidget();
131 142
132 struct PanelInfo{ 143 struct ASH_EXPORT PanelInfo {
133 PanelInfo() : window(NULL), callout_widget(NULL), slide_in(false) {} 144 PanelInfo() : window(NULL), callout_widget(NULL), slide_in(false) {}
134 145
135 bool operator==(const aura::Window* other_window) const { 146 bool operator==(const wm::WmWindow* other_window) const {
136 return window == other_window; 147 return window == other_window;
137 } 148 }
138 149
150 // Returns |callout_widget| as a widget. Used by tests.
151 views::Widget* CalloutWidget();
152
139 // A weak pointer to the panel window. 153 // A weak pointer to the panel window.
140 aura::Window* window; 154 wm::WmWindow* window;
155
141 // The callout widget for this panel. This pointer must be managed 156 // The callout widget for this panel. This pointer must be managed
142 // manually as this structure is used in a std::list. See 157 // manually as this structure is used in a std::list. See
143 // http://www.chromium.org/developers/smart-pointer-guidelines 158 // http://www.chromium.org/developers/smart-pointer-guidelines
144 PanelCalloutWidget* callout_widget; 159 PanelCalloutWidget* callout_widget;
145 160
146 // True on new and restored panel windows until the panel has been 161 // True on new and restored panel windows until the panel has been
147 // positioned. The first time Relayout is called the panel will be shown, 162 // positioned. The first time Relayout is called the panel will be shown,
148 // and slide into position and this will be set to false. 163 // and slide into position and this will be set to false.
149 bool slide_in; 164 bool slide_in;
150 }; 165 };
151 166
152 typedef std::list<PanelInfo> PanelList; 167 typedef std::list<PanelInfo> PanelList;
153 168
154 void MinimizePanel(aura::Window* panel); 169 void MinimizePanel(wm::WmWindow* panel);
155 void RestorePanel(aura::Window* panel); 170 void RestorePanel(wm::WmWindow* panel);
156 171
157 // Called whenever the panel layout might change. 172 // Called whenever the panel layout might change.
158 void Relayout(); 173 void Relayout();
159 174
160 // Called whenever the panel stacking order needs to be updated (e.g. focus 175 // Called whenever the panel stacking order needs to be updated (e.g. focus
161 // changes or a panel is moved). 176 // changes or a panel is moved).
162 void UpdateStacking(aura::Window* active_panel); 177 void UpdateStacking(wm::WmWindow* active_panel);
163 178
164 // Update the callout arrows for all managed panels. 179 // Update the callout arrows for all managed panels.
165 void UpdateCallouts(); 180 void UpdateCallouts();
166 181
167 // Overridden from keyboard::KeyboardControllerObserver: 182 // Overridden from keyboard::KeyboardControllerObserver:
168 void OnKeyboardBoundsChanging(const gfx::Rect& keyboard_bounds) override; 183 void OnKeyboardBoundsChanging(const gfx::Rect& keyboard_bounds) override;
169 184
170 // Parent window associated with this layout manager. 185 // Parent window associated with this layout manager.
171 aura::Window* panel_container_; 186 wm::WmWindow* panel_container_;
187
188 wm::WmRootWindowController* root_window_controller_;
189
172 // Protect against recursive calls to OnWindowAddedToLayout(). 190 // Protect against recursive calls to OnWindowAddedToLayout().
173 bool in_add_window_; 191 bool in_add_window_;
174 // Protect against recursive calls to Relayout(). 192 // Protect against recursive calls to Relayout().
175 bool in_layout_; 193 bool in_layout_;
176 // Indicates if the panel callout widget should be created. 194 // Indicates if the panel callout widget should be created.
177 bool show_callout_widgets_; 195 bool show_callout_widgets_;
178 // Ordered list of unowned pointers to panel windows. 196 // Ordered list of unowned pointers to panel windows.
179 PanelList panel_windows_; 197 PanelList panel_windows_;
180 // The panel being dragged. 198 // The panel being dragged.
181 aura::Window* dragged_panel_; 199 wm::WmWindow* dragged_panel_;
182 // The shelf we are observing for shelf icon changes. 200 // The shelf we are observing for shelf icon changes.
183 Shelf* shelf_; 201 Shelf* shelf_;
184 // The shelf layout manager being observed for visibility changes. 202 // The shelf layout manager being observed for visibility changes.
185 ShelfLayoutManager* shelf_layout_manager_; 203 ShelfLayoutManager* shelf_layout_manager_;
186 204
187 // When not NULL, the shelf is hidden (i.e. full screen) and this tracks the 205 // When not NULL, the shelf is hidden (i.e. full screen) and this tracks the
188 // set of panel windows which have been temporarily hidden and need to be 206 // set of panel windows which have been temporarily hidden and need to be
189 // restored when the shelf becomes visible again. 207 // restored when the shelf becomes visible again.
190 std::unique_ptr<aura::WindowTracker> restore_windows_on_shelf_visible_; 208 std::unique_ptr<wm::WmWindowTracker> restore_windows_on_shelf_visible_;
191 209
192 // The last active panel. Used to maintain stacking order even if no panels 210 // The last active panel. Used to maintain stacking order even if no panels
193 // are currently focused. 211 // are currently focused.
194 aura::Window* last_active_panel_; 212 wm::WmWindow* last_active_panel_;
195 base::WeakPtrFactory<PanelLayoutManager> weak_factory_; 213 base::WeakPtrFactory<PanelLayoutManager> weak_factory_;
196 214
197 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager); 215 DISALLOW_COPY_AND_ASSIGN(PanelLayoutManager);
198 }; 216 };
199 217
200 } // namespace ash 218 } // namespace ash
201 219
202 #endif // ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_ 220 #endif // ASH_WM_PANELS_PANEL_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698