OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_COMMON_WM_DEFAULT_STATE_H_ | |
6 #define ASH_COMMON_WM_DEFAULT_STATE_H_ | |
7 | |
8 #include "ash/common/wm/window_state.h" | |
9 #include "base/macros.h" | |
10 #include "ui/display/display.h" | |
11 #include "ui/gfx/geometry/rect.h" | |
12 | |
13 namespace ash { | |
14 namespace wm { | |
15 class SetBoundsEvent; | |
16 | |
17 // DefaultState implements Ash behavior without state machine. | |
18 class DefaultState : public WindowState::State { | |
19 public: | |
20 explicit DefaultState(WindowStateType initial_state_type); | |
21 ~DefaultState() override; | |
22 | |
23 // WindowState::State overrides: | |
24 void OnWMEvent(WindowState* window_state, const WMEvent* event) override; | |
25 WindowStateType GetType() const override; | |
26 void AttachState(WindowState* window_state, | |
27 WindowState::State* previous_state) override; | |
28 void DetachState(WindowState* window_state) override; | |
29 | |
30 private: | |
31 // Process state dependent events, such as TOGGLE_MAXIMIZED, | |
32 // TOGGLE_FULLSCREEN. | |
33 static bool ProcessCompoundEvents(WindowState* window_state, | |
34 const WMEvent* event); | |
35 | |
36 // Process workspace related events, such as DISPLAY_BOUNDS_CHANGED. | |
37 static bool ProcessWorkspaceEvents(WindowState* window_state, | |
38 const WMEvent* event); | |
39 | |
40 // Set the fullscreen/maximized bounds without animation. | |
41 static bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state); | |
42 | |
43 static void SetBounds(WindowState* window_state, | |
44 const SetBoundsEvent* bounds_event); | |
45 | |
46 static void CenterWindow(WindowState* window_state); | |
47 | |
48 // Enters next state. This is used when the state moves from one to another | |
49 // within the same desktop mode. | |
50 void EnterToNextState(wm::WindowState* window_state, | |
51 wm::WindowStateType next_state_type); | |
52 | |
53 // Reenters the current state. This is called when migrating from | |
54 // previous desktop mode, and the window's state needs to re-construct the | |
55 // state/bounds for this state. | |
56 void ReenterToCurrentState(wm::WindowState* window_state, | |
57 wm::WindowState::State* state_in_previous_mode); | |
58 | |
59 // Animates to new window bounds based on the current and previous state type. | |
60 void UpdateBoundsFromState(wm::WindowState* window_state, | |
61 wm::WindowStateType old_state_type); | |
62 | |
63 // The current type of the window. | |
64 WindowStateType state_type_; | |
65 | |
66 // The saved window state for the case that the state gets de-/activated. | |
67 gfx::Rect stored_bounds_; | |
68 gfx::Rect stored_restore_bounds_; | |
69 | |
70 // The display state in which the mode got started. | |
71 display::Display stored_display_state_; | |
72 | |
73 // The window state only gets remembered for DCHECK reasons. | |
74 WindowState* stored_window_state_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(DefaultState); | |
77 }; | |
78 | |
79 } // namespace wm | |
80 } // namespace ash | |
81 | |
82 #endif // ASH_COMMON_WM_DEFAULT_STATE_H_ | |
OLD | NEW |