| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 46 | 45 |
| 47 namespace wm { | 46 namespace wm { |
| 48 class WindowState; | 47 class WindowState; |
| 49 } | 48 } |
| 50 | 49 |
| 51 // WmWindow abstracts away differences between ash running in classic mode | 50 // WmWindow abstracts away differences between ash running in classic mode |
| 52 // and ash running with aura-mus. | 51 // and ash running with aura-mus. |
| 53 // | 52 // |
| 54 // WmWindow is tied to the life of the underlying aura::Window. Use the | 53 // 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. | 54 // static Get() function to obtain a WmWindow from an aura::Window. |
| 56 class ASH_EXPORT WmWindow : public aura::WindowObserver, | 55 class ASH_EXPORT WmWindow : public ::wm::TransientWindowObserver { |
| 57 public ::wm::TransientWindowObserver { | |
| 58 public: | 56 public: |
| 59 // See comments in SetBoundsInScreen(). | 57 // See comments in SetBoundsInScreen(). |
| 60 enum class BoundsInScreenBehavior { | 58 enum class BoundsInScreenBehavior { |
| 61 USE_LOCAL_COORDINATES, | 59 USE_LOCAL_COORDINATES, |
| 62 USE_SCREEN_COORDINATES, | 60 USE_SCREEN_COORDINATES, |
| 63 }; | 61 }; |
| 64 | 62 |
| 65 using Windows = std::vector<WmWindow*>; | 63 using Windows = std::vector<WmWindow*>; |
| 66 | 64 |
| 67 // NOTE: this class is owned by the corresponding window. You shouldn't delete | 65 // 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); | 191 void Animate(::wm::WindowAnimationType type); |
| 194 void StopAnimatingProperty( | 192 void StopAnimatingProperty( |
| 195 ui::LayerAnimationElement::AnimatableProperty property); | 193 ui::LayerAnimationElement::AnimatableProperty property); |
| 196 void SetChildWindowVisibilityChangesAnimated(); | 194 void SetChildWindowVisibilityChangesAnimated(); |
| 197 | 195 |
| 198 // See description in ui::Layer. | 196 // See description in ui::Layer. |
| 199 void SetMasksToBounds(bool value); | 197 void SetMasksToBounds(bool value); |
| 200 void SetBounds(const gfx::Rect& bounds); | 198 void SetBounds(const gfx::Rect& bounds); |
| 201 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, | 199 void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, |
| 202 base::TimeDelta delta); | 200 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 | 201 |
| 208 // Sets the bounds in two distinct ways. The exact behavior is dictated by | 202 // Sets the bounds in two distinct ways. The exact behavior is dictated by |
| 209 // the value of BoundsInScreenBehavior set on the parent: | 203 // the value of BoundsInScreenBehavior set on the parent: |
| 210 // | 204 // |
| 211 // USE_LOCAL_COORDINATES: the bounds are applied as is to the window. In other | 205 // 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. | 206 // words this behaves the same as if SetBounds(bounds_in_screen) was used. |
| 213 // This is the default. | 207 // This is the default. |
| 214 // USE_SCREEN_COORDINATES: the bounds are actual screen bounds and converted | 208 // 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 | 209 // from the display. In this case the window may move to a different |
| 216 // display if allowed (see SetLockedToRoot()). | 210 // display if allowed (see SetLockedToRoot()). |
| 217 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | 211 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, |
| 218 const display::Display& dst_display); | 212 const display::Display& dst_display); |
| 219 gfx::Rect GetBoundsInScreen() const; | 213 gfx::Rect GetBoundsInScreen() const; |
| 220 const gfx::Rect& GetBounds() const; | 214 const gfx::Rect& GetBounds() const; |
| 221 gfx::Rect GetTargetBounds(); | 215 gfx::Rect GetTargetBounds(); |
| 222 void ClearRestoreBounds(); | 216 void ClearRestoreBounds(); |
| 223 void SetRestoreBoundsInScreen(const gfx::Rect& bounds); | 217 void SetRestoreBoundsInScreen(const gfx::Rect& bounds); |
| 224 gfx::Rect GetRestoreBoundsInScreen() const; | 218 gfx::Rect GetRestoreBoundsInScreen() const; |
| 225 | 219 |
| 226 bool Contains(const WmWindow* other) const; | 220 bool Contains(const WmWindow* other) const; |
| 227 | 221 |
| 228 void SetShowState(ui::WindowShowState show_state); | 222 void SetShowState(ui::WindowShowState show_state); |
| 229 ui::WindowShowState GetShowState() const; | 223 ui::WindowShowState GetShowState() const; |
| 230 | 224 |
| 231 void SetPreFullscreenShowState(ui::WindowShowState show_state); | 225 void SetPreFullscreenShowState(ui::WindowShowState show_state); |
| 232 | 226 |
| 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 | 227 // If |value| is true the window can not be moved to another root, regardless |
| 240 // of the bounds set on it. | 228 // of the bounds set on it. |
| 241 void SetLockedToRoot(bool value); | 229 void SetLockedToRoot(bool value); |
| 242 bool IsLockedToRoot() const; | 230 bool IsLockedToRoot() const; |
| 243 | 231 |
| 244 void SetCapture(); | 232 void SetCapture(); |
| 245 bool HasCapture(); | 233 bool HasCapture(); |
| 246 void ReleaseCapture(); | 234 void ReleaseCapture(); |
| 247 | 235 |
| 248 bool HasRestoreBounds() const; | 236 bool HasRestoreBounds() const; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // | 304 // |
| 317 // Also note that the target of these events is always an aura::Window. | 305 // Also note that the target of these events is always an aura::Window. |
| 318 void AddLimitedPreTargetHandler(ui::EventHandler* handler); | 306 void AddLimitedPreTargetHandler(ui::EventHandler* handler); |
| 319 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler); | 307 void RemoveLimitedPreTargetHandler(ui::EventHandler* handler); |
| 320 | 308 |
| 321 private: | 309 private: |
| 322 friend class WmWindowTestApi; | 310 friend class WmWindowTestApi; |
| 323 | 311 |
| 324 explicit WmWindow(aura::Window* window); | 312 explicit WmWindow(aura::Window* window); |
| 325 | 313 |
| 326 // aura::WindowObserver: | |
| 327 void OnWindowPropertyChanged(aura::Window* window, | |
| 328 const void* key, | |
| 329 intptr_t old) override; | |
| 330 | |
| 331 // ::wm::TransientWindowObserver overrides: | 314 // ::wm::TransientWindowObserver overrides: |
| 332 void OnTransientChildAdded(aura::Window* window, | 315 void OnTransientChildAdded(aura::Window* window, |
| 333 aura::Window* transient) override; | 316 aura::Window* transient) override; |
| 334 void OnTransientChildRemoved(aura::Window* window, | 317 void OnTransientChildRemoved(aura::Window* window, |
| 335 aura::Window* transient) override; | 318 aura::Window* transient) override; |
| 336 | 319 |
| 337 aura::Window* window_; | 320 aura::Window* window_; |
| 338 | 321 |
| 339 bool added_transient_observer_ = false; | 322 bool added_transient_observer_ = false; |
| 340 base::ObserverList<WmTransientWindowObserver> transient_observers_; | 323 base::ObserverList<WmTransientWindowObserver> transient_observers_; |
| 341 | 324 |
| 342 // If true child windows should get a slightly larger hit region to make | 325 // If true child windows should get a slightly larger hit region to make |
| 343 // resizing easier. | 326 // resizing easier. |
| 344 bool children_use_extended_hit_region_ = false; | 327 bool children_use_extended_hit_region_ = false; |
| 345 | 328 |
| 346 // Default value for |use_empty_minimum_size_for_testing_|. | 329 // Default value for |use_empty_minimum_size_for_testing_|. |
| 347 static bool default_use_empty_minimum_size_for_testing_; | 330 static bool default_use_empty_minimum_size_for_testing_; |
| 348 | 331 |
| 349 // If true the minimum size is 0x0, default is minimum size comes from widget. | 332 // If true the minimum size is 0x0, default is minimum size comes from widget. |
| 350 bool use_empty_minimum_size_for_testing_; | 333 bool use_empty_minimum_size_for_testing_; |
| 351 | 334 |
| 352 DISALLOW_COPY_AND_ASSIGN(WmWindow); | 335 DISALLOW_COPY_AND_ASSIGN(WmWindow); |
| 353 }; | 336 }; |
| 354 | 337 |
| 355 } // namespace ash | 338 } // namespace ash |
| 356 | 339 |
| 357 #endif // ASH_WM_WINDOW_H_ | 340 #endif // ASH_WM_WINDOW_H_ |
| OLD | NEW |