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