OLD | NEW |
(Empty) | |
| 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_TABLET_MODE_TABLET_MODE_WINDOW_STATE_H_ |
| 6 #define ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_STATE_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "ash/wm/window_state.h" |
| 11 #include "base/macros.h" |
| 12 |
| 13 namespace ash { |
| 14 class TabletModeWindowManager; |
| 15 |
| 16 // The TabletModeWindowState implementation which reduces all possible window |
| 17 // states to minimized and maximized. If a window cannot be maximized it will be |
| 18 // set to normal. If a window cannot fill the entire workspace it will be |
| 19 // centered within the workspace. |
| 20 class TabletModeWindowState : public wm::WindowState::State { |
| 21 public: |
| 22 // Called when the window position might need to be updated. |
| 23 static void UpdateWindowPosition(wm::WindowState* window_state); |
| 24 |
| 25 // The |window|'s state object will be modified to use this new window mode |
| 26 // state handler. Upon destruction it will restore the previous state handler |
| 27 // and call |creator::WindowStateDestroyed()| to inform that the window mode |
| 28 // was reverted to the old window manager. |
| 29 TabletModeWindowState(aura::Window* window, TabletModeWindowManager* creator); |
| 30 ~TabletModeWindowState() override; |
| 31 |
| 32 void set_ignore_wm_events(bool ignore) { ignore_wm_events_ = ignore; } |
| 33 |
| 34 // Leaves the tablet mode by reverting to previous state object. |
| 35 void LeaveTabletMode(wm::WindowState* window_state); |
| 36 |
| 37 // Sets whether to ignore bounds updates. If set to false, immediately does a |
| 38 // bounds update as the current window bounds may no longer be correct. |
| 39 void SetDeferBoundsUpdates(bool defer_bounds_updates); |
| 40 |
| 41 // WindowState::State overrides: |
| 42 void OnWMEvent(wm::WindowState* window_state, |
| 43 const wm::WMEvent* event) override; |
| 44 |
| 45 wm::WindowStateType GetType() const override; |
| 46 void AttachState(wm::WindowState* window_state, |
| 47 wm::WindowState::State* previous_state) override; |
| 48 void DetachState(wm::WindowState* window_state) override; |
| 49 |
| 50 private: |
| 51 // Updates the window to |new_state_type| and resulting bounds: |
| 52 // Either full screen, maximized centered or minimized. If the state does not |
| 53 // change, only the bounds will be changed. If |animate| is set, the bound |
| 54 // change get animated. |
| 55 void UpdateWindow(wm::WindowState* window_state, |
| 56 wm::WindowStateType new_state_type, |
| 57 bool animate); |
| 58 |
| 59 // Depending on the capabilities of the window we either return |
| 60 // |WINDOW_STATE_TYPE_MAXIMIZED| or |WINDOW_STATE_TYPE_NORMAL|. |
| 61 wm::WindowStateType GetMaximizedOrCenteredWindowType( |
| 62 wm::WindowState* window_state); |
| 63 |
| 64 // Updates the bounds to the maximum possible bounds according to the current |
| 65 // window state. If |animated| is set we animate the change. |
| 66 void UpdateBounds(wm::WindowState* window_state, bool animated); |
| 67 |
| 68 // The original state object of the window. |
| 69 std::unique_ptr<wm::WindowState::State> old_state_; |
| 70 |
| 71 // The window whose WindowState owns this instance. |
| 72 aura::Window* window_; |
| 73 |
| 74 // The creator which needs to be informed when this state goes away. |
| 75 TabletModeWindowManager* creator_; |
| 76 |
| 77 // The current state type. Due to the nature of this state, this can only be |
| 78 // WM_STATE_TYPE{NORMAL, MINIMIZED, MAXIMIZED}. |
| 79 wm::WindowStateType current_state_type_; |
| 80 |
| 81 // If true, do not update bounds. |
| 82 bool defer_bounds_updates_; |
| 83 |
| 84 // If true, the state will not process events. |
| 85 bool ignore_wm_events_ = false; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(TabletModeWindowState); |
| 88 }; |
| 89 |
| 90 } // namespace ash |
| 91 |
| 92 #endif // ASH_WM_TABLET_MODE_TABLET_MODE_WINDOW_STATE_H_ |
OLD | NEW |