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

Side by Side Diff: ash/common/wm_window.h

Issue 2629643002: chromeos: Renames WmWindowAura to WmWindow (Closed)
Patch Set: unnecessary casts Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_COMMON_WM_WINDOW_H_ 5 #ifndef ASH_COMMON_WM_WINDOW_H_
6 #define ASH_COMMON_WM_WINDOW_H_ 6 #define ASH_COMMON_WM_WINDOW_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "base/macros.h"
13 #include "base/observer_list.h"
12 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
13 #include "base/time/time.h" 15 #include "base/time/time.h"
14 #include "third_party/skia/include/core/SkColor.h" 16 #include "ui/aura/window_observer.h"
15 #include "ui/base/ui_base_types.h" 17 #include "ui/base/ui_base_types.h"
16 #include "ui/compositor/layer_animation_element.h" 18 #include "ui/compositor/layer_animation_element.h"
17 #include "ui/gfx/image/image_skia.h" 19 #include "ui/wm/core/transient_window_observer.h"
18 #include "ui/wm/core/window_animations.h" 20 #include "ui/wm/core/window_animations.h"
19 #include "ui/wm/public/window_types.h" 21 #include "ui/wm/public/window_types.h"
20 22
21 namespace display { 23 namespace display {
22 class Display; 24 class Display;
23 } 25 }
24 26
25 namespace gfx { 27 namespace gfx {
28 class ImageSkia;
26 class Point; 29 class Point;
27 class Rect; 30 class Rect;
28 class Size; 31 class Size;
29 class Transform; 32 class Transform;
30 } 33 }
31 34
32 namespace ui { 35 namespace ui {
33 class EventHandler; 36 class EventHandler;
34 class Layer; 37 class Layer;
35 } 38 }
36 39
37 namespace views { 40 namespace views {
38 class View; 41 class View;
39 class Widget; 42 class Widget;
40 } 43 }
41 44
42 namespace ash { 45 namespace ash {
43 46
44 class ImmersiveFullscreenController; 47 class ImmersiveFullscreenController;
45 class RootWindowController; 48 class RootWindowController;
46 class WmLayoutManager; 49 class WmLayoutManager;
47 class WmShell; 50 class WmShell;
48 class WmTransientWindowObserver; 51 class WmTransientWindowObserver;
49 class WmWindowObserver; 52 class WmWindowObserver;
53 class WmWindowTestApi;
50 enum class WmWindowProperty; 54 enum class WmWindowProperty;
51 55
52 namespace wm { 56 namespace wm {
53 class WindowState; 57 class WindowState;
54 } 58 }
55 59
56 // This class exists as a porting layer to allow ash/wm to work with 60 // WmWindow is tied to the life of the underlying aura::Window. Use the
57 // aura::Window or ui::Window. See aura::Window for details on the functions. 61 // static Get() function to obtain a WmWindow from an aura::Window.
James Cook 2017/01/12 20:45:56 nit: I would add a note explaining why this class
sky 2017/01/12 20:58:25 Done.
58 class ASH_EXPORT WmWindow { 62 class ASH_EXPORT WmWindow : public aura::WindowObserver,
63 public ::wm::TransientWindowObserver {
59 public: 64 public:
60 // See comments in SetBoundsInScreen(). 65 // See comments in SetBoundsInScreen().
61 enum class BoundsInScreenBehavior { 66 enum class BoundsInScreenBehavior {
62 USE_LOCAL_COORDINATES, 67 USE_LOCAL_COORDINATES,
63 USE_SCREEN_COORDINATES, 68 USE_SCREEN_COORDINATES,
64 }; 69 };
65 70
66 using Windows = std::vector<WmWindow*>; 71 using Windows = std::vector<WmWindow*>;
67 72
68 virtual void Destroy() = 0; 73 // NOTE: this class is owned by the corresponding window. You shouldn't delete
74 // TODO(sky): friend deleter and make private.
75 ~WmWindow() override;
76
77 // Returns a WmWindow for an aura::Window, creating if necessary. |window| may
78 // be null, in which case null is returned.
79 static WmWindow* Get(aura::Window* window) {
80 return const_cast<WmWindow*>(Get(const_cast<const aura::Window*>(window)));
81 }
82 static const WmWindow* Get(const aura::Window* window);
83
84 static std::vector<WmWindow*> FromAuraWindows(
85 const std::vector<aura::Window*>& aura_windows);
86 static std::vector<aura::Window*> ToAuraWindows(
87 const std::vector<WmWindow*>& windows);
88
89 // Convenience for wm_window->aura_window(). Returns null if |wm_window| is
90 // null.
91 static aura::Window* GetAuraWindow(WmWindow* wm_window) {
sky 2017/01/12 18:13:46 I started trying to remove this, and realized as t
James Cook 2017/01/12 20:45:56 Acknowledged.
92 return const_cast<aura::Window*>(
93 GetAuraWindow(const_cast<const WmWindow*>(wm_window)));
94 }
95 static const aura::Window* GetAuraWindow(const WmWindow* wm_window);
96
97 aura::Window* aura_window() { return window_; }
98 const aura::Window* aura_window() const { return window_; }
99
100 // See description of |children_use_extended_hit_region_|.
101 bool ShouldUseExtendedHitRegion() const;
102
103 void Destroy();
69 104
70 WmWindow* GetRootWindow() { 105 WmWindow* GetRootWindow() {
71 return const_cast<WmWindow*>( 106 return const_cast<WmWindow*>(
72 const_cast<const WmWindow*>(this)->GetRootWindow()); 107 const_cast<const WmWindow*>(this)->GetRootWindow());
73 } 108 }
74 virtual const WmWindow* GetRootWindow() const = 0; 109 const WmWindow* GetRootWindow() const;
75 virtual RootWindowController* GetRootWindowController() = 0; 110 RootWindowController* GetRootWindowController();
76 111
77 // TODO(sky): fix constness. 112 // TODO(sky): fix constness.
78 virtual WmShell* GetShell() const = 0; 113 WmShell* GetShell() const;
79 114
80 // Used for debugging. 115 // Used for debugging.
81 virtual void SetName(const char* name) = 0; 116 void SetName(const char* name);
82 virtual std::string GetName() const = 0; 117 std::string GetName() const;
83 118
84 virtual void SetTitle(const base::string16& title) = 0; 119 void SetTitle(const base::string16& title);
85 virtual base::string16 GetTitle() const = 0; 120 base::string16 GetTitle() const;
86 121
87 // See shell_window_ids.h for list of known ids. 122 // See shell_window_ids.h for list of known ids.
88 virtual void SetShellWindowId(int id) = 0; 123 void SetShellWindowId(int id);
89 virtual int GetShellWindowId() const = 0; 124 int GetShellWindowId() const;
90 virtual WmWindow* GetChildByShellWindowId(int id) = 0; 125 WmWindow* GetChildByShellWindowId(int id);
91 126
92 virtual ui::wm::WindowType GetType() const = 0; 127 ui::wm::WindowType GetType() const;
93 virtual int GetAppType() const = 0; 128 int GetAppType() const;
94 virtual void SetAppType(int app_type) const = 0; 129 void SetAppType(int app_type) const;
95 130
96 virtual ui::Layer* GetLayer() = 0; 131 ui::Layer* GetLayer();
97 132
98 // TODO(sky): these are temporary until GetLayer() always returns non-null. 133 // TODO(sky): these are temporary until GetLayer() always returns non-null.
99 virtual bool GetLayerTargetVisibility() = 0; 134 bool GetLayerTargetVisibility();
100 virtual bool GetLayerVisible() = 0; 135 bool GetLayerVisible();
101 136
102 virtual display::Display GetDisplayNearestWindow() = 0; 137 display::Display GetDisplayNearestWindow();
103 138
104 virtual bool HasNonClientArea() = 0; 139 bool HasNonClientArea();
105 virtual int GetNonClientComponent(const gfx::Point& location) = 0; 140 int GetNonClientComponent(const gfx::Point& location);
141 gfx::Point ConvertPointToTarget(const WmWindow* target,
142 const gfx::Point& point) const;
106 143
107 virtual gfx::Point ConvertPointToTarget(const WmWindow* target, 144 gfx::Point ConvertPointToScreen(const gfx::Point& point) const;
108 const gfx::Point& point) const = 0; 145 gfx::Point ConvertPointFromScreen(const gfx::Point& point) const;
109 virtual gfx::Point ConvertPointToScreen(const gfx::Point& point) const = 0; 146 gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const;
110 virtual gfx::Point ConvertPointFromScreen(const gfx::Point& point) const = 0; 147 gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const;
111 virtual gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const = 0;
112 virtual gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const = 0;
113 148
114 virtual gfx::Size GetMinimumSize() const = 0; 149 gfx::Size GetMinimumSize() const;
115 virtual gfx::Size GetMaximumSize() const = 0; 150 gfx::Size GetMaximumSize() const;
116 151
117 // Returns the visibility requested by this window. IsVisible() takes into 152 // Returns the visibility requested by this window. IsVisible() takes into
118 // account the visibility of the layer and ancestors, where as this tracks 153 // account the visibility of the layer and ancestors, where as this tracks
119 // whether Show() without a Hide() has been invoked. 154 // whether Show() without a Hide() has been invoked.
120 virtual bool GetTargetVisibility() const = 0; 155 bool GetTargetVisibility() const;
121 156
122 virtual bool IsVisible() const = 0; 157 bool IsVisible() const;
123 158
124 virtual void SetOpacity(float opacity) = 0; 159 void SetOpacity(float opacity);
125 virtual float GetTargetOpacity() const = 0; 160 float GetTargetOpacity() const;
126 161
127 virtual gfx::Rect GetMinimizeAnimationTargetBoundsInScreen() const = 0; 162 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen() const;
128 163
129 virtual void SetTransform(const gfx::Transform& transform) = 0; 164 void SetTransform(const gfx::Transform& transform);
130 virtual gfx::Transform GetTargetTransform() const = 0; 165 gfx::Transform GetTargetTransform() const;
131 166
132 virtual bool IsSystemModal() const = 0; 167 bool IsSystemModal() const;
133 168
134 virtual bool GetBoolProperty(WmWindowProperty key) = 0; 169 bool GetBoolProperty(WmWindowProperty key);
135 virtual void SetBoolProperty(WmWindowProperty key, bool value) = 0; 170 void SetBoolProperty(WmWindowProperty key, bool value);
136 virtual SkColor GetColorProperty(WmWindowProperty key) = 0; 171 SkColor GetColorProperty(WmWindowProperty key);
137 virtual void SetColorProperty(WmWindowProperty key, SkColor value) = 0; 172 void SetColorProperty(WmWindowProperty key, SkColor value);
138 virtual int GetIntProperty(WmWindowProperty key) = 0; 173 int GetIntProperty(WmWindowProperty key);
139 virtual void SetIntProperty(WmWindowProperty key, int value) = 0; 174 void SetIntProperty(WmWindowProperty key, int value);
140 virtual std::string GetStringProperty(WmWindowProperty key) = 0; 175 std::string GetStringProperty(WmWindowProperty key);
141 virtual void SetStringProperty(WmWindowProperty key, 176 void SetStringProperty(WmWindowProperty key, const std::string& value);
142 const std::string& value) = 0;
143 177
144 virtual gfx::ImageSkia GetWindowIcon() = 0; 178 gfx::ImageSkia GetWindowIcon();
145 virtual gfx::ImageSkia GetAppIcon() = 0; 179 gfx::ImageSkia GetAppIcon();
146 180
147 wm::WindowState* GetWindowState() { 181 wm::WindowState* GetWindowState() {
148 return const_cast<wm::WindowState*>( 182 return const_cast<wm::WindowState*>(
149 const_cast<const WmWindow*>(this)->GetWindowState()); 183 const_cast<const WmWindow*>(this)->GetWindowState());
150 } 184 }
151 virtual const wm::WindowState* GetWindowState() const = 0; 185 const wm::WindowState* GetWindowState() const;
152 186
153 // The implementation of this matches aura::Window::GetToplevelWindow(). 187 // The implementation of this matches aura::Window::GetToplevelWindow().
154 virtual WmWindow* GetToplevelWindow() = 0; 188 WmWindow* GetToplevelWindow();
189
155 // The implementation of this matches 190 // The implementation of this matches
156 // aura::client::ActivationClient::GetToplevelWindow(). 191 // aura::client::ActivationClient::GetToplevelWindow().
157 virtual WmWindow* GetToplevelWindowForFocus() = 0; 192 WmWindow* GetToplevelWindowForFocus();
158 193
159 // See aura::client::ParentWindowWithContext() for details of what this does. 194 // See aura::client::ParentWindowWithContext() for details of what this does.
160 virtual void SetParentUsingContext(WmWindow* context, 195 void SetParentUsingContext(WmWindow* context, const gfx::Rect& screen_bounds);
161 const gfx::Rect& screen_bounds) = 0; 196 void AddChild(WmWindow* window);
162 virtual void AddChild(WmWindow* window) = 0; 197 void RemoveChild(WmWindow* child);
163 virtual void RemoveChild(WmWindow* child) = 0;
164 198
165 WmWindow* GetParent() { 199 WmWindow* GetParent() {
166 return const_cast<WmWindow*>( 200 return const_cast<WmWindow*>(
167 const_cast<const WmWindow*>(this)->GetParent()); 201 const_cast<const WmWindow*>(this)->GetParent());
168 } 202 }
169 virtual const WmWindow* GetParent() const = 0; 203 const WmWindow* GetParent() const;
170 204
171 WmWindow* GetTransientParent() { 205 WmWindow* GetTransientParent() {
172 return const_cast<WmWindow*>( 206 return const_cast<WmWindow*>(
173 const_cast<const WmWindow*>(this)->GetTransientParent()); 207 const_cast<const WmWindow*>(this)->GetTransientParent());
174 } 208 }
175 virtual const WmWindow* GetTransientParent() const = 0; 209 const WmWindow* GetTransientParent() const;
176 virtual Windows GetTransientChildren() = 0; 210 std::vector<WmWindow*> GetTransientChildren();
177 211
178 // Moves this to the display where |event| occurred; returns true if moved. 212 // Moves this to the display where |event| occurred; returns true if moved.
179 virtual bool MoveToEventRoot(const ui::Event& event) = 0; 213 bool MoveToEventRoot(const ui::Event& event);
180 214
181 virtual void SetLayoutManager( 215 void SetLayoutManager(std::unique_ptr<WmLayoutManager> layout_manager);
182 std::unique_ptr<WmLayoutManager> layout_manager) = 0; 216 WmLayoutManager* GetLayoutManager();
183 virtual WmLayoutManager* GetLayoutManager() = 0;
184 217
185 // See wm::SetWindowVisibilityChangesAnimated() for details on what this 218 // See wm::SetWindowVisibilityChangesAnimated() for details on what this
186 // does. 219 // does.
187 virtual void SetVisibilityChangesAnimated() = 0; 220 void SetVisibilityChangesAnimated();
188 // |type| is WindowVisibilityAnimationType. Has to be an int to match aura. 221 // |type| is WindowVisibilityAnimationType. Has to be an int to match aura.
189 virtual void SetVisibilityAnimationType(int type) = 0; 222 void SetVisibilityAnimationType(int type);
190 virtual void SetVisibilityAnimationDuration(base::TimeDelta delta) = 0; 223 void SetVisibilityAnimationDuration(base::TimeDelta delta);
191 virtual void SetVisibilityAnimationTransition( 224 void SetVisibilityAnimationTransition(
192 ::wm::WindowVisibilityAnimationTransition transition) = 0; 225 ::wm::WindowVisibilityAnimationTransition transition);
193 virtual void Animate(::wm::WindowAnimationType type) = 0; 226 void Animate(::wm::WindowAnimationType type);
194 virtual void StopAnimatingProperty( 227 void StopAnimatingProperty(
195 ui::LayerAnimationElement::AnimatableProperty property) = 0; 228 ui::LayerAnimationElement::AnimatableProperty property);
196 virtual void SetChildWindowVisibilityChangesAnimated() = 0; 229 void SetChildWindowVisibilityChangesAnimated();
197 230
198 // See description in ui::Layer. 231 // See description in ui::Layer.
199 virtual void SetMasksToBounds(bool value) = 0; 232 void SetMasksToBounds(bool value);
200 233 void SetBounds(const gfx::Rect& bounds);
201 virtual void SetBounds(const gfx::Rect& bounds) = 0; 234 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds,
202 virtual void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, 235 base::TimeDelta delta);
203 base::TimeDelta delta) = 0;
204 // Sets the bounds in such a way that LayoutManagers are circumvented. 236 // Sets the bounds in such a way that LayoutManagers are circumvented.
205 virtual void SetBoundsDirect(const gfx::Rect& bounds) = 0; 237 void SetBoundsDirect(const gfx::Rect& bounds);
206 virtual void SetBoundsDirectAnimated(const gfx::Rect& bounds) = 0; 238 void SetBoundsDirectAnimated(const gfx::Rect& bounds);
207 virtual void SetBoundsDirectCrossFade(const gfx::Rect& bounds) = 0; 239 void SetBoundsDirectCrossFade(const gfx::Rect& bounds);
208 240
209 // Sets the bounds in two distinct ways. The exact behavior is dictated by 241 // Sets the bounds in two distinct ways. The exact behavior is dictated by
210 // the value of BoundsInScreenBehavior set on the parent: 242 // the value of BoundsInScreenBehavior set on the parent:
211 // 243 //
212 // USE_LOCAL_COORDINATES: the bounds are applied as is to the window. In other 244 // USE_LOCAL_COORDINATES: the bounds are applied as is to the window. In other
213 // words this behaves the same as if SetBounds(bounds_in_screen) was used. 245 // words this behaves the same as if SetBounds(bounds_in_screen) was used.
214 // This is the default. 246 // This is the default.
215 // USE_SCREEN_COORDINATES: the bounds are actual screen bounds and converted 247 // USE_SCREEN_COORDINATES: the bounds are actual screen bounds and converted
216 // from the display. In this case the window may move to a different 248 // from the display. In this case the window may move to a different
217 // display if allowed (see SetLockedToRoot()). 249 // display if allowed (see SetLockedToRoot()).
218 virtual void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, 250 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
219 const display::Display& dst_display) = 0; 251 const display::Display& dst_display);
220 virtual gfx::Rect GetBoundsInScreen() const = 0; 252 gfx::Rect GetBoundsInScreen() const;
221 virtual const gfx::Rect& GetBounds() const = 0; 253 const gfx::Rect& GetBounds() const;
222 virtual gfx::Rect GetTargetBounds() = 0; 254 gfx::Rect GetTargetBounds();
255 void ClearRestoreBounds();
256 void SetRestoreBoundsInScreen(const gfx::Rect& bounds);
257 gfx::Rect GetRestoreBoundsInScreen() const;
223 258
224 virtual void ClearRestoreBounds() = 0; 259 bool Contains(const WmWindow* other) const;
225 virtual void SetRestoreBoundsInScreen(const gfx::Rect& bounds) = 0;
226 virtual gfx::Rect GetRestoreBoundsInScreen() const = 0;
227 260
228 virtual bool Contains(const WmWindow* other) const = 0; 261 void SetShowState(ui::WindowShowState show_state);
262 ui::WindowShowState GetShowState() const;
229 263
230 virtual void SetShowState(ui::WindowShowState show_state) = 0; 264 void SetRestoreShowState(ui::WindowShowState show_state);
231 virtual ui::WindowShowState GetShowState() const = 0;
232
233 virtual void SetRestoreShowState(ui::WindowShowState show_state) = 0;
234 265
235 // Sets the restore bounds and show state overrides. These values take 266 // Sets the restore bounds and show state overrides. These values take
236 // precedence over the restore bounds and restore show state (if set). 267 // precedence over the restore bounds and restore show state (if set).
237 // If |bounds_override| is empty the values are cleared. 268 // If |bounds_override| is empty the values are cleared.
238 virtual void SetRestoreOverrides( 269 void SetRestoreOverrides(const gfx::Rect& bounds_override,
239 const gfx::Rect& bounds_override, 270 ui::WindowShowState window_state_override);
240 ui::WindowShowState window_state_override) = 0;
241 271
242 // If |value| is true the window can not be moved to another root, regardless 272 // If |value| is true the window can not be moved to another root, regardless
243 // of the bounds set on it. 273 // of the bounds set on it.
244 virtual void SetLockedToRoot(bool value) = 0; 274 void SetLockedToRoot(bool value);
245 virtual bool IsLockedToRoot() const = 0; 275 bool IsLockedToRoot() const;
246 276
247 virtual void SetCapture() = 0; 277 void SetCapture();
248 virtual bool HasCapture() = 0; 278 bool HasCapture();
249 virtual void ReleaseCapture() = 0; 279 void ReleaseCapture();
250 280
251 virtual bool HasRestoreBounds() const = 0; 281 bool HasRestoreBounds() const;
282 bool CanMaximize() const;
283 bool CanMinimize() const;
284 bool CanResize() const;
285 bool CanActivate() const;
286
287 void StackChildAtTop(WmWindow* child);
288 void StackChildAtBottom(WmWindow* child);
289 void StackChildAbove(WmWindow* child, WmWindow* target);
290 void StackChildBelow(WmWindow* child, WmWindow* target);
252 291
253 // See ScreenPinningController::SetPinnedWindow() for details. 292 // See ScreenPinningController::SetPinnedWindow() for details.
254 virtual void SetPinned(bool trusted) = 0; 293 void SetPinned(bool trusted);
255 294
256 virtual void SetAlwaysOnTop(bool value) = 0; 295 void SetAlwaysOnTop(bool value);
257 virtual bool IsAlwaysOnTop() const = 0; 296 bool IsAlwaysOnTop() const;
258 297
259 virtual void Hide() = 0; 298 void Hide();
260 virtual void Show() = 0; 299 void Show();
261 300
262 // Returns the widget associated with this window, or null if not associated 301 // Returns the widget associated with this window, or null if not associated
263 // with a widget. Only ash system UI widgets are returned, not widgets created 302 // with a widget. Only ash system UI widgets are returned, not widgets created
264 // by the mus window manager code to show a non-client frame. 303 // by the mus window manager code to show a non-client frame.
265 virtual views::Widget* GetInternalWidget() = 0; 304 views::Widget* GetInternalWidget();
266 305
267 // Requests the window to close and destroy itself. This is intended to 306 // Requests the window to close and destroy itself. This is intended to
268 // forward to an associated widget. 307 // forward to an associated widget.
269 virtual void CloseWidget() = 0; 308 void CloseWidget();
270 309
271 virtual void SetFocused() = 0; 310 void SetFocused();
272 virtual bool IsFocused() const = 0; 311 bool IsFocused() const;
273 312
274 virtual bool IsActive() const = 0; 313 bool IsActive() const;
275 virtual void Activate() = 0; 314 void Activate();
276 virtual void Deactivate() = 0; 315 void Deactivate();
277 316
278 virtual void SetFullscreen() = 0; 317 void SetFullscreen();
279 318
280 virtual void Maximize() = 0; 319 void Maximize();
281 virtual void Minimize() = 0; 320 void Minimize();
282 virtual void Unminimize() = 0; 321 void Unminimize();
283 322
284 virtual bool CanMaximize() const = 0; 323 std::vector<WmWindow*> GetChildren();
285 virtual bool CanMinimize() const = 0;
286 virtual bool CanResize() const = 0;
287 virtual bool CanActivate() const = 0;
288
289 virtual void StackChildAtTop(WmWindow* child) = 0;
290 virtual void StackChildAtBottom(WmWindow* child) = 0;
291 virtual void StackChildAbove(WmWindow* child, WmWindow* target) = 0;
292 virtual void StackChildBelow(WmWindow* child, WmWindow* target) = 0;
293
294 virtual Windows GetChildren() = 0;
295 324
296 // Shows/hides the resize shadow. |component| is the component to show the 325 // Shows/hides the resize shadow. |component| is the component to show the
297 // shadow for (one of the constants in ui/base/hit_test.h). 326 // shadow for (one of the constants in ui/base/hit_test.h).
298 virtual void ShowResizeShadow(int component) = 0; 327 void ShowResizeShadow(int component);
299 virtual void HideResizeShadow() = 0; 328 void HideResizeShadow();
300 329
301 // Installs a resize handler on the window that makes it easier to resize 330 // Installs a resize handler on the window that makes it easier to resize
302 // the window. See ResizeHandleWindowTargeter for the specifics. 331 // the window. See ResizeHandleWindowTargeter for the specifics.
303 virtual void InstallResizeHandleWindowTargeter( 332 void InstallResizeHandleWindowTargeter(
304 ImmersiveFullscreenController* immersive_fullscreen_controller) = 0; 333 ImmersiveFullscreenController* immersive_fullscreen_controller);
305 334
306 // See description in SetBoundsInScreen(). 335 // See description in SetBoundsInScreen().
307 virtual void SetBoundsInScreenBehaviorForChildren(BoundsInScreenBehavior) = 0; 336 void SetBoundsInScreenBehaviorForChildren(BoundsInScreenBehavior behavior);
308 337
309 // See description of SnapToPixelBoundaryIfNecessary(). 338 // See description of SnapToPixelBoundaryIfNecessary().
310 virtual void SetSnapsChildrenToPhysicalPixelBoundary() = 0; 339 void SetSnapsChildrenToPhysicalPixelBoundary();
311 340
312 // If an ancestor has been set to snap children to pixel boundaries, then 341 // If an ancestor has been set to snap children to pixel boundaries, then
313 // snaps the layer associated with this window to the layer associated with 342 // snaps the layer associated with this window to the layer associated with
314 // the ancestor. 343 // the ancestor.
315 virtual void SnapToPixelBoundaryIfNecessary() = 0; 344 void SnapToPixelBoundaryIfNecessary();
316 345
317 // Makes the hit region for children slightly larger for easier resizing. 346 // Makes the hit region for children slightly larger for easier resizing.
318 virtual void SetChildrenUseExtendedHitRegion() = 0; 347 void SetChildrenUseExtendedHitRegion();
319 348
320 // Returns a View that renders the contents of this window's layers. 349 // Returns a View that renders the contents of this window's layers.
321 virtual std::unique_ptr<views::View> CreateViewWithRecreatedLayers() = 0; 350 std::unique_ptr<views::View> CreateViewWithRecreatedLayers();
322 351
323 virtual void AddObserver(WmWindowObserver* observer) = 0; 352 void AddObserver(WmWindowObserver* observer);
324 virtual void RemoveObserver(WmWindowObserver* observer) = 0; 353 void RemoveObserver(WmWindowObserver* observer);
325 virtual bool HasObserver(const WmWindowObserver* observer) const = 0; 354 bool HasObserver(const WmWindowObserver* observer) const;
326 355
327 virtual void AddTransientWindowObserver( 356 void AddTransientWindowObserver(WmTransientWindowObserver* observer);
328 WmTransientWindowObserver* observer) = 0; 357 void RemoveTransientWindowObserver(WmTransientWindowObserver* observer);
329 virtual void RemoveTransientWindowObserver(
330 WmTransientWindowObserver* observer) = 0;
331 358
332 // Adds or removes a handler to receive events targeted at this window, before 359 // Adds or removes a handler to receive events targeted at this window, before
333 // this window handles the events itself; the handler does not recieve events 360 // this window handles the events itself; the handler does not recieve events
334 // from embedded windows. This only supports windows with internal widgets; 361 // from embedded windows. This only supports windows with internal widgets;
335 // see GetInternalWidget(). Ownership of the handler is not transferred. 362 // see GetInternalWidget(). Ownership of the handler is not transferred.
336 // 363 //
337 // Also note that the target of these events is always an aura::Window. 364 // Also note that the target of these events is always an aura::Window.
338 virtual void AddLimitedPreTargetHandler(ui::EventHandler* handler) = 0; 365 void AddLimitedPreTargetHandler(ui::EventHandler* handler);
339 virtual void RemoveLimitedPreTargetHandler(ui::EventHandler* handler) = 0; 366 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler);
340 367
341 protected: 368 protected:
James Cook 2017/01/12 20:45:57 Are there still subclasses of WmWindow? WmWindowMu
sky 2017/01/12 20:58:19 Done.
342 virtual ~WmWindow() {} 369 explicit WmWindow(aura::Window* window);
370
371 // Returns true if a WmWindow has been created for |window|.
372 static bool HasInstance(const aura::Window* window);
James Cook 2017/01/12 20:45:57 Does this have callers outside the now-deleted WmW
sky 2017/01/12 20:58:17 Indeed you're right, it's not needed anymore. Remo
373
374 base::ObserverList<WmWindowObserver>& observers() { return observers_; }
375
376 // aura::WindowObserver:
377 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override;
378 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override;
379 void OnWindowStackingChanged(aura::Window* window) override;
380 void OnWindowPropertyChanged(aura::Window* window,
381 const void* key,
382 intptr_t old) override;
383 void OnWindowBoundsChanged(aura::Window* window,
384 const gfx::Rect& old_bounds,
385 const gfx::Rect& new_bounds) override;
386 void OnWindowDestroying(aura::Window* window) override;
387 void OnWindowDestroyed(aura::Window* window) override;
388 void OnWindowVisibilityChanging(aura::Window* window, bool visible) override;
389 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
390 void OnWindowTitleChanged(aura::Window* window) override;
391
392 // ::wm::TransientWindowObserver overrides:
393 void OnTransientChildAdded(aura::Window* window,
394 aura::Window* transient) override;
395 void OnTransientChildRemoved(aura::Window* window,
396 aura::Window* transient) override;
397
398 private:
399 friend class WmWindowTestApi;
400
401 aura::Window* window_;
402
403 base::ObserverList<WmWindowObserver> observers_;
404
405 bool added_transient_observer_ = false;
406 base::ObserverList<WmTransientWindowObserver> transient_observers_;
407
408 // If true child windows should get a slightly larger hit region to make
409 // resizing easier.
410 bool children_use_extended_hit_region_ = false;
411
412 // Default value for |use_empty_minimum_size_for_testing_|.
413 static bool default_use_empty_minimum_size_for_testing_;
414
415 // If true the minimum size is 0x0, default is minimum size comes from widget.
416 bool use_empty_minimum_size_for_testing_;
417
418 DISALLOW_COPY_AND_ASSIGN(WmWindow);
343 }; 419 };
344 420
345 } // namespace ash 421 } // namespace ash
346 422
347 #endif // ASH_COMMON_WM_WINDOW_H_ 423 #endif // ASH_COMMON_WM_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698