| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_ | 5 #ifndef ASH_WM_LOCK_WINDOW_STATE_H_ |
| 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_ | 6 #define ASH_WM_LOCK_WINDOW_STATE_H_ |
| 7 | 7 |
| 8 #include "ash/wm/window_state.h" | 8 #include "ash/wm/window_state.h" |
| 9 | 9 |
| 10 namespace ash { | 10 namespace ash { |
| 11 class MaximizeModeWindowManager; | |
| 12 | 11 |
| 13 // The MaximizeModeWindowState implementation which reduces all possible window | 12 class LockLayoutManager; |
| 14 // states to minimized and maximized. If a window cannot be maximized it will be | 13 |
| 15 // set to normal. If a window cannot fill the entire workspace it will be | 14 // The LockWindowState implementation which reduces all possible window |
| 16 // centered within the workspace. | 15 // states to maximized and is applied only on lock (login) window container. |
| 17 class MaximizeModeWindowState : public wm::WindowState::State { | 16 // LockWindowState implements Ash behavior without state machine. |
| 17 class LockWindowState : public wm::WindowState::State { |
| 18 public: | 18 public: |
| 19 // Called when the window position might need to be updated. | |
| 20 static void UpdateWindowPosition(wm::WindowState* window_state, | |
| 21 bool animated); | |
| 22 | |
| 23 // The |window|'s state object will be modified to use this new window mode | 19 // The |window|'s state object will be modified to use this new window mode |
| 24 // state handler. Upon destruction it will restore the previous state handler | 20 // state handler. Upon destruction it will restore the previous state handler |
| 25 // and call |creator::WindowStateDestroyed()| to inform that the window mode | 21 // and call |creator::WindowStateDestroyed()| to inform that the window mode |
| 26 // was reverted to the old window manager. | 22 // was reverted to the old window manager. |
| 27 MaximizeModeWindowState(aura::Window* window, | 23 LockWindowState(aura::Window* window, LockLayoutManager* creator); |
| 28 MaximizeModeWindowManager* creator); | 24 virtual ~LockWindowState(); |
| 29 virtual ~MaximizeModeWindowState(); | |
| 30 | 25 |
| 31 // Leaves the maximize mode by reverting to previous state object. | 26 // Reverts to previous WindowState object. |
| 32 void LeaveMaximizeMode(wm::WindowState* window_state); | 27 void RestoreWindowState(wm::WindowState* window_state); |
| 33 | 28 |
| 34 // WindowState::State overrides: | 29 // WindowState::State overrides: |
| 35 virtual void OnWMEvent(wm::WindowState* window_state, | 30 virtual void OnWMEvent(wm::WindowState* window_state, |
| 36 const wm::WMEvent* event) OVERRIDE; | 31 const wm::WMEvent* event) OVERRIDE; |
| 37 | 32 |
| 38 virtual wm::WindowStateType GetType() const OVERRIDE; | 33 virtual wm::WindowStateType GetType() const OVERRIDE; |
| 39 virtual void AttachState(wm::WindowState* window_state, | 34 virtual void AttachState(wm::WindowState* window_state, |
| 40 wm::WindowState::State* previous_state) OVERRIDE; | 35 wm::WindowState::State* previous_state) OVERRIDE; |
| 41 virtual void DetachState(wm::WindowState* window_state) OVERRIDE; | 36 virtual void DetachState(wm::WindowState* window_state) OVERRIDE; |
| 42 | 37 |
| 43 private: | 38 private: |
| 44 // Updates the window to |new_state_type| and resulting bounds: | 39 // Updates the window to |new_state_type| and resulting bounds: |
| 45 // Either full screen, maximized centered or minimized. If the state does not | 40 // Either full screen, maximized centered or minimized. If the state does not |
| 46 // change, only the bounds will be changed. If |animate| is set, the bound | 41 // change, only the bounds will be changed. |
| 47 // change get animated. | |
| 48 void UpdateWindow(wm::WindowState* window_state, | 42 void UpdateWindow(wm::WindowState* window_state, |
| 49 wm::WindowStateType new_state_type, | 43 wm::WindowStateType new_state_type); |
| 50 bool animate); | |
| 51 | 44 |
| 52 // Depending on the capabilities of the window we either return | 45 // Depending on the capabilities of the window we either return |
| 53 // |WINDOW_STATE_TYPE_MAXIMIZED| or |WINDOW_STATE_TYPE_NORMAL|. | 46 // |WINDOW_STATE_TYPE_MAXIMIZED| or |WINDOW_STATE_TYPE_NORMAL|. |
| 54 wm::WindowStateType GetMaximizedOrCenteredWindowType( | 47 wm::WindowStateType GetMaximizedOrCenteredWindowType( |
| 55 wm::WindowState* window_state); | 48 wm::WindowState* window_state); |
| 56 | 49 |
| 57 // Updates the bounds to the maximum possible bounds according to the current | 50 // Updates the bounds taking virtual keyboard bounds into consideration. |
| 58 // window state. If |animated| is set we animate the change. | 51 void UpdateBounds(wm::WindowState* window_state); |
| 59 void UpdateBounds(wm::WindowState* window_state, bool animated); | |
| 60 | 52 |
| 61 // The original state object of the window. | 53 // The original state object of the window. |
| 62 scoped_ptr<wm::WindowState::State> old_state_; | 54 scoped_ptr<wm::WindowState::State> old_state_; |
| 63 | 55 |
| 64 // The state object for this object which owns this instance. | 56 // The state object for this object which owns this instance. |
| 65 aura::Window* window_; | 57 aura::Window* window_; |
| 66 | 58 |
| 67 // The creator which needs to be informed when this state goes away. | 59 // The creator which needs to be informed when this state goes away. |
| 68 MaximizeModeWindowManager* creator_; | 60 LockLayoutManager* creator_; |
| 69 | 61 |
| 70 // The current state type. Due to the nature of this state, this can only be | 62 // The current state type. Due to the nature of this state, this can only be |
| 71 // WM_STATE_TYPE{NORMAL, MINIMIZED, MAXIMIZED}. | 63 // WM_STATE_TYPE{NORMAL, MINIMIZED, MAXIMIZED}. |
| 72 wm::WindowStateType current_state_type_; | 64 wm::WindowStateType current_state_type_; |
| 73 | 65 |
| 74 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowState); | 66 DISALLOW_COPY_AND_ASSIGN(LockWindowState); |
| 75 }; | 67 }; |
| 76 | 68 |
| 77 } // namespace ash | 69 } // namespace ash |
| 78 | 70 |
| 79 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_WINDOW_STATE_H_ | 71 #endif // ASH_WM_LOCK_WINDOW_STATE_H_ |
| OLD | NEW |