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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 int window_component, | 267 int window_component, |
265 aura::client::WindowMoveSource source); | 268 aura::client::WindowMoveSource source); |
266 | 269 |
267 // Deletes and clears a pointer to DragDetails. This should be done when the | 270 // Deletes and clears a pointer to DragDetails. This should be done when the |
268 // resizer gets destroyed. | 271 // resizer gets destroyed. |
269 void DeleteDragDetails(); | 272 void DeleteDragDetails(); |
270 | 273 |
271 // Sets the currently stored restore bounds and clears the restore bounds. | 274 // Sets the currently stored restore bounds and clears the restore bounds. |
272 void SetAndClearRestoreBounds(); | 275 void SetAndClearRestoreBounds(); |
273 | 276 |
277 // Adjusts the |bounds| so that they are flush with the edge of the | |
278 // workspace if the window represented by |window_state| is side snapped. | |
279 void AdjustSnappedBounds(gfx::Rect* bounds); | |
280 | |
274 // Returns a pointer to DragDetails during drag operations. | 281 // Returns a pointer to DragDetails during drag operations. |
275 const DragDetails* drag_details() const { return drag_details_.get(); } | 282 const DragDetails* drag_details() const { return drag_details_.get(); } |
276 DragDetails* drag_details() { return drag_details_.get(); } | 283 DragDetails* drag_details() { return drag_details_.get(); } |
277 | 284 |
278 // aura::WindowObserver overrides: | 285 // aura::WindowObserver overrides: |
279 virtual void OnWindowPropertyChanged(aura::Window* window, | 286 virtual void OnWindowPropertyChanged(aura::Window* window, |
280 const void* key, | 287 const void* key, |
281 intptr_t old) OVERRIDE; | 288 intptr_t old) OVERRIDE; |
282 | 289 |
283 private: | 290 private: |
291 friend class DefaultState; | |
292 // TODO(oshima): Remove more logic from WLM and this. | |
pkotwicz
2014/02/12 05:10:00
Nit: Can you rephrase the TODO? I do not understan
oshima
2014/02/12 14:08:33
Done.
| |
293 friend class internal::WorkspaceLayoutManager; | |
294 | |
295 WindowStateDelegate* delegate() { return delegate_.get(); } | |
296 | |
284 // Snaps the window to left or right of the desktop with given bounds. | 297 // Snaps the window to left or right of the desktop with given bounds. |
285 void SnapWindow(WindowShowType left_or_right, | 298 void SnapWindow(WindowShowType left_or_right, |
286 const gfx::Rect& bounds); | 299 const gfx::Rect& bounds); |
287 | 300 |
288 // Sets the window show type and updates the show state if necessary. | 301 // Sets the window show type and updates the show state if necessary. |
289 void SetWindowShowType(WindowShowType new_window_show_type); | 302 // Note that this does not update the window bounds. |
303 void UpdateWindowShowType(WindowShowType new_window_show_type); | |
304 | |
305 void NotifyPreShowTypeChange(WindowShowType old_window_show_type); | |
306 void NotifyPostShowTypeChange(WindowShowType old_window_show_type); | |
307 | |
308 void SetBoundsDirect(const gfx::Rect& bounds); | |
309 void SetBoundsDirectAnimated(const gfx::Rect& bounds); | |
290 | 310 |
291 // The owner of this window settings. | 311 // The owner of this window settings. |
292 aura::Window* window_; | 312 aura::Window* window_; |
293 scoped_ptr<WindowStateDelegate> delegate_; | 313 scoped_ptr<WindowStateDelegate> delegate_; |
294 | 314 |
295 bool window_position_managed_; | 315 bool window_position_managed_; |
296 bool bounds_changed_by_user_; | 316 bool bounds_changed_by_user_; |
297 bool panel_attached_; | 317 bool panel_attached_; |
298 bool continue_drag_after_reparent_; | 318 bool continue_drag_after_reparent_; |
299 bool ignored_by_shelf_; | 319 bool ignored_by_shelf_; |
300 bool can_consume_system_keys_; | 320 bool can_consume_system_keys_; |
301 bool top_row_keys_are_function_keys_; | 321 bool top_row_keys_are_function_keys_; |
302 scoped_ptr<DragDetails> drag_details_; | 322 scoped_ptr<DragDetails> drag_details_; |
303 | 323 |
304 bool unminimize_to_restore_bounds_; | 324 bool unminimize_to_restore_bounds_; |
305 bool hide_shelf_when_fullscreen_; | 325 bool hide_shelf_when_fullscreen_; |
306 bool animate_to_fullscreen_; | 326 bool animate_to_fullscreen_; |
307 bool minimum_visibility_; | 327 bool minimum_visibility_; |
308 | 328 |
309 // A property to remember the window position which was set before the | 329 // 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 | 330 // auto window position manager changed the window bounds, so that it can get |
311 // restored when only this one window gets shown. | 331 // restored when only this one window gets shown. |
312 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; | 332 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; |
313 | 333 |
314 ObserverList<WindowStateObserver> observer_list_; | 334 ObserverList<WindowStateObserver> observer_list_; |
315 | 335 |
316 // True when in SetWindowShowType(). This is used to avoid reentrance. | 336 // True to ignore a property change event to avoid reentrance. |
317 bool in_set_window_show_type_; | 337 bool ignore_property_change_; |
318 | 338 |
319 WindowShowType window_show_type_; | 339 WindowShowType window_show_type_; |
320 | 340 |
321 scoped_ptr<State> current_state_; | 341 scoped_ptr<State> current_state_; |
322 | 342 |
323 DISALLOW_COPY_AND_ASSIGN(WindowState); | 343 DISALLOW_COPY_AND_ASSIGN(WindowState); |
324 }; | 344 }; |
325 | 345 |
326 // Returns the WindowState for active window. Returns |NULL| | 346 // Returns the WindowState for active window. Returns |NULL| |
327 // if there is no active window. | 347 // if there is no active window. |
328 ASH_EXPORT WindowState* GetActiveWindowState(); | 348 ASH_EXPORT WindowState* GetActiveWindowState(); |
329 | 349 |
330 // Returns the WindowState for |window|. Creates WindowState | 350 // Returns the WindowState for |window|. Creates WindowState |
331 // if it didn't exist. The settings object is owned by |window|. | 351 // if it didn't exist. The settings object is owned by |window|. |
332 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); | 352 ASH_EXPORT WindowState* GetWindowState(aura::Window* window); |
333 | 353 |
334 // const version of GetWindowState. | 354 // const version of GetWindowState. |
335 ASH_EXPORT const WindowState* | 355 ASH_EXPORT const WindowState* |
336 GetWindowState(const aura::Window* window); | 356 GetWindowState(const aura::Window* window); |
337 | 357 |
338 } // namespace wm | 358 } // namespace wm |
339 } // namespace ash | 359 } // namespace ash |
340 | 360 |
341 #endif // ASH_WM_WINDOW_STATE_H_ | 361 #endif // ASH_WM_WINDOW_STATE_H_ |
OLD | NEW |