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