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/drag_details.h" | 9 #include "ash/wm/drag_details.h" |
10 #include "ash/wm/wm_types.h" | 10 #include "ash/wm/wm_types.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
15 #include "ui/base/ui_base_types.h" | 15 #include "ui/base/ui_base_types.h" |
16 | 16 |
17 namespace aura { | 17 namespace aura { |
18 class Window; | 18 class Window; |
19 } | 19 } |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 class Rect; | 22 class Rect; |
23 } | 23 } |
24 | 24 |
25 namespace ash { | 25 namespace ash { |
26 namespace internal { | |
27 class WorkspaceLayoutManager; | |
28 } | |
26 | 29 |
27 namespace wm { | 30 namespace wm { |
28 class WindowStateDelegate; | 31 class WindowStateDelegate; |
29 class WindowStateObserver; | 32 class WindowStateObserver; |
30 | 33 |
31 // WindowState manages and defines ash specific window state and | 34 // WindowState manages and defines ash specific window state and |
32 // behavior. Ash specific per-window state (such as ones that controls | 35 // behavior. Ash specific per-window state (such as ones that controls |
33 // window manager behavior) and ash specific window behavior (such as | 36 // window manager behavior) and ash specific window behavior (such as |
34 // maximize, minimize, snap sizing etc) should be added here instead | 37 // maximize, minimize, snap sizing etc) should be added here instead |
35 // of defining separate functions (like |MaximizeWindow(aura::Window* | 38 // of defining separate functions (like |MaximizeWindow(aura::Window* |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 bool IsNormalShowState() const; | 90 bool IsNormalShowState() const; |
88 | 91 |
89 // True if the window's show type is SHOW_TYPE_NORMAL or SHOW_TYPE_DEFAULT. | 92 // True if the window's show type is SHOW_TYPE_NORMAL or SHOW_TYPE_DEFAULT. |
90 // Unlike IsNormalShowState(), returns false if the window's show type is | 93 // Unlike IsNormalShowState(), returns false if the window's show type is |
91 // SHOW_TYPE_LEFT_SNAPPED or SHOW_TYPE_RIGHT_SNAPPED. | 94 // SHOW_TYPE_LEFT_SNAPPED or SHOW_TYPE_RIGHT_SNAPPED. |
92 bool IsNormalShowType() const; | 95 bool IsNormalShowType() const; |
93 | 96 |
94 bool IsActive() const; | 97 bool IsActive() const; |
95 bool IsDocked() const; | 98 bool IsDocked() const; |
96 bool IsSnapped() const; | 99 bool IsSnapped() const; |
100 bool IsPanel() const; | |
97 | 101 |
98 // Checks if the window can change its state accordingly. | 102 // Checks if the window can change its state accordingly. |
99 bool CanMaximize() const; | 103 bool CanMaximize() const; |
100 bool CanMinimize() const; | 104 bool CanMinimize() const; |
101 bool CanResize() const; | 105 bool CanResize() const; |
102 bool CanSnap() const; | 106 bool CanSnap() const; |
103 bool CanActivate() const; | 107 bool CanActivate() const; |
104 | 108 |
105 // Returns true if the window has restore bounds. | 109 // Returns true if the window has restore bounds. |
106 bool HasRestoreBounds() const; | 110 bool HasRestoreBounds() const; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 int window_component, | 268 int window_component, |
265 aura::client::WindowMoveSource source); | 269 aura::client::WindowMoveSource source); |
266 | 270 |
267 // Deletes and clears a pointer to DragDetails. This should be done when the | 271 // Deletes and clears a pointer to DragDetails. This should be done when the |
268 // resizer gets destroyed. | 272 // resizer gets destroyed. |
269 void DeleteDragDetails(); | 273 void DeleteDragDetails(); |
270 | 274 |
271 // Sets the currently stored restore bounds and clears the restore bounds. | 275 // Sets the currently stored restore bounds and clears the restore bounds. |
272 void SetAndClearRestoreBounds(); | 276 void SetAndClearRestoreBounds(); |
273 | 277 |
278 // Adjusts the |bounds| so that they are flush with the edge of the | |
279 // workspace if the window represented by |window_state| is side snapped. | |
280 void AdjustSnappedBounds(gfx::Rect* bounds); | |
281 | |
274 // Returns a pointer to DragDetails during drag operations. | 282 // Returns a pointer to DragDetails during drag operations. |
275 const DragDetails* drag_details() const { return drag_details_.get(); } | 283 const DragDetails* drag_details() const { return drag_details_.get(); } |
276 DragDetails* drag_details() { return drag_details_.get(); } | 284 DragDetails* drag_details() { return drag_details_.get(); } |
277 | 285 |
278 // aura::WindowObserver overrides: | 286 // aura::WindowObserver overrides: |
279 virtual void OnWindowPropertyChanged(aura::Window* window, | 287 virtual void OnWindowPropertyChanged(aura::Window* window, |
280 const void* key, | 288 const void* key, |
281 intptr_t old) OVERRIDE; | 289 intptr_t old) OVERRIDE; |
282 | 290 |
283 private: | 291 private: |
292 friend class DefaultState; | |
293 // TODO(oshima): Move more logic from WLM to this class and remove | |
294 // this friend. | |
295 friend class internal::WorkspaceLayoutManager; | |
296 | |
297 WindowStateDelegate* delegate() { return delegate_.get(); } | |
298 | |
284 // Snaps the window to left or right of the desktop with given bounds. | 299 // Snaps the window to left or right of the desktop with given bounds. |
285 void SnapWindow(WindowShowType left_or_right, | 300 void SnapWindow(WindowShowType left_or_right, |
286 const gfx::Rect& bounds); | 301 const gfx::Rect& bounds); |
287 | 302 |
288 // Sets the window show type and updates the show state if necessary. | 303 // Sets the window show type and updates the show state if necessary. |
289 void SetWindowShowType(WindowShowType new_window_show_type); | 304 // Note that this does not update the window bounds. |
305 void UpdateWindowShowType(WindowShowType new_window_show_type); | |
306 | |
307 void NotifyPreShowTypeChange(WindowShowType old_window_show_type); | |
308 void NotifyPostShowTypeChange(WindowShowType old_window_show_type); | |
309 | |
310 void SetBoundsDirect(const gfx::Rect& bounds); | |
311 void SetBoundsDirectAnimated(const gfx::Rect& bounds); | |
290 | 312 |
291 // The owner of this window settings. | 313 // The owner of this window settings. |
292 aura::Window* window_; | 314 aura::Window* window_; |
293 scoped_ptr<WindowStateDelegate> delegate_; | 315 scoped_ptr<WindowStateDelegate> delegate_; |
294 | 316 |
295 bool window_position_managed_; | 317 bool window_position_managed_; |
296 bool bounds_changed_by_user_; | 318 bool bounds_changed_by_user_; |
297 bool panel_attached_; | 319 bool panel_attached_; |
298 bool continue_drag_after_reparent_; | 320 bool continue_drag_after_reparent_; |
299 bool ignored_by_shelf_; | 321 bool ignored_by_shelf_; |
300 bool can_consume_system_keys_; | 322 bool can_consume_system_keys_; |
301 bool top_row_keys_are_function_keys_; | 323 bool top_row_keys_are_function_keys_; |
302 scoped_ptr<DragDetails> drag_details_; | 324 scoped_ptr<DragDetails> drag_details_; |
303 | 325 |
304 bool unminimize_to_restore_bounds_; | 326 bool unminimize_to_restore_bounds_; |
305 bool hide_shelf_when_fullscreen_; | 327 bool hide_shelf_when_fullscreen_; |
306 bool animate_to_fullscreen_; | 328 bool animate_to_fullscreen_; |
307 bool minimum_visibility_; | 329 bool minimum_visibility_; |
308 | 330 |
309 // A property to remember the window position which was set before the | 331 // A property to remember the window position which was set before the |
310 // auto window position manager changed the window bounds, so that it can get | 332 // auto window position manager changed the window bounds, so that it can get |
311 // restored when only this one window gets shown. | 333 // restored when only this one window gets shown. |
312 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; | 334 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; |
313 | 335 |
314 ObserverList<WindowStateObserver> observer_list_; | 336 ObserverList<WindowStateObserver> observer_list_; |
315 | 337 |
316 // True when in SetWindowShowType(). This is used to avoid reentrance. | 338 // True to ignore a property change event to avoid reentrance. |
pkotwicz
2014/02/12 22:27:27
How about: "True to ignore a property change event
oshima
2014/02/13 14:52:34
Done.
| |
317 bool in_set_window_show_type_; | 339 bool ignore_property_change_; |
318 | 340 |
319 WindowShowType window_show_type_; | 341 WindowShowType window_show_type_; |
320 | 342 |
321 scoped_ptr<State> current_state_; | 343 scoped_ptr<State> current_state_; |
322 | 344 |
323 DISALLOW_COPY_AND_ASSIGN(WindowState); | 345 DISALLOW_COPY_AND_ASSIGN(WindowState); |
324 }; | 346 }; |
325 | 347 |
326 // Returns the WindowState for active window. Returns |NULL| | 348 // Returns the WindowState for active window. Returns |NULL| |
327 // if there is no active window. | 349 // if there is no active window. |
328 ASH_EXPORT WindowState* GetActiveWindowState(); | 350 ASH_EXPORT WindowState* GetActiveWindowState(); |
329 | 351 |
330 // Returns the WindowState for |window|. Creates WindowState | 352 // Returns the WindowState for |window|. Creates WindowState |
331 // if it didn't exist. The settings object is owned by |window|. | 353 // if it didn't exist. The settings object is owned by |window|. |
332 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); | 354 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); |
333 | 355 |
334 // const version of GetWindowState. | 356 // const version of GetWindowState. |
335 ASH_EXPORT const WindowState* | 357 ASH_EXPORT const WindowState* |
336 GetWindowState(const aura::Window* window); | 358 GetWindowState(const aura::Window* window); |
337 | 359 |
338 } // namespace wm | 360 } // namespace wm |
339 } // namespace ash | 361 } // namespace ash |
340 | 362 |
341 #endif // ASH_WM_WINDOW_STATE_H_ | 363 #endif // ASH_WM_WINDOW_STATE_H_ |
OLD | NEW |