Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: ash/wm/window_state.h

Issue 2901663003: chromeos: converts WindowState to aura::Window (Closed)
Patch Set: feedback Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/window_resizer.cc ('k') | ash/wm/window_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/wm/drag_details.h" 11 #include "ash/wm/drag_details.h"
12 #include "ash/wm/wm_types.h" 12 #include "ash/wm/wm_types.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "ui/aura/window_observer.h"
16 #include "ui/base/ui_base_types.h" 17 #include "ui/base/ui_base_types.h"
17 18
18 namespace aura {
19 class Window;
20 }
21
22 namespace gfx { 19 namespace gfx {
23 class Rect; 20 class Rect;
24 } 21 }
25 22
26 namespace ash { 23 namespace ash {
27 class LockWindowState; 24 class LockWindowState;
28 class MaximizeModeWindowState; 25 class MaximizeModeWindowState;
29 class WmWindow;
30 26
31 namespace mojom { 27 namespace mojom {
32 enum class WindowPinType; 28 enum class WindowPinType;
33 } 29 }
34 30
35 namespace wm { 31 namespace wm {
36 class WindowState; 32 class WindowState;
37 class WindowStateDelegate; 33 class WindowStateDelegate;
38 class WindowStateObserver; 34 class WindowStateObserver;
39 class WMEvent; 35 class WMEvent;
(...skipping 11 matching lines...) Expand all
51 // behavior. Ash specific per-window state (such as ones that controls 47 // behavior. Ash specific per-window state (such as ones that controls
52 // window manager behavior) and ash specific window behavior (such as 48 // window manager behavior) and ash specific window behavior (such as
53 // maximize, minimize, snap sizing etc) should be added here instead 49 // maximize, minimize, snap sizing etc) should be added here instead
54 // of defining separate functions (like |MaximizeWindow(aura::Window* 50 // of defining separate functions (like |MaximizeWindow(aura::Window*
55 // window)|) or using aura Window property. 51 // window)|) or using aura Window property.
56 // The WindowState gets created when first accessed by 52 // The WindowState gets created when first accessed by
57 // |wm::GetWindowState|, and deleted when the window is deleted. 53 // |wm::GetWindowState|, and deleted when the window is deleted.
58 // Prefer using this class instead of passing aura::Window* around in 54 // Prefer using this class instead of passing aura::Window* around in
59 // ash code as this is often what you need to interact with, and 55 // ash code as this is often what you need to interact with, and
60 // accessing the window using |window()| is cheap. 56 // accessing the window using |window()| is cheap.
61 class ASH_EXPORT WindowState { 57 class ASH_EXPORT WindowState : public aura::WindowObserver {
62 public: 58 public:
63 // A subclass of State class represents one of the window's states 59 // A subclass of State class represents one of the window's states
64 // that corresponds to WindowStateType in Ash environment, e.g. 60 // that corresponds to WindowStateType in Ash environment, e.g.
65 // maximized, minimized or side snapped, as subclass. 61 // maximized, minimized or side snapped, as subclass.
66 // Each subclass defines its own behavior and transition for each WMEvent. 62 // Each subclass defines its own behavior and transition for each WMEvent.
67 class State { 63 class State {
68 public: 64 public:
69 State() {} 65 State() {}
70 virtual ~State() {} 66 virtual ~State() {}
71 67
(...skipping 13 matching lines...) Expand all
85 // Gets called before the state objects gets deactivated / detached from the 81 // Gets called before the state objects gets deactivated / detached from the
86 // window, so that it can save the various states it is interested in. 82 // window, so that it can save the various states it is interested in.
87 // Note: This only gets called when the state object gets changed. 83 // Note: This only gets called when the state object gets changed.
88 virtual void DetachState(WindowState* window_state) = 0; 84 virtual void DetachState(WindowState* window_state) = 0;
89 85
90 private: 86 private:
91 DISALLOW_COPY_AND_ASSIGN(State); 87 DISALLOW_COPY_AND_ASSIGN(State);
92 }; 88 };
93 89
94 // Call GetWindowState() to instantiate this class. 90 // Call GetWindowState() to instantiate this class.
95 virtual ~WindowState(); 91 ~WindowState() override;
96 92
97 WmWindow* window() { return window_; } 93 aura::Window* window() { return window_; }
98 const WmWindow* window() const { return window_; } 94 const aura::Window* window() const { return window_; }
99 95
100 bool HasDelegate() const; 96 bool HasDelegate() const;
101 void SetDelegate(std::unique_ptr<WindowStateDelegate> delegate); 97 void SetDelegate(std::unique_ptr<WindowStateDelegate> delegate);
102 98
103 // Returns the window's current ash state type. 99 // Returns the window's current ash state type.
104 // Refer to WindowStateType definition in wm_types.h as for why Ash 100 // Refer to WindowStateType definition in wm_types.h as for why Ash
105 // has its own state type. 101 // has its own state type.
106 WindowStateType GetStateType() const; 102 WindowStateType GetStateType() const;
107 103
108 // Predicates to check window state. 104 // Predicates to check window state.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 143
148 void Activate(); 144 void Activate();
149 void Deactivate(); 145 void Deactivate();
150 146
151 // Set the window state to normal. 147 // Set the window state to normal.
152 // TODO(oshima): Change to use RESTORE event. 148 // TODO(oshima): Change to use RESTORE event.
153 void Restore(); 149 void Restore();
154 150
155 // Caches, then disables always on top state and then stacks |window_| below 151 // Caches, then disables always on top state and then stacks |window_| below
156 // |window_on_top| if a |window_| is currently in always on top state. 152 // |window_on_top| if a |window_| is currently in always on top state.
157 void DisableAlwaysOnTop(WmWindow* window_on_top); 153 void DisableAlwaysOnTop(aura::Window* window_on_top);
158 154
159 // Restores always on top state that a window might have cached. 155 // Restores always on top state that a window might have cached.
160 void RestoreAlwaysOnTop(); 156 void RestoreAlwaysOnTop();
161 157
162 // Invoked when a WMevent occurs, which drives the internal 158 // Invoked when a WMevent occurs, which drives the internal
163 // state machine. 159 // state machine.
164 void OnWMEvent(const WMEvent* event); 160 void OnWMEvent(const WMEvent* event);
165 161
166 // TODO(oshima): Try hiding these methods and making them accessible only to 162 // TODO(oshima): Try hiding these methods and making them accessible only to
167 // state impl. State changes should happen through events (as much 163 // state impl. State changes should happen through events (as much
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // resizer gets destroyed. 316 // resizer gets destroyed.
321 void DeleteDragDetails(); 317 void DeleteDragDetails();
322 318
323 // Sets the currently stored restore bounds and clears the restore bounds. 319 // Sets the currently stored restore bounds and clears the restore bounds.
324 void SetAndClearRestoreBounds(); 320 void SetAndClearRestoreBounds();
325 321
326 // Returns a pointer to DragDetails during drag operations. 322 // Returns a pointer to DragDetails during drag operations.
327 const DragDetails* drag_details() const { return drag_details_.get(); } 323 const DragDetails* drag_details() const { return drag_details_.get(); }
328 DragDetails* drag_details() { return drag_details_.get(); } 324 DragDetails* drag_details() { return drag_details_.get(); }
329 325
330 // Called from the associated WmWindow once the show state changes.
331 void OnWindowShowStateChanged();
332
333 // Called from the associated WmWindow once the window pin type changes.
334 void OnWindowPinTypeChanged();
335
336 private: 326 private:
337 friend class DefaultState; 327 friend class DefaultState;
338 friend class ash::LockWindowState; 328 friend class ash::LockWindowState;
339 friend class ash::MaximizeModeWindowState; 329 friend class ash::MaximizeModeWindowState;
340 friend WindowState* GetWindowState(aura::Window*); 330 friend WindowState* GetWindowState(aura::Window*);
341 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, CrossFadeToBounds); 331 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, CrossFadeToBounds);
342 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest, 332 FRIEND_TEST_ALL_PREFIXES(WindowAnimationsTest,
343 CrossFadeToBoundsFromTransform); 333 CrossFadeToBoundsFromTransform);
344 334
345 explicit WindowState(WmWindow* window); 335 explicit WindowState(aura::Window* window);
346 336
347 WindowStateDelegate* delegate() { return delegate_.get(); } 337 WindowStateDelegate* delegate() { return delegate_.get(); }
348 338
349 // Returns the window's current always_on_top state. 339 // Returns the window's current always_on_top state.
350 bool GetAlwaysOnTop() const; 340 bool GetAlwaysOnTop() const;
351 341
352 // Returns the window's current show state. 342 // Returns the window's current show state.
353 ui::WindowShowState GetShowState() const; 343 ui::WindowShowState GetShowState() const;
354 344
355 // Return the window's current pin type. 345 // Return the window's current pin type.
(...skipping 22 matching lines...) Expand all
378 void SetBoundsConstrained(const gfx::Rect& bounds); 368 void SetBoundsConstrained(const gfx::Rect& bounds);
379 369
380 // Sets the wndow's |bounds| and transitions to the new bounds with 370 // Sets the wndow's |bounds| and transitions to the new bounds with
381 // a scale animation. 371 // a scale animation.
382 void SetBoundsDirectAnimated(const gfx::Rect& bounds); 372 void SetBoundsDirectAnimated(const gfx::Rect& bounds);
383 373
384 // Sets the window's |bounds| and transition to the new bounds with 374 // Sets the window's |bounds| and transition to the new bounds with
385 // a cross fade animation. 375 // a cross fade animation.
386 void SetBoundsDirectCrossFade(const gfx::Rect& bounds); 376 void SetBoundsDirectCrossFade(const gfx::Rect& bounds);
387 377
378 // aura::WindowObserver:
379 void OnWindowPropertyChanged(aura::Window* window,
380 const void* key,
381 intptr_t old) override;
382
388 // The owner of this window settings. 383 // The owner of this window settings.
389 WmWindow* window_; 384 aura::Window* window_;
390 std::unique_ptr<WindowStateDelegate> delegate_; 385 std::unique_ptr<WindowStateDelegate> delegate_;
391 386
392 bool window_position_managed_; 387 bool window_position_managed_;
393 bool bounds_changed_by_user_; 388 bool bounds_changed_by_user_;
394 bool ignored_by_shelf_; 389 bool ignored_by_shelf_;
395 bool can_consume_system_keys_; 390 bool can_consume_system_keys_;
396 std::unique_ptr<DragDetails> drag_details_; 391 std::unique_ptr<DragDetails> drag_details_;
397 392
398 bool unminimize_to_restore_bounds_; 393 bool unminimize_to_restore_bounds_;
399 bool in_immersive_fullscreen_; 394 bool in_immersive_fullscreen_;
(...skipping 18 matching lines...) Expand all
418 413
419 std::unique_ptr<State> current_state_; 414 std::unique_ptr<State> current_state_;
420 415
421 DISALLOW_COPY_AND_ASSIGN(WindowState); 416 DISALLOW_COPY_AND_ASSIGN(WindowState);
422 }; 417 };
423 418
424 } // namespace wm 419 } // namespace wm
425 } // namespace ash 420 } // namespace ash
426 421
427 #endif // ASH_WM_WINDOW_STATE_H_ 422 #endif // ASH_WM_WINDOW_STATE_H_
OLDNEW
« no previous file with comments | « ash/wm/window_resizer.cc ('k') | ash/wm/window_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698