| 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_COMMON_WM_WINDOW_H_ | 5 #ifndef ASH_WM_COMMON_WM_WINDOW_H_ |
| 6 #define ASH_WM_COMMON_WM_WINDOW_H_ | 6 #define ASH_WM_COMMON_WM_WINDOW_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "ui/base/ui_base_types.h" | 13 #include "ui/base/ui_base_types.h" |
| 13 #include "ui/wm/core/window_animations.h" | 14 #include "ui/wm/core/window_animations.h" |
| 14 #include "ui/wm/public/window_types.h" | 15 #include "ui/wm/public/window_types.h" |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 class Display; | 18 class Display; |
| 18 class Point; | 19 class Point; |
| 19 class Rect; | 20 class Rect; |
| 20 class Size; | 21 class Size; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace ui { | 24 namespace ui { |
| 24 class Layer; | 25 class Layer; |
| 25 } | 26 } |
| 26 | 27 |
| 28 namespace views { |
| 29 class Widget; |
| 30 } |
| 31 |
| 27 namespace ash { | 32 namespace ash { |
| 28 namespace wm { | 33 namespace wm { |
| 29 | 34 |
| 30 class WMEvent; | 35 class WMEvent; |
| 31 class WmGlobals; | 36 class WmGlobals; |
| 37 class WmLayoutManager; |
| 32 class WmRootWindowController; | 38 class WmRootWindowController; |
| 33 class WmWindowObserver; | 39 class WmWindowObserver; |
| 34 enum class WmWindowProperty; | 40 enum class WmWindowProperty; |
| 35 class WindowState; | 41 class WindowState; |
| 36 | 42 |
| 37 // This class exists as a porting layer to allow ash/wm to work with | 43 // This class exists as a porting layer to allow ash/wm to work with |
| 38 // aura::Window | 44 // aura::Window |
| 39 // or mus::Window. See aura::Window for details on the functions. | 45 // or mus::Window. See aura::Window for details on the functions. |
| 40 class ASH_EXPORT WmWindow { | 46 class ASH_EXPORT WmWindow { |
| 41 public: | 47 public: |
| 48 static WmWindow* Get(views::Widget* widget); |
| 49 |
| 42 WmWindow* GetRootWindow() { | 50 WmWindow* GetRootWindow() { |
| 43 return const_cast<WmWindow*>( | 51 return const_cast<WmWindow*>( |
| 44 const_cast<const WmWindow*>(this)->GetRootWindow()); | 52 const_cast<const WmWindow*>(this)->GetRootWindow()); |
| 45 } | 53 } |
| 46 virtual const WmWindow* GetRootWindow() const = 0; | 54 virtual const WmWindow* GetRootWindow() const = 0; |
| 47 virtual WmRootWindowController* GetRootWindowController() = 0; | 55 virtual WmRootWindowController* GetRootWindowController() = 0; |
| 48 | 56 |
| 49 // TODO(sky): fix constness. | 57 // TODO(sky): fix constness. |
| 50 virtual WmGlobals* GetGlobals() const = 0; | 58 virtual WmGlobals* GetGlobals() const = 0; |
| 51 | 59 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 62 virtual bool HasNonClientArea() = 0; | 70 virtual bool HasNonClientArea() = 0; |
| 63 virtual int GetNonClientComponent(const gfx::Point& location) = 0; | 71 virtual int GetNonClientComponent(const gfx::Point& location) = 0; |
| 64 | 72 |
| 65 virtual gfx::Point ConvertPointToTarget(const WmWindow* target, | 73 virtual gfx::Point ConvertPointToTarget(const WmWindow* target, |
| 66 const gfx::Point& point) const = 0; | 74 const gfx::Point& point) const = 0; |
| 67 virtual gfx::Point ConvertPointToScreen(const gfx::Point& point) const = 0; | 75 virtual gfx::Point ConvertPointToScreen(const gfx::Point& point) const = 0; |
| 68 virtual gfx::Point ConvertPointFromScreen(const gfx::Point& point) const = 0; | 76 virtual gfx::Point ConvertPointFromScreen(const gfx::Point& point) const = 0; |
| 69 virtual gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const = 0; | 77 virtual gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const = 0; |
| 70 virtual gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const = 0; | 78 virtual gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const = 0; |
| 71 | 79 |
| 72 virtual gfx::Size GetMinimumSize() = 0; | 80 virtual gfx::Size GetMinimumSize() const = 0; |
| 73 virtual gfx::Size GetMaximumSize() = 0; | 81 virtual gfx::Size GetMaximumSize() const = 0; |
| 74 | 82 |
| 75 // Returns the visibility requested by this window. IsVisible() takes into | 83 // Returns the visibility requested by this window. IsVisible() takes into |
| 76 // account the visibility of the layer and ancestors, where as this tracks | 84 // account the visibility of the layer and ancestors, where as this tracks |
| 77 // whether Show() without a Hide() has been invoked. | 85 // whether Show() without a Hide() has been invoked. |
| 78 virtual bool GetTargetVisibility() const = 0; | 86 virtual bool GetTargetVisibility() const = 0; |
| 79 | 87 |
| 80 virtual bool IsVisible() const = 0; | 88 virtual bool IsVisible() const = 0; |
| 81 | 89 |
| 82 virtual bool GetBoolProperty(WmWindowProperty key) = 0; | 90 virtual bool GetBoolProperty(WmWindowProperty key) = 0; |
| 83 | 91 |
| 84 WindowState* GetWindowState() { | 92 WindowState* GetWindowState() { |
| 85 return const_cast<WindowState*>( | 93 return const_cast<WindowState*>( |
| 86 const_cast<const WmWindow*>(this)->GetWindowState()); | 94 const_cast<const WmWindow*>(this)->GetWindowState()); |
| 87 } | 95 } |
| 88 virtual const WindowState* GetWindowState() const = 0; | 96 virtual const WindowState* GetWindowState() const = 0; |
| 89 | 97 |
| 90 virtual WmWindow* GetToplevelWindow() = 0; | 98 virtual WmWindow* GetToplevelWindow() = 0; |
| 91 | 99 |
| 92 // See aura::client::ParentWindowWithContext() for details of what this does. | 100 // See aura::client::ParentWindowWithContext() for details of what this does. |
| 93 virtual void SetParentUsingContext(WmWindow* context, | 101 virtual void SetParentUsingContext(WmWindow* context, |
| 94 const gfx::Rect& screen_bounds) = 0; | 102 const gfx::Rect& screen_bounds) = 0; |
| 95 virtual void AddChild(WmWindow* window) = 0; | 103 virtual void AddChild(WmWindow* window) = 0; |
| 96 | 104 |
| 97 virtual WmWindow* GetParent() = 0; | 105 virtual WmWindow* GetParent() = 0; |
| 98 | 106 |
| 99 virtual WmWindow* GetTransientParent() = 0; | 107 WmWindow* GetTransientParent() { |
| 108 return const_cast<WmWindow*>( |
| 109 const_cast<const WmWindow*>(this)->GetTransientParent()); |
| 110 } |
| 111 virtual const WmWindow* GetTransientParent() const = 0; |
| 100 virtual std::vector<WmWindow*> GetTransientChildren() = 0; | 112 virtual std::vector<WmWindow*> GetTransientChildren() = 0; |
| 101 | 113 |
| 114 virtual void SetLayoutManager( |
| 115 std::unique_ptr<WmLayoutManager> layout_manager) = 0; |
| 116 virtual WmLayoutManager* GetLayoutManager() = 0; |
| 117 |
| 102 // |type| is WindowVisibilityAnimationType. Has to be an int to match aura. | 118 // |type| is WindowVisibilityAnimationType. Has to be an int to match aura. |
| 103 virtual void SetVisibilityAnimationType(int type) = 0; | 119 virtual void SetVisibilityAnimationType(int type) = 0; |
| 120 virtual void SetVisibilityAnimationDuration(base::TimeDelta delta) = 0; |
| 104 virtual void Animate(::wm::WindowAnimationType type) = 0; | 121 virtual void Animate(::wm::WindowAnimationType type) = 0; |
| 105 | 122 |
| 106 virtual void SetBounds(const gfx::Rect& bounds) = 0; | 123 virtual void SetBounds(const gfx::Rect& bounds) = 0; |
| 107 virtual void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, | 124 virtual void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, |
| 108 base::TimeDelta delta) = 0; | 125 base::TimeDelta delta) = 0; |
| 109 // Sets the bounds in such a way that LayoutManagers are circumvented. | 126 // Sets the bounds in such a way that LayoutManagers are circumvented. |
| 110 virtual void SetBoundsDirect(const gfx::Rect& bounds) = 0; | 127 virtual void SetBoundsDirect(const gfx::Rect& bounds) = 0; |
| 111 virtual void SetBoundsDirectAnimated(const gfx::Rect& bounds) = 0; | 128 virtual void SetBoundsDirectAnimated(const gfx::Rect& bounds) = 0; |
| 112 virtual void SetBoundsDirectCrossFade(const gfx::Rect& bounds) = 0; | 129 virtual void SetBoundsDirectCrossFade(const gfx::Rect& bounds) = 0; |
| 113 virtual void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | 130 virtual void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 134 virtual void ReleaseCapture() = 0; | 151 virtual void ReleaseCapture() = 0; |
| 135 | 152 |
| 136 virtual bool HasRestoreBounds() const = 0; | 153 virtual bool HasRestoreBounds() const = 0; |
| 137 | 154 |
| 138 virtual void SetAlwaysOnTop(bool value) = 0; | 155 virtual void SetAlwaysOnTop(bool value) = 0; |
| 139 virtual bool IsAlwaysOnTop() const = 0; | 156 virtual bool IsAlwaysOnTop() const = 0; |
| 140 | 157 |
| 141 virtual void Hide() = 0; | 158 virtual void Hide() = 0; |
| 142 virtual void Show() = 0; | 159 virtual void Show() = 0; |
| 143 | 160 |
| 161 virtual bool IsFocused() const = 0; |
| 162 |
| 144 virtual bool IsActive() const = 0; | 163 virtual bool IsActive() const = 0; |
| 145 virtual void Activate() = 0; | 164 virtual void Activate() = 0; |
| 146 virtual void Deactivate() = 0; | 165 virtual void Deactivate() = 0; |
| 147 | 166 |
| 148 virtual void Maximize() = 0; | 167 virtual void Maximize() = 0; |
| 149 virtual void Minimize() = 0; | 168 virtual void Minimize() = 0; |
| 150 virtual void Unminimize() = 0; | 169 virtual void Unminimize() = 0; |
| 151 | 170 |
| 152 virtual bool CanMaximize() const = 0; | 171 virtual bool CanMaximize() const = 0; |
| 153 virtual bool CanMinimize() const = 0; | 172 virtual bool CanMinimize() const = 0; |
| 154 virtual bool CanResize() const = 0; | 173 virtual bool CanResize() const = 0; |
| 155 virtual bool CanActivate() const = 0; | 174 virtual bool CanActivate() const = 0; |
| 156 | 175 |
| 157 virtual void StackChildAtTop(WmWindow* child) = 0; | 176 virtual void StackChildAtTop(WmWindow* child) = 0; |
| 177 virtual void StackChildAtBottom(WmWindow* child) = 0; |
| 158 virtual void StackChildAbove(WmWindow* child, WmWindow* target) = 0; | 178 virtual void StackChildAbove(WmWindow* child, WmWindow* target) = 0; |
| 159 virtual void StackChildBelow(WmWindow* child, WmWindow* target) = 0; | 179 virtual void StackChildBelow(WmWindow* child, WmWindow* target) = 0; |
| 160 | 180 |
| 161 virtual std::vector<WmWindow*> GetChildren() = 0; | 181 virtual std::vector<WmWindow*> GetChildren() = 0; |
| 162 | 182 |
| 183 // If an ancestor has been set to snap children to pixel boundaries, then |
| 184 // snaps the layer associated with this window to the layer associated with |
| 185 // the ancestor. |
| 186 virtual void SnapToPixelBoundaryIfNecessary() = 0; |
| 187 |
| 163 virtual void AddObserver(WmWindowObserver* observer) = 0; | 188 virtual void AddObserver(WmWindowObserver* observer) = 0; |
| 164 virtual void RemoveObserver(WmWindowObserver* observer) = 0; | 189 virtual void RemoveObserver(WmWindowObserver* observer) = 0; |
| 165 | 190 |
| 166 protected: | 191 protected: |
| 167 virtual ~WmWindow() {} | 192 virtual ~WmWindow() {} |
| 168 }; | 193 }; |
| 169 | 194 |
| 170 } // namespace wm | 195 } // namespace wm |
| 171 } // namespace ash | 196 } // namespace ash |
| 172 | 197 |
| 173 #endif // ASH_WM_COMMON_WM_WINDOW_H_ | 198 #endif // ASH_WM_COMMON_WM_WINDOW_H_ |
| OLD | NEW |