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.
5 #ifndef ASH_WM_DEFAULT_STATE_H_
6 #define ASH_WM_DEFAULT_STATE_H_
8 #include "ash/wm/window_state.h"
9 #include "ui/gfx/display.h"
15 // DefaultState implements Ash behavior without state machine.
16 class DefaultState
: public WindowState::State
{
18 explicit DefaultState(WindowStateType initial_state_type
);
19 virtual ~DefaultState();
21 // WindowState::State overrides:
22 virtual void OnWMEvent(WindowState
* window_state
,
23 const WMEvent
* event
) OVERRIDE
;
24 virtual WindowStateType
GetType() const OVERRIDE
;
25 virtual void AttachState(WindowState
* window_state
,
26 WindowState::State
* previous_state
) OVERRIDE
;
27 virtual void DetachState(WindowState
* window_state
) OVERRIDE
;
30 // Process state dependent events, such as TOGGLE_MAXIMIZED,
32 static bool ProcessCompoundEvents(WindowState
* window_state
,
33 const WMEvent
* event
);
35 // Process workspace related events, such as DISPLAY_BOUNDS_CHANGED.
36 static bool ProcessWorkspaceEvents(WindowState
* window_state
,
37 const WMEvent
* event
);
39 // Set the fullscreen/maximized bounds without animation.
40 static bool SetMaximizedOrFullscreenBounds(wm::WindowState
* window_state
);
42 static void SetBounds(WindowState
* window_state
,
43 const SetBoundsEvent
* bounds_event
);
45 static void CenterWindow(WindowState
* window_state
);
47 // Enters next state. This is used when the state moves from one to another
48 // within the same desktop mode.
49 void EnterToNextState(wm::WindowState
* window_state
,
50 wm::WindowStateType next_state_type
);
52 // Reenters the current state. This is called when migrating from
53 // previous desktop mode, and the window's state needs to re-construct the
54 // state/bounds for this state.
55 void ReenterToCurrentState(wm::WindowState
* window_state
,
56 wm::WindowState::State
* state_in_previous_mode
);
58 // Animates to new window bounds based on the current and previous state type.
59 void UpdateBoundsFromState(wm::WindowState
* window_state
,
60 wm::WindowStateType old_state_type
);
62 // The current type of the window.
63 WindowStateType state_type_
;
65 // The saved window state for the case that the state gets de-/activated.
66 gfx::Rect stored_bounds_
;
67 gfx::Rect stored_restore_bounds_
;
69 // The display state in which the mode got started.
70 gfx::Display stored_display_state_
;
72 // The window state only gets remembered for DCHECK reasons.
73 WindowState
* stored_window_state_
;
75 DISALLOW_COPY_AND_ASSIGN(DefaultState
);
81 #endif // ASH_WM_DEFAULT_STATE_H_