| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_STATE_H_ | 5 #ifndef ASH_WM_WINDOW_STATE_H_ |
| 6 #define ASH_WM_WINDOW_STATE_H_ | 6 #define ASH_WM_WINDOW_STATE_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/wm/wm_types.h" | 9 #include "ash/wm/wm_types.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
| 14 #include "ui/base/ui_base_types.h" | 14 #include "ui/base/ui_base_types.h" |
| 15 | 15 |
| 16 namespace aura { | 16 namespace aura { |
| 17 class Window; | 17 class Window; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace gfx { | 20 namespace gfx { |
| 21 class Rect; | 21 class Rect; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 class WindowResizer; | 25 class WindowResizer; |
| 26 | 26 |
| 27 namespace wm { | 27 namespace wm { |
| 28 class WindowStateDelegate; |
| 28 class WindowStateObserver; | 29 class WindowStateObserver; |
| 29 | 30 |
| 30 // WindowState manages and defines ash specific window state and | 31 // WindowState manages and defines ash specific window state and |
| 31 // behavior. Ash specific per-window state (such as ones that controls | 32 // behavior. Ash specific per-window state (such as ones that controls |
| 32 // window manager behavior) and ash specific window behavior (such as | 33 // window manager behavior) and ash specific window behavior (such as |
| 33 // maximize, minimize, snap sizing etc) should be added here instead | 34 // maximize, minimize, snap sizing etc) should be added here instead |
| 34 // of defining separate functions (like |MaximizeWindow(aura::Window* | 35 // of defining separate functions (like |MaximizeWindow(aura::Window* |
| 35 // window)|) or using aura Window property. | 36 // window)|) or using aura Window property. |
| 36 // The WindowState gets created when first accessed by | 37 // The WindowState gets created when first accessed by |
| 37 // |wm::GetWindowState|, and deleted when the window is deleted. | 38 // |wm::GetWindowState|, and deleted when the window is deleted. |
| 38 // Prefer using this class instead of passing aura::Window* around in | 39 // Prefer using this class instead of passing aura::Window* around in |
| 39 // ash code as this is often what you need to interact with, and | 40 // ash code as this is often what you need to interact with, and |
| 40 // accessing the window using |window()| is cheap. | 41 // accessing the window using |window()| is cheap. |
| 41 class ASH_EXPORT WindowState : public aura::WindowObserver { | 42 class ASH_EXPORT WindowState : public aura::WindowObserver { |
| 42 public: | 43 public: |
| 43 static bool IsMaximizedOrFullscreenState(ui::WindowShowState state); | 44 static bool IsMaximizedOrFullscreenState(ui::WindowShowState state); |
| 44 | 45 |
| 45 explicit WindowState(aura::Window* window); | 46 explicit WindowState(aura::Window* window); |
| 46 virtual ~WindowState(); | 47 virtual ~WindowState(); |
| 47 | 48 |
| 48 aura::Window* window() { return window_; } | 49 aura::Window* window() { return window_; } |
| 49 const aura::Window* window() const { return window_; } | 50 const aura::Window* window() const { return window_; } |
| 50 | 51 |
| 52 void SetDelegate(WindowStateDelegate* delegate); |
| 53 |
| 51 // Returns the window's current show state. | 54 // Returns the window's current show state. |
| 52 ui::WindowShowState GetShowState() const; | 55 ui::WindowShowState GetShowState() const; |
| 53 | 56 |
| 54 // Returns the window's current ash show type. | 57 // Returns the window's current ash show type. |
| 55 // Refer to WindowShowType definition in wm_types.h as for why Ash | 58 // Refer to WindowShowType definition in wm_types.h as for why Ash |
| 56 // has its own show type. | 59 // has its own show type. |
| 57 WindowShowType window_show_type() const { return window_show_type_; } | 60 WindowShowType window_show_type() const { return window_show_type_; } |
| 58 | 61 |
| 59 // Predicates to check window state. | 62 // Predicates to check window state. |
| 60 bool IsMinimized() const; | 63 bool IsMinimized() const; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 // Returns true if the window has restore bounds. | 79 // Returns true if the window has restore bounds. |
| 77 bool HasRestoreBounds() const; | 80 bool HasRestoreBounds() const; |
| 78 | 81 |
| 79 void Maximize(); | 82 void Maximize(); |
| 80 void Minimize(); | 83 void Minimize(); |
| 81 void Unminimize(); | 84 void Unminimize(); |
| 82 void Activate(); | 85 void Activate(); |
| 83 void Deactivate(); | 86 void Deactivate(); |
| 84 void Restore(); | 87 void Restore(); |
| 85 void ToggleMaximized(); | 88 void ToggleMaximized(); |
| 89 void ToggleFullscreen(); |
| 86 void SnapLeft(const gfx::Rect& bounds); | 90 void SnapLeft(const gfx::Rect& bounds); |
| 87 void SnapRight(const gfx::Rect& bounds); | 91 void SnapRight(const gfx::Rect& bounds); |
| 88 | 92 |
| 89 // Sets the window's bounds in screen coordinates. | 93 // Sets the window's bounds in screen coordinates. |
| 90 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen); | 94 void SetBoundsInScreen(const gfx::Rect& bounds_in_screen); |
| 91 | 95 |
| 92 // Saves the current bounds to be used as a restore bounds. | 96 // Saves the current bounds to be used as a restore bounds. |
| 93 void SaveCurrentBoundsForRestore(); | 97 void SaveCurrentBoundsForRestore(); |
| 94 | 98 |
| 95 // Same as |GetRestoreBoundsInScreen| except that it returns the | 99 // Same as |GetRestoreBoundsInScreen| except that it returns the |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Gets/sets whether the shelf should be hidden when this window is | 131 // Gets/sets whether the shelf should be hidden when this window is |
| 128 // fullscreen. | 132 // fullscreen. |
| 129 bool hide_shelf_when_fullscreen() const { | 133 bool hide_shelf_when_fullscreen() const { |
| 130 return hide_shelf_when_fullscreen_; | 134 return hide_shelf_when_fullscreen_; |
| 131 } | 135 } |
| 132 | 136 |
| 133 void set_hide_shelf_when_fullscreen(bool value) { | 137 void set_hide_shelf_when_fullscreen(bool value) { |
| 134 hide_shelf_when_fullscreen_ = value; | 138 hide_shelf_when_fullscreen_ = value; |
| 135 } | 139 } |
| 136 | 140 |
| 141 // Sets/gets the flag to suppress the cross-fade animation for |
| 142 // the transition to the fullscreen state. |
| 143 bool animate_to_fullscreen() const { |
| 144 return animate_to_fullscreen_; |
| 145 } |
| 146 void set_animate_to_fullscreen(bool value) { |
| 147 animate_to_fullscreen_ = value; |
| 148 } |
| 149 |
| 137 // Gets/Sets the bounds of the window before it was moved by the auto window | 150 // Gets/Sets the bounds of the window before it was moved by the auto window |
| 138 // management. As long as it was not auto-managed, it will return NULL. | 151 // management. As long as it was not auto-managed, it will return NULL. |
| 139 const gfx::Rect* pre_auto_manage_window_bounds() const { | 152 const gfx::Rect* pre_auto_manage_window_bounds() const { |
| 140 return pre_auto_manage_window_bounds_.get(); | 153 return pre_auto_manage_window_bounds_.get(); |
| 141 } | 154 } |
| 142 void SetPreAutoManageWindowBounds(const gfx::Rect& bounds); | 155 void SetPreAutoManageWindowBounds(const gfx::Rect& bounds); |
| 143 | 156 |
| 144 // Layout related properties | 157 // Layout related properties |
| 145 | 158 |
| 146 void AddObserver(WindowStateObserver* observer); | 159 void AddObserver(WindowStateObserver* observer); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 intptr_t old) OVERRIDE; | 239 intptr_t old) OVERRIDE; |
| 227 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 240 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 228 | 241 |
| 229 private: | 242 private: |
| 230 // Snaps the window to left or right of the desktop with given bounds. | 243 // Snaps the window to left or right of the desktop with given bounds. |
| 231 void SnapWindow(WindowShowType left_or_right, | 244 void SnapWindow(WindowShowType left_or_right, |
| 232 const gfx::Rect& bounds); | 245 const gfx::Rect& bounds); |
| 233 | 246 |
| 234 // The owner of this window settings. | 247 // The owner of this window settings. |
| 235 aura::Window* window_; | 248 aura::Window* window_; |
| 249 scoped_ptr<WindowStateDelegate> delegate_; |
| 236 | 250 |
| 237 bool tracked_by_workspace_; | 251 bool tracked_by_workspace_; |
| 238 bool window_position_managed_; | 252 bool window_position_managed_; |
| 239 bool bounds_changed_by_user_; | 253 bool bounds_changed_by_user_; |
| 240 bool panel_attached_; | 254 bool panel_attached_; |
| 241 bool continue_drag_after_reparent_; | 255 bool continue_drag_after_reparent_; |
| 242 bool ignored_by_shelf_; | 256 bool ignored_by_shelf_; |
| 243 bool can_consume_system_keys_; | 257 bool can_consume_system_keys_; |
| 244 bool top_row_keys_are_function_keys_; | 258 bool top_row_keys_are_function_keys_; |
| 245 WindowResizer* window_resizer_; | 259 WindowResizer* window_resizer_; |
| 246 | 260 |
| 247 bool always_restores_to_restore_bounds_; | 261 bool always_restores_to_restore_bounds_; |
| 248 bool hide_shelf_when_fullscreen_; | 262 bool hide_shelf_when_fullscreen_; |
| 263 bool animate_to_fullscreen_; |
| 249 | 264 |
| 250 // A property to remember the window position which was set before the | 265 // A property to remember the window position which was set before the |
| 251 // auto window position manager changed the window bounds, so that it can get | 266 // auto window position manager changed the window bounds, so that it can get |
| 252 // restored when only this one window gets shown. | 267 // restored when only this one window gets shown. |
| 253 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; | 268 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; |
| 254 | 269 |
| 255 ObserverList<WindowStateObserver> observer_list_; | 270 ObserverList<WindowStateObserver> observer_list_; |
| 256 | 271 |
| 257 WindowShowType window_show_type_; | 272 WindowShowType window_show_type_; |
| 258 | 273 |
| 259 DISALLOW_COPY_AND_ASSIGN(WindowState); | 274 DISALLOW_COPY_AND_ASSIGN(WindowState); |
| 260 }; | 275 }; |
| 261 | 276 |
| 262 // Returns the WindowState for active window. Returns |NULL| | 277 // Returns the WindowState for active window. Returns |NULL| |
| 263 // if there is no active window. | 278 // if there is no active window. |
| 264 ASH_EXPORT WindowState* GetActiveWindowState(); | 279 ASH_EXPORT WindowState* GetActiveWindowState(); |
| 265 | 280 |
| 266 // Returns the WindowState for |window|. Creates WindowState | 281 // Returns the WindowState for |window|. Creates WindowState |
| 267 // if it didn't exist. The settings object is owned by |window|. | 282 // if it didn't exist. The settings object is owned by |window|. |
| 268 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); | 283 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); |
| 269 | 284 |
| 270 // const version of GetWindowState. | 285 // const version of GetWindowState. |
| 271 ASH_EXPORT const WindowState* | 286 ASH_EXPORT const WindowState* |
| 272 GetWindowState(const aura::Window* window); | 287 GetWindowState(const aura::Window* window); |
| 273 | 288 |
| 274 } // namespace wm | 289 } // namespace wm |
| 275 } // namespace ash | 290 } // namespace ash |
| 276 | 291 |
| 277 #endif // ASH_WM_WINDOW_STATE_H_ | 292 #endif // ASH_WM_WINDOW_STATE_H_ |
| OLD | NEW |