blob: ccee0f88992906bb5daa8dd97d1e068136d8f324 [file] [log] [blame]
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +00001// 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_WM_DEFAULT_STATE_H_
6#define ASH_WM_DEFAULT_STATE_H_
7
8#include "ash/wm/window_state.h"
Ben Murdocheffb81e2014-03-31 11:51:25 +01009#include "ui/gfx/display.h"
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000010
11namespace ash {
12namespace wm {
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000013class SetBoundsEvent;
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000014
15// DefaultState implements Ash behavior without state machine.
16class DefaultState : public WindowState::State {
17 public:
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000018 explicit DefaultState(WindowStateType initial_state_type);
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000019 virtual ~DefaultState();
20
21 // WindowState::State overrides:
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000022 virtual void OnWMEvent(WindowState* window_state,
23 const WMEvent* event) OVERRIDE;
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000024 virtual WindowStateType GetType() const OVERRIDE;
Torne (Richard Coles)23730a62014-03-21 14:25:57 +000025 virtual void AttachState(WindowState* window_state,
26 WindowState::State* previous_state) OVERRIDE;
27 virtual void DetachState(WindowState* window_state) OVERRIDE;
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000028
29 private:
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000030 // Process state dependent events, such as TOGGLE_MAXIMIZED,
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000031 // TOGGLE_FULLSCREEN.
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000032 static bool ProcessCompoundEvents(WindowState* window_state,
33 const WMEvent* event);
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000034
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000035 // Process workspace related events, such as DISPLAY_BOUNDS_CHANGED.
36 static bool ProcessWorkspaceEvents(WindowState* window_state,
37 const WMEvent* event);
38
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000039 // Set the fullscreen/maximized bounds without animation.
40 static bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state);
41
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000042 static void SetBounds(WindowState* window_state,
43 const SetBoundsEvent* bounds_event);
44
Torne (Richard Coles)23730a62014-03-21 14:25:57 +000045 static void CenterWindow(WindowState* window_state);
46
Ben Murdocheffb81e2014-03-31 11:51:25 +010047 // 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);
51
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);
57
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);
61
Torne (Richard Coles)23730a62014-03-21 14:25:57 +000062 // The current type of the window.
Torne (Richard Coles)a1401312014-03-18 10:20:56 +000063 WindowStateType state_type_;
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000064
Torne (Richard Coles)23730a62014-03-21 14:25:57 +000065 // The saved window state for the case that the state gets de-/activated.
66 gfx::Rect stored_bounds_;
67 gfx::Rect stored_restore_bounds_;
68
Ben Murdocheffb81e2014-03-31 11:51:25 +010069 // The display state in which the mode got started.
70 gfx::Display stored_display_state_;
Torne (Richard Coles)23730a62014-03-21 14:25:57 +000071
72 // The window state only gets remembered for DCHECK reasons.
73 WindowState* stored_window_state_;
74
Torne (Richard Coles)5d1f7b12014-02-21 12:16:55 +000075 DISALLOW_COPY_AND_ASSIGN(DefaultState);
76};
77
78} // namespace wm
79} // namespace ash
80
81#endif // ASH_WM_DEFAULT_STATE_H_