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_LOCK_WINDOW_STATE_H_ 6 #define ASH_WM_LOCK_WINDOW_STATE_H_ 7 8 #include "ash/wm/window_state.h" 9 #include "base/macros.h" 10 11 namespace ash { 12 13 // The LockWindowState implementation which reduces all possible window 14 // states to maximized (or normal if can't be maximized)/minimized/full-screen 15 // and is applied only on lock (login) window container and window containers 16 // associated with apps handling lock screen tray actions. 17 // LockWindowState implements Ash behavior without state machine. 18 class LockWindowState : public WindowState::State { 19 public: 20 // The |window|'s state object will be modified to use this new window mode 21 // state handler. 22 // |exclude_shelf| - if set, the maximized window size will be 23 // restricted to work area defined by ash shelf, rather than taking only 24 // virtual keyboard window into consideration when calculating the window 25 // size. 26 LockWindowState(aura::Window* window, bool exclude_shelf); 27 28 ~LockWindowState() override; 29 30 // WindowState::State overrides: 31 void OnWMEvent(WindowState* window_state, const WMEvent* event) override; 32 chromeos::WindowStateType GetType() const override; 33 void AttachState(WindowState* window_state, 34 WindowState::State* previous_state) override; 35 void DetachState(WindowState* window_state) override; 36 37 // Creates new LockWindowState instance and attaches it to |window|. 38 static WindowState* SetLockWindowState(aura::Window* window); 39 static WindowState* SetLockWindowStateWithShelfExcluded(aura::Window* window); 40 41 private: 42 // Updates the window to |new_state_type| and resulting bounds: 43 // Either full screen, maximized centered or minimized. If the state does not 44 // change, only the bounds will be changed. 45 void UpdateWindow(WindowState* window_state, 46 chromeos::WindowStateType new_state_type); 47 48 // Depending on the capabilities of the window we either return 49 // |WindowStateType::kMaximized| or |WindowStateType::kNormal|. 50 chromeos::WindowStateType GetMaximizedOrCenteredWindowType( 51 WindowState* window_state); 52 53 // Returns boudns to be used for the provided window. 54 gfx::Rect GetWindowBounds(aura::Window* window); 55 56 // Updates the bounds taking virtual keyboard bounds into consideration. 57 void UpdateBounds(WindowState* window_state); 58 59 // The current state type. Due to the nature of this state, this can only be 60 // WM_STATE_TYPE{NORMAL, MINIMIZED, MAXIMIZED}. 61 chromeos::WindowStateType current_state_type_; 62 63 // Restrict window size to the work area defined by the shelf - i.e. window 64 // bounds exclude system shelf bounds. 65 bool exclude_shelf_ = false; 66 67 DISALLOW_COPY_AND_ASSIGN(LockWindowState); 68 }; 69 70 } // namespace ash 71 72 #endif // ASH_WM_LOCK_WINDOW_STATE_H_ 73