OLD | NEW |
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_WM_WINDOW_H_ | 5 #ifndef ASH_WM_WINDOW_H_ |
6 #define ASH_WM_WINDOW_H_ | 6 #define ASH_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" | 12 #include "base/macros.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "ui/aura/window_observer.h" | |
17 #include "ui/base/ui_base_types.h" | 16 #include "ui/base/ui_base_types.h" |
18 #include "ui/compositor/layer_animation_element.h" | 17 #include "ui/compositor/layer_animation_element.h" |
19 #include "ui/wm/core/transient_window_observer.h" | 18 #include "ui/wm/core/transient_window_observer.h" |
20 #include "ui/wm/core/window_animations.h" | 19 #include "ui/wm/core/window_animations.h" |
21 #include "ui/wm/public/window_types.h" | 20 #include "ui/wm/public/window_types.h" |
22 | 21 |
23 namespace display { | 22 namespace display { |
24 class Display; | 23 class Display; |
25 } | 24 } |
26 | 25 |
27 namespace gfx { | 26 namespace gfx { |
28 class Point; | 27 class Point; |
29 class Rect; | 28 class Rect; |
30 class Size; | 29 class Size; |
31 class Transform; | 30 class Transform; |
32 } | 31 } |
33 | 32 |
34 namespace ui { | 33 namespace ui { |
35 class EventHandler; | 34 class EventHandler; |
36 class Layer; | 35 class Layer; |
37 } | 36 } |
38 | 37 |
39 namespace ash { | 38 namespace ash { |
40 | 39 |
41 class ImmersiveFullscreenController; | 40 class ImmersiveFullscreenController; |
42 class RootWindowController; | 41 class RootWindowController; |
43 class WmTransientWindowObserver; | 42 class WmTransientWindowObserver; |
44 class WmWindowTestApi; | |
45 enum class WmWindowProperty; | 43 enum class WmWindowProperty; |
46 | 44 |
47 namespace wm { | 45 namespace wm { |
48 class WindowState; | 46 class WindowState; |
49 } | 47 } |
50 | 48 |
51 // WmWindow abstracts away differences between ash running in classic mode | 49 // WmWindow abstracts away differences between ash running in classic mode |
52 // and ash running with aura-mus. | 50 // and ash running with aura-mus. |
53 // | 51 // |
54 // WmWindow is tied to the life of the underlying aura::Window. Use the | 52 // WmWindow is tied to the life of the underlying aura::Window. Use the |
55 // static Get() function to obtain a WmWindow from an aura::Window. | 53 // static Get() function to obtain a WmWindow from an aura::Window. |
56 class ASH_EXPORT WmWindow : public aura::WindowObserver, | 54 class ASH_EXPORT WmWindow : public ::wm::TransientWindowObserver { |
57 public ::wm::TransientWindowObserver { | |
58 public: | 55 public: |
59 // See comments in SetBoundsInScreen(). | 56 // See comments in SetBoundsInScreen(). |
60 enum class BoundsInScreenBehavior { | 57 enum class BoundsInScreenBehavior { |
61 USE_LOCAL_COORDINATES, | 58 USE_LOCAL_COORDINATES, |
62 USE_SCREEN_COORDINATES, | 59 USE_SCREEN_COORDINATES, |
63 }; | 60 }; |
64 | 61 |
65 using Windows = std::vector<WmWindow*>; | 62 using Windows = std::vector<WmWindow*>; |
66 | 63 |
67 // NOTE: this class is owned by the corresponding window. You shouldn't delete | 64 // NOTE: this class is owned by the corresponding window. You shouldn't delete |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 void Animate(::wm::WindowAnimationType type); | 190 void Animate(::wm::WindowAnimationType type); |
194 void StopAnimatingProperty( | 191 void StopAnimatingProperty( |
195 ui::LayerAnimationElement::AnimatableProperty property); | 192 ui::LayerAnimationElement::AnimatableProperty property); |
196 void SetChildWindowVisibilityChangesAnimated(); | 193 void SetChildWindowVisibilityChangesAnimated(); |
197 | 194 |
198 // See description in ui::Layer. | 195 // See description in ui::Layer. |
199 void SetMasksToBounds(bool value); | 196 void SetMasksToBounds(bool value); |
200 void SetBounds(const gfx::Rect& bounds); | 197 void SetBounds(const gfx::Rect& bounds); |
201 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, | 198 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, |
202 base::TimeDelta delta); | 199 base::TimeDelta delta); |
203 // Sets the bounds in such a way that LayoutManagers are circumvented. | |
204 void SetBoundsDirect(const gfx::Rect& bounds); | |
205 void SetBoundsDirectAnimated(const gfx::Rect& bounds); | |
206 void SetBoundsDirectCrossFade(const gfx::Rect& bounds); | |
207 | 200 |
208 // Sets the bounds in two distinct ways. The exact behavior is dictated by | 201 // Sets the bounds in two distinct ways. The exact behavior is dictated by |
209 // the value of BoundsInScreenBehavior set on the parent: | 202 // the value of BoundsInScreenBehavior set on the parent: |
210 // | 203 // |
211 // USE_LOCAL_COORDINATES: the bounds are applied as is to the window. In other | 204 // USE_LOCAL_COORDINATES: the bounds are applied as is to the window. In other |
212 // words this behaves the same as if SetBounds(bounds_in_screen) was used. | 205 // words this behaves the same as if SetBounds(bounds_in_screen) was used. |
213 // This is the default. | 206 // This is the default. |
214 // USE_SCREEN_COORDINATES: the bounds are actual screen bounds and converted | 207 // USE_SCREEN_COORDINATES: the bounds are actual screen bounds and converted |
215 // from the display. In this case the window may move to a different | 208 // from the display. In this case the window may move to a different |
216 // display if allowed (see SetLockedToRoot()). | 209 // display if allowed (see SetLockedToRoot()). |
217 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | 210 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, |
218 const display::Display& dst_display); | 211 const display::Display& dst_display); |
219 gfx::Rect GetBoundsInScreen() const; | 212 gfx::Rect GetBoundsInScreen() const; |
220 const gfx::Rect& GetBounds() const; | 213 const gfx::Rect& GetBounds() const; |
221 gfx::Rect GetTargetBounds(); | 214 gfx::Rect GetTargetBounds(); |
222 void ClearRestoreBounds(); | 215 void ClearRestoreBounds(); |
223 void SetRestoreBoundsInScreen(const gfx::Rect& bounds); | 216 void SetRestoreBoundsInScreen(const gfx::Rect& bounds); |
224 gfx::Rect GetRestoreBoundsInScreen() const; | 217 gfx::Rect GetRestoreBoundsInScreen() const; |
225 | 218 |
226 bool Contains(const WmWindow* other) const; | 219 bool Contains(const WmWindow* other) const; |
227 | 220 |
228 void SetShowState(ui::WindowShowState show_state); | 221 void SetShowState(ui::WindowShowState show_state); |
229 ui::WindowShowState GetShowState() const; | 222 ui::WindowShowState GetShowState() const; |
230 | 223 |
231 void SetPreFullscreenShowState(ui::WindowShowState show_state); | 224 void SetPreFullscreenShowState(ui::WindowShowState show_state); |
232 | 225 |
233 // Sets the restore bounds and show state overrides. These values take | |
234 // precedence over the restore bounds and restore show state (if set). | |
235 // If |bounds_override| is empty the values are cleared. | |
236 void SetRestoreOverrides(const gfx::Rect& bounds_override, | |
237 ui::WindowShowState window_state_override); | |
238 | |
239 // If |value| is true the window can not be moved to another root, regardless | 226 // If |value| is true the window can not be moved to another root, regardless |
240 // of the bounds set on it. | 227 // of the bounds set on it. |
241 void SetLockedToRoot(bool value); | 228 void SetLockedToRoot(bool value); |
242 bool IsLockedToRoot() const; | 229 bool IsLockedToRoot() const; |
243 | 230 |
244 void SetCapture(); | 231 void SetCapture(); |
245 bool HasCapture(); | 232 bool HasCapture(); |
246 void ReleaseCapture(); | 233 void ReleaseCapture(); |
247 | 234 |
248 bool HasRestoreBounds() const; | 235 bool HasRestoreBounds() const; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // this window handles the events itself; the handler does not recieve events | 299 // this window handles the events itself; the handler does not recieve events |
313 // from embedded windows. This only supports windows with internal widgets; | 300 // from embedded windows. This only supports windows with internal widgets; |
314 // see ash::GetInternalWidgetForWindow(). Ownership of the handler is not | 301 // see ash::GetInternalWidgetForWindow(). Ownership of the handler is not |
315 // transferred. | 302 // transferred. |
316 // | 303 // |
317 // Also note that the target of these events is always an aura::Window. | 304 // Also note that the target of these events is always an aura::Window. |
318 void AddLimitedPreTargetHandler(ui::EventHandler* handler); | 305 void AddLimitedPreTargetHandler(ui::EventHandler* handler); |
319 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler); | 306 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler); |
320 | 307 |
321 private: | 308 private: |
322 friend class WmWindowTestApi; | |
323 | |
324 explicit WmWindow(aura::Window* window); | 309 explicit WmWindow(aura::Window* window); |
325 | 310 |
326 // aura::WindowObserver: | |
327 void OnWindowPropertyChanged(aura::Window* window, | |
328 const void* key, | |
329 intptr_t old) override; | |
330 | |
331 // ::wm::TransientWindowObserver overrides: | 311 // ::wm::TransientWindowObserver overrides: |
332 void OnTransientChildAdded(aura::Window* window, | 312 void OnTransientChildAdded(aura::Window* window, |
333 aura::Window* transient) override; | 313 aura::Window* transient) override; |
334 void OnTransientChildRemoved(aura::Window* window, | 314 void OnTransientChildRemoved(aura::Window* window, |
335 aura::Window* transient) override; | 315 aura::Window* transient) override; |
336 | 316 |
337 aura::Window* window_; | 317 aura::Window* window_; |
338 | 318 |
339 bool added_transient_observer_ = false; | 319 bool added_transient_observer_ = false; |
340 base::ObserverList<WmTransientWindowObserver> transient_observers_; | 320 base::ObserverList<WmTransientWindowObserver> transient_observers_; |
341 | 321 |
342 // If true child windows should get a slightly larger hit region to make | 322 // If true child windows should get a slightly larger hit region to make |
343 // resizing easier. | 323 // resizing easier. |
344 bool children_use_extended_hit_region_ = false; | 324 bool children_use_extended_hit_region_ = false; |
345 | 325 |
346 // Default value for |use_empty_minimum_size_for_testing_|. | 326 // Default value for |use_empty_minimum_size_for_testing_|. |
347 static bool default_use_empty_minimum_size_for_testing_; | 327 static bool default_use_empty_minimum_size_for_testing_; |
348 | 328 |
349 // If true the minimum size is 0x0, default is minimum size comes from widget. | 329 // If true the minimum size is 0x0, default is minimum size comes from widget. |
350 bool use_empty_minimum_size_for_testing_; | 330 bool use_empty_minimum_size_for_testing_; |
351 | 331 |
352 DISALLOW_COPY_AND_ASSIGN(WmWindow); | 332 DISALLOW_COPY_AND_ASSIGN(WmWindow); |
353 }; | 333 }; |
354 | 334 |
355 } // namespace ash | 335 } // namespace ash |
356 | 336 |
357 #endif // ASH_WM_WINDOW_H_ | 337 #endif // ASH_WM_WINDOW_H_ |
OLD | NEW |