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