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): Move more logic from WLM to this class and remove |
| 293 // this friend. |
| 294 friend class internal::WorkspaceLayoutManager; |
| 295 |
| 296 WindowStateDelegate* delegate() { return delegate_.get(); } |
| 297 |
284 // Snaps the window to left or right of the desktop with given bounds. | 298 // Snaps the window to left or right of the desktop with given bounds. |
285 void SnapWindow(WindowShowType left_or_right, | 299 void SnapWindow(WindowShowType left_or_right, |
286 const gfx::Rect& bounds); | 300 const gfx::Rect& bounds); |
287 | 301 |
288 // Sets the window show type and updates the show state if necessary. | 302 // Sets the window show type and updates the show state if necessary. |
289 void SetWindowShowType(WindowShowType new_window_show_type); | 303 // Note that this does not update the window bounds. |
| 304 void UpdateWindowShowType(WindowShowType new_window_show_type); |
| 305 |
| 306 void NotifyPreShowTypeChange(WindowShowType old_window_show_type); |
| 307 void NotifyPostShowTypeChange(WindowShowType old_window_show_type); |
| 308 |
| 309 void SetBoundsDirect(const gfx::Rect& bounds); |
| 310 void SetBoundsDirectAnimated(const gfx::Rect& bounds); |
290 | 311 |
291 // The owner of this window settings. | 312 // The owner of this window settings. |
292 aura::Window* window_; | 313 aura::Window* window_; |
293 scoped_ptr<WindowStateDelegate> delegate_; | 314 scoped_ptr<WindowStateDelegate> delegate_; |
294 | 315 |
295 bool window_position_managed_; | 316 bool window_position_managed_; |
296 bool bounds_changed_by_user_; | 317 bool bounds_changed_by_user_; |
297 bool panel_attached_; | 318 bool panel_attached_; |
298 bool continue_drag_after_reparent_; | 319 bool continue_drag_after_reparent_; |
299 bool ignored_by_shelf_; | 320 bool ignored_by_shelf_; |
300 bool can_consume_system_keys_; | 321 bool can_consume_system_keys_; |
301 bool top_row_keys_are_function_keys_; | 322 bool top_row_keys_are_function_keys_; |
302 scoped_ptr<DragDetails> drag_details_; | 323 scoped_ptr<DragDetails> drag_details_; |
303 | 324 |
304 bool unminimize_to_restore_bounds_; | 325 bool unminimize_to_restore_bounds_; |
305 bool hide_shelf_when_fullscreen_; | 326 bool hide_shelf_when_fullscreen_; |
306 bool animate_to_fullscreen_; | 327 bool animate_to_fullscreen_; |
307 bool minimum_visibility_; | 328 bool minimum_visibility_; |
308 | 329 |
309 // A property to remember the window position which was set before the | 330 // 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 | 331 // auto window position manager changed the window bounds, so that it can get |
311 // restored when only this one window gets shown. | 332 // restored when only this one window gets shown. |
312 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; | 333 scoped_ptr<gfx::Rect> pre_auto_manage_window_bounds_; |
313 | 334 |
314 ObserverList<WindowStateObserver> observer_list_; | 335 ObserverList<WindowStateObserver> observer_list_; |
315 | 336 |
316 // True when in SetWindowShowType(). This is used to avoid reentrance. | 337 // True to ignore a property change event to avoid reentrance in |
317 bool in_set_window_show_type_; | 338 // UpdateWindowShowType() |
| 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 |