Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ash / wm / default_state.h
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_WM_DEFAULT_STATE_H_
6 #define ASH_WM_DEFAULT_STATE_H_
7
8 #include "ash/wm/window_state.h"
9 #include "ui/gfx/display.h"
10
11 namespace ash {
12 namespace wm {
13 class SetBoundsEvent;
14
15 // DefaultState implements Ash behavior without state machine.
16 class DefaultState : public WindowState::State {
17  public:
18   explicit DefaultState(WindowStateType initial_state_type);
19   ~DefaultState() override;
20
21   // WindowState::State overrides:
22   void OnWMEvent(WindowState* window_state, const WMEvent* event) override;
23   WindowStateType GetType() const override;
24   void AttachState(WindowState* window_state,
25                    WindowState::State* previous_state) override;
26   void DetachState(WindowState* window_state) override;
27
28  private:
29   // Process state dependent events, such as TOGGLE_MAXIMIZED,
30   // TOGGLE_FULLSCREEN.
31   static bool ProcessCompoundEvents(WindowState* window_state,
32                                     const WMEvent* event);
33
34   // Process workspace related events, such as DISPLAY_BOUNDS_CHANGED.
35   static bool ProcessWorkspaceEvents(WindowState* window_state,
36                                      const WMEvent* event);
37
38   // Set the fullscreen/maximized bounds without animation.
39   static bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state);
40
41   static void SetBounds(WindowState* window_state,
42                         const SetBoundsEvent* bounds_event);
43
44   static void CenterWindow(WindowState* window_state);
45
46   // Enters next state. This is used when the state moves from one to another
47   // within the same desktop mode.
48   void EnterToNextState(wm::WindowState* window_state,
49                         wm::WindowStateType next_state_type);
50
51   // Reenters the current state. This is called when migrating from
52   // previous desktop mode, and the window's state needs to re-construct the
53   // state/bounds for this state.
54   void ReenterToCurrentState(wm::WindowState* window_state,
55                              wm::WindowState::State* state_in_previous_mode);
56
57   // Animates to new window bounds based on the current and previous state type.
58   void UpdateBoundsFromState(wm::WindowState* window_state,
59                              wm::WindowStateType old_state_type);
60
61   // The current type of the window.
62   WindowStateType state_type_;
63
64   // The saved window state for the case that the state gets de-/activated.
65   gfx::Rect stored_bounds_;
66   gfx::Rect stored_restore_bounds_;
67
68   // The display state in which the mode got started.
69   gfx::Display stored_display_state_;
70
71   // The window state only gets remembered for DCHECK reasons.
72   WindowState* stored_window_state_;
73
74   DISALLOW_COPY_AND_ASSIGN(DefaultState);
75 };
76
77 }  // namespace wm
78 }  // namespace ash
79
80 #endif  // ASH_WM_DEFAULT_STATE_H_