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 virtual ~DefaultState(); 20 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; 28 29 private: 30 // Process state dependent events, such as TOGGLE_MAXIMIZED, 31 // TOGGLE_FULLSCREEN. 32 static bool ProcessCompoundEvents(WindowState* window_state, 33 const WMEvent* event); 34 35 // Process workspace related events, such as DISPLAY_BOUNDS_CHANGED. 36 static bool ProcessWorkspaceEvents(WindowState* window_state, 37 const WMEvent* event); 38 39 // Set the fullscreen/maximized bounds without animation. 40 static bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state); 41 42 static void SetBounds(WindowState* window_state, 43 const SetBoundsEvent* bounds_event); 44 45 static void CenterWindow(WindowState* window_state); 46 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 62 // The current type of the window. 63 WindowStateType state_type_; 64 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 69 // The display state in which the mode got started. 70 gfx::Display stored_display_state_; 71 72 // The window state only gets remembered for DCHECK reasons. 73 WindowState* stored_window_state_; 74 75 DISALLOW_COPY_AND_ASSIGN(DefaultState); 76 }; 77 78 } // namespace wm 79 } // namespace ash 80 81 #endif // ASH_WM_DEFAULT_STATE_H_ 82