Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 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" |
Ben Murdoch | effb81e | 2014-03-31 11:51:25 +0100 | [diff] [blame] | 9 | #include "ui/gfx/display.h" |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 10 | |
| 11 | namespace ash { |
| 12 | namespace wm { |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 13 | class SetBoundsEvent; |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 14 | |
| 15 | // DefaultState implements Ash behavior without state machine. |
| 16 | class DefaultState : public WindowState::State { |
| 17 | public: |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 18 | explicit DefaultState(WindowStateType initial_state_type); |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 19 | virtual ~DefaultState(); |
| 20 | |
| 21 | // WindowState::State overrides: |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 22 | virtual void OnWMEvent(WindowState* window_state, |
| 23 | const WMEvent* event) OVERRIDE; |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 24 | virtual WindowStateType GetType() const OVERRIDE; |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 25 | virtual void AttachState(WindowState* window_state, |
| 26 | WindowState::State* previous_state) OVERRIDE; |
| 27 | virtual void DetachState(WindowState* window_state) OVERRIDE; |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 28 | |
| 29 | private: |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 30 | // Process state dependent events, such as TOGGLE_MAXIMIZED, |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 31 | // TOGGLE_FULLSCREEN. |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 32 | static bool ProcessCompoundEvents(WindowState* window_state, |
| 33 | const WMEvent* event); |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 34 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 35 | // Process workspace related events, such as DISPLAY_BOUNDS_CHANGED. |
| 36 | static bool ProcessWorkspaceEvents(WindowState* window_state, |
| 37 | const WMEvent* event); |
| 38 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 39 | // Set the fullscreen/maximized bounds without animation. |
| 40 | static bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state); |
| 41 | |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 42 | static void SetBounds(WindowState* window_state, |
| 43 | const SetBoundsEvent* bounds_event); |
| 44 | |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 45 | static void CenterWindow(WindowState* window_state); |
| 46 | |
Ben Murdoch | effb81e | 2014-03-31 11:51:25 +0100 | [diff] [blame] | 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); |
| 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) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 62 | // The current type of the window. |
Torne (Richard Coles) | a140131 | 2014-03-18 10:20:56 +0000 | [diff] [blame] | 63 | WindowStateType state_type_; |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 64 | |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 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_; |
| 68 | |
Ben Murdoch | effb81e | 2014-03-31 11:51:25 +0100 | [diff] [blame] | 69 | // The display state in which the mode got started. |
| 70 | gfx::Display stored_display_state_; |
Torne (Richard Coles) | 23730a6 | 2014-03-21 14:25:57 +0000 | [diff] [blame] | 71 | |
| 72 | // The window state only gets remembered for DCHECK reasons. |
| 73 | WindowState* stored_window_state_; |
| 74 | |
Torne (Richard Coles) | 5d1f7b1 | 2014-02-21 12:16:55 +0000 | [diff] [blame] | 75 | DISALLOW_COPY_AND_ASSIGN(DefaultState); |
| 76 | }; |
| 77 | |
| 78 | } // namespace wm |
| 79 | } // namespace ash |
| 80 | |
| 81 | #endif // ASH_WM_DEFAULT_STATE_H_ |