| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_COMMON_WM_WM_WINDOW_H_ | |
| 6 #define ASH_COMMON_WM_WM_WINDOW_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "ash/ash_export.h" | |
| 12 #include "base/strings/string16.h" | |
| 13 #include "base/time/time.h" | |
| 14 #include "ui/base/ui_base_types.h" | |
| 15 #include "ui/compositor/layer_animation_element.h" | |
| 16 #include "ui/wm/core/window_animations.h" | |
| 17 #include "ui/wm/public/window_types.h" | |
| 18 | |
| 19 namespace display { | |
| 20 class Display; | |
| 21 } | |
| 22 | |
| 23 namespace gfx { | |
| 24 class Point; | |
| 25 class Rect; | |
| 26 class Size; | |
| 27 class Transform; | |
| 28 } | |
| 29 | |
| 30 namespace ui { | |
| 31 class Layer; | |
| 32 } | |
| 33 | |
| 34 namespace ash { | |
| 35 namespace wm { | |
| 36 | |
| 37 class WMEvent; | |
| 38 class WmGlobals; | |
| 39 class WmLayoutManager; | |
| 40 class WmRootWindowController; | |
| 41 class WmWindowObserver; | |
| 42 enum class WmWindowProperty; | |
| 43 class WindowState; | |
| 44 | |
| 45 // This class exists as a porting layer to allow ash/wm to work with | |
| 46 // aura::Window or mus::Window. See aura::Window for details on the functions. | |
| 47 class ASH_EXPORT WmWindow { | |
| 48 public: | |
| 49 // See comments in SetBoundsInScreen(). | |
| 50 enum class BoundsInScreenBehavior { | |
| 51 USE_LOCAL_COORDINATES, | |
| 52 USE_SCREEN_COORDINATES, | |
| 53 }; | |
| 54 | |
| 55 WmWindow* GetRootWindow() { | |
| 56 return const_cast<WmWindow*>( | |
| 57 const_cast<const WmWindow*>(this)->GetRootWindow()); | |
| 58 } | |
| 59 virtual const WmWindow* GetRootWindow() const = 0; | |
| 60 virtual WmRootWindowController* GetRootWindowController() = 0; | |
| 61 | |
| 62 // TODO(sky): fix constness. | |
| 63 virtual WmGlobals* GetGlobals() const = 0; | |
| 64 | |
| 65 // Used for debugging. | |
| 66 virtual void SetName(const char* name) = 0; | |
| 67 | |
| 68 virtual base::string16 GetTitle() const = 0; | |
| 69 | |
| 70 // See shell_window_ids.h for list of known ids. | |
| 71 virtual void SetShellWindowId(int id) = 0; | |
| 72 virtual int GetShellWindowId() const = 0; | |
| 73 virtual WmWindow* GetChildByShellWindowId(int id) = 0; | |
| 74 | |
| 75 virtual ui::wm::WindowType GetType() const = 0; | |
| 76 | |
| 77 // TODO(sky): seems like this shouldn't be exposed. | |
| 78 virtual ui::Layer* GetLayer() = 0; | |
| 79 | |
| 80 virtual display::Display GetDisplayNearestWindow() = 0; | |
| 81 | |
| 82 virtual bool HasNonClientArea() = 0; | |
| 83 virtual int GetNonClientComponent(const gfx::Point& location) = 0; | |
| 84 | |
| 85 virtual gfx::Point ConvertPointToTarget(const WmWindow* target, | |
| 86 const gfx::Point& point) const = 0; | |
| 87 virtual gfx::Point ConvertPointToScreen(const gfx::Point& point) const = 0; | |
| 88 virtual gfx::Point ConvertPointFromScreen(const gfx::Point& point) const = 0; | |
| 89 virtual gfx::Rect ConvertRectToScreen(const gfx::Rect& rect) const = 0; | |
| 90 virtual gfx::Rect ConvertRectFromScreen(const gfx::Rect& rect) const = 0; | |
| 91 | |
| 92 virtual gfx::Size GetMinimumSize() const = 0; | |
| 93 virtual gfx::Size GetMaximumSize() const = 0; | |
| 94 | |
| 95 // Returns the visibility requested by this window. IsVisible() takes into | |
| 96 // account the visibility of the layer and ancestors, where as this tracks | |
| 97 // whether Show() without a Hide() has been invoked. | |
| 98 virtual bool GetTargetVisibility() const = 0; | |
| 99 | |
| 100 virtual bool IsVisible() const = 0; | |
| 101 | |
| 102 virtual void SetOpacity(float opacity) = 0; | |
| 103 virtual float GetTargetOpacity() const = 0; | |
| 104 | |
| 105 virtual void SetTransform(const gfx::Transform& transform) = 0; | |
| 106 virtual gfx::Transform GetTargetTransform() const = 0; | |
| 107 | |
| 108 virtual bool IsSystemModal() const = 0; | |
| 109 | |
| 110 virtual bool GetBoolProperty(WmWindowProperty key) = 0; | |
| 111 virtual int GetIntProperty(WmWindowProperty key) = 0; | |
| 112 | |
| 113 WindowState* GetWindowState() { | |
| 114 return const_cast<WindowState*>( | |
| 115 const_cast<const WmWindow*>(this)->GetWindowState()); | |
| 116 } | |
| 117 virtual const WindowState* GetWindowState() const = 0; | |
| 118 | |
| 119 virtual WmWindow* GetToplevelWindow() = 0; | |
| 120 | |
| 121 // See aura::client::ParentWindowWithContext() for details of what this does. | |
| 122 virtual void SetParentUsingContext(WmWindow* context, | |
| 123 const gfx::Rect& screen_bounds) = 0; | |
| 124 virtual void AddChild(WmWindow* window) = 0; | |
| 125 | |
| 126 virtual WmWindow* GetParent() = 0; | |
| 127 | |
| 128 WmWindow* GetTransientParent() { | |
| 129 return const_cast<WmWindow*>( | |
| 130 const_cast<const WmWindow*>(this)->GetTransientParent()); | |
| 131 } | |
| 132 virtual const WmWindow* GetTransientParent() const = 0; | |
| 133 virtual std::vector<WmWindow*> GetTransientChildren() = 0; | |
| 134 | |
| 135 virtual void SetLayoutManager( | |
| 136 std::unique_ptr<WmLayoutManager> layout_manager) = 0; | |
| 137 virtual WmLayoutManager* GetLayoutManager() = 0; | |
| 138 | |
| 139 // |type| is WindowVisibilityAnimationType. Has to be an int to match aura. | |
| 140 virtual void SetVisibilityAnimationType(int type) = 0; | |
| 141 virtual void SetVisibilityAnimationDuration(base::TimeDelta delta) = 0; | |
| 142 virtual void SetVisibilityAnimationTransition( | |
| 143 ::wm::WindowVisibilityAnimationTransition transition) = 0; | |
| 144 virtual void Animate(::wm::WindowAnimationType type) = 0; | |
| 145 virtual void StopAnimatingProperty( | |
| 146 ui::LayerAnimationElement::AnimatableProperty property) = 0; | |
| 147 virtual void SetChildWindowVisibilityChangesAnimated() = 0; | |
| 148 | |
| 149 // See description in ui::Layer. | |
| 150 virtual void SetMasksToBounds(bool value) = 0; | |
| 151 | |
| 152 virtual void SetBounds(const gfx::Rect& bounds) = 0; | |
| 153 virtual void SetBoundsWithTransitionDelay(const gfx::Rect& bounds, | |
| 154 base::TimeDelta delta) = 0; | |
| 155 // Sets the bounds in such a way that LayoutManagers are circumvented. | |
| 156 virtual void SetBoundsDirect(const gfx::Rect& bounds) = 0; | |
| 157 virtual void SetBoundsDirectAnimated(const gfx::Rect& bounds) = 0; | |
| 158 virtual void SetBoundsDirectCrossFade(const gfx::Rect& bounds) = 0; | |
| 159 | |
| 160 // Sets the bounds in two distinct ways. The exact behavior is dictated by | |
| 161 // the value of BoundsInScreenBehavior set on the parent: | |
| 162 // | |
| 163 // USE_LOCAL_COORDINATES: the bounds are applied as is to the window. In other | |
| 164 // words this behaves the same as if SetBounds(bounds_in_screen) was used. | |
| 165 // This is the default. | |
| 166 // USE_SCREEN_COORDINATES: the bounds are actual screen bounds and converted | |
| 167 // from the display. In this case the window may move to a different | |
| 168 // display if allowed (see SetDescendantsStayInSameRootWindow()). | |
| 169 virtual void SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | |
| 170 const display::Display& dst_display) = 0; | |
| 171 virtual gfx::Rect GetBoundsInScreen() const = 0; | |
| 172 virtual const gfx::Rect& GetBounds() const = 0; | |
| 173 virtual gfx::Rect GetTargetBounds() = 0; | |
| 174 | |
| 175 virtual void ClearRestoreBounds() = 0; | |
| 176 virtual void SetRestoreBoundsInScreen(const gfx::Rect& bounds) = 0; | |
| 177 virtual gfx::Rect GetRestoreBoundsInScreen() const = 0; | |
| 178 | |
| 179 virtual bool Contains(const WmWindow* other) const = 0; | |
| 180 | |
| 181 virtual void SetShowState(ui::WindowShowState show_state) = 0; | |
| 182 virtual ui::WindowShowState GetShowState() const = 0; | |
| 183 | |
| 184 virtual void SetRestoreShowState(ui::WindowShowState show_state) = 0; | |
| 185 | |
| 186 // If |value| is true the window can not be moved to another root, regardless | |
| 187 // of the bounds set on it. | |
| 188 virtual void SetLockedToRoot(bool value) = 0; | |
| 189 | |
| 190 virtual void SetCapture() = 0; | |
| 191 virtual bool HasCapture() = 0; | |
| 192 virtual void ReleaseCapture() = 0; | |
| 193 | |
| 194 virtual bool HasRestoreBounds() const = 0; | |
| 195 | |
| 196 virtual void SetAlwaysOnTop(bool value) = 0; | |
| 197 virtual bool IsAlwaysOnTop() const = 0; | |
| 198 | |
| 199 virtual void Hide() = 0; | |
| 200 virtual void Show() = 0; | |
| 201 | |
| 202 // Requests the window to close and destroy itself. This is intended to | |
| 203 // forward to an associated widget. | |
| 204 virtual void CloseWidget() = 0; | |
| 205 | |
| 206 virtual bool IsFocused() const = 0; | |
| 207 | |
| 208 virtual bool IsActive() const = 0; | |
| 209 virtual void Activate() = 0; | |
| 210 virtual void Deactivate() = 0; | |
| 211 | |
| 212 virtual void SetFullscreen() = 0; | |
| 213 | |
| 214 virtual void Maximize() = 0; | |
| 215 virtual void Minimize() = 0; | |
| 216 virtual void Unminimize() = 0; | |
| 217 | |
| 218 virtual bool CanMaximize() const = 0; | |
| 219 virtual bool CanMinimize() const = 0; | |
| 220 virtual bool CanResize() const = 0; | |
| 221 virtual bool CanActivate() const = 0; | |
| 222 | |
| 223 virtual void StackChildAtTop(WmWindow* child) = 0; | |
| 224 virtual void StackChildAtBottom(WmWindow* child) = 0; | |
| 225 virtual void StackChildAbove(WmWindow* child, WmWindow* target) = 0; | |
| 226 virtual void StackChildBelow(WmWindow* child, WmWindow* target) = 0; | |
| 227 | |
| 228 virtual std::vector<WmWindow*> GetChildren() = 0; | |
| 229 | |
| 230 // Shows/hides the resize shadow. |component| is the component to show the | |
| 231 // shadow for (one of the constants in ui/base/hit_test.h). | |
| 232 virtual void ShowResizeShadow(int component) = 0; | |
| 233 virtual void HideResizeShadow() = 0; | |
| 234 | |
| 235 // See description in SetBoundsInScreen(). | |
| 236 virtual void SetBoundsInScreenBehaviorForChildren(BoundsInScreenBehavior) = 0; | |
| 237 | |
| 238 // See description of SnapToPixelBoundaryIfNecessary(). | |
| 239 virtual void SetSnapsChildrenToPhysicalPixelBoundary() = 0; | |
| 240 | |
| 241 // If an ancestor has been set to snap children to pixel boundaries, then | |
| 242 // snaps the layer associated with this window to the layer associated with | |
| 243 // the ancestor. | |
| 244 virtual void SnapToPixelBoundaryIfNecessary() = 0; | |
| 245 | |
| 246 // Makes the hit region for children slightly larger for easier resizing. | |
| 247 virtual void SetChildrenUseExtendedHitRegion() = 0; | |
| 248 | |
| 249 // Sets whether descendants of this should not be moved to a different | |
| 250 // container. This is used by SetBoundsInScreen(). | |
| 251 virtual void SetDescendantsStayInSameRootWindow(bool value) = 0; | |
| 252 | |
| 253 virtual void AddObserver(WmWindowObserver* observer) = 0; | |
| 254 virtual void RemoveObserver(WmWindowObserver* observer) = 0; | |
| 255 | |
| 256 protected: | |
| 257 virtual ~WmWindow() {} | |
| 258 }; | |
| 259 | |
| 260 } // namespace wm | |
| 261 } // namespace ash | |
| 262 | |
| 263 #endif // ASH_COMMON_WM_WM_WINDOW_H_ | |
| OLD | NEW |