forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wm_helper.h
173 lines (141 loc) · 5.61 KB
/
wm_helper.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// Copyright 2016 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 COMPONENTS_EXO_WM_HELPER_H_
#define COMPONENTS_EXO_WM_HELPER_H_
#include <memory>
#include "base/macros.h"
#include "base/observer_list.h"
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/base/cursor/cursor.h"
namespace aura {
class Window;
}
namespace display {
class Display;
class ManagedDisplayInfo;
}
namespace ui {
class EventHandler;
class DropTargetEvent;
}
namespace exo {
// A helper class for accessing WindowManager related features.
class WMHelper : public aura::client::DragDropDelegate {
public:
class ActivationObserver {
public:
virtual void OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) = 0;
protected:
virtual ~ActivationObserver() {}
};
class FocusObserver {
public:
virtual void OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) = 0;
protected:
virtual ~FocusObserver() {}
};
class CursorObserver {
public:
virtual void OnCursorVisibilityChanged(bool is_visible) {}
virtual void OnCursorSizeChanged(ui::CursorSize cursor_size) {}
virtual void OnCursorDisplayChanged(const display::Display& display) {}
protected:
virtual ~CursorObserver() {}
};
class TabletModeObserver {
public:
virtual void OnTabletModeStarted() = 0;
virtual void OnTabletModeEnding() = 0;
virtual void OnTabletModeEnded() = 0;
protected:
virtual ~TabletModeObserver() {}
};
class InputDeviceEventObserver {
public:
virtual void OnKeyboardDeviceConfigurationChanged() = 0;
protected:
virtual ~InputDeviceEventObserver() {}
};
class DisplayConfigurationObserver {
public:
virtual void OnDisplayConfigurationChanged() = 0;
protected:
virtual ~DisplayConfigurationObserver() {}
};
class DragDropObserver {
public:
virtual void OnDragEntered(const ui::DropTargetEvent& event) = 0;
virtual int OnDragUpdated(const ui::DropTargetEvent& event) = 0;
virtual void OnDragExited() = 0;
virtual int OnPerformDrop(const ui::DropTargetEvent& event) = 0;
protected:
virtual ~DragDropObserver() {}
};
~WMHelper() override;
static void SetInstance(WMHelper* helper);
static WMHelper* GetInstance();
static bool HasInstance();
void AddActivationObserver(ActivationObserver* observer);
void RemoveActivationObserver(ActivationObserver* observer);
void AddFocusObserver(FocusObserver* observer);
void RemoveFocusObserver(FocusObserver* observer);
void AddCursorObserver(CursorObserver* observer);
void RemoveCursorObserver(CursorObserver* observer);
void AddTabletModeObserver(TabletModeObserver* observer);
void RemoveTabletModeObserver(TabletModeObserver* observer);
void AddInputDeviceEventObserver(InputDeviceEventObserver* observer);
void RemoveInputDeviceEventObserver(InputDeviceEventObserver* observer);
void AddDisplayConfigurationObserver(DisplayConfigurationObserver* observer);
void RemoveDisplayConfigurationObserver(
DisplayConfigurationObserver* observer);
void AddDragDropObserver(DragDropObserver* observer);
void RemoveDragDropObserver(DragDropObserver* observer);
void SetDragDropDelegate(aura::Window*);
void ResetDragDropDelegate(aura::Window*);
virtual const display::ManagedDisplayInfo& GetDisplayInfo(
int64_t display_id) const = 0;
virtual aura::Window* GetPrimaryDisplayContainer(int container_id) = 0;
virtual aura::Window* GetActiveWindow() const = 0;
virtual aura::Window* GetFocusedWindow() const = 0;
virtual ui::CursorSize GetCursorSize() const = 0;
virtual const display::Display& GetCursorDisplay() const = 0;
virtual void AddPreTargetHandler(ui::EventHandler* handler) = 0;
virtual void PrependPreTargetHandler(ui::EventHandler* handler) = 0;
virtual void RemovePreTargetHandler(ui::EventHandler* handler) = 0;
virtual void AddPostTargetHandler(ui::EventHandler* handler) = 0;
virtual void RemovePostTargetHandler(ui::EventHandler* handler) = 0;
virtual bool IsTabletModeWindowManagerEnabled() const = 0;
// Overridden from aura::client::DragDropDelegate:
void OnDragEntered(const ui::DropTargetEvent& event) override;
int OnDragUpdated(const ui::DropTargetEvent& event) override;
void OnDragExited() override;
int OnPerformDrop(const ui::DropTargetEvent& event) override;
protected:
WMHelper();
void NotifyWindowActivated(aura::Window* gained_active,
aura::Window* lost_active);
void NotifyWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus);
void NotifyCursorVisibilityChanged(bool is_visible);
void NotifyCursorSizeChanged(ui::CursorSize cursor_size);
void NotifyCursorDisplayChanged(const display::Display& display);
void NotifyTabletModeStarted();
void NotifyTabletModeEnding();
void NotifyTabletModeEnded();
void NotifyKeyboardDeviceConfigurationChanged();
void NotifyDisplayConfigurationChanged();
private:
base::ObserverList<ActivationObserver> activation_observers_;
base::ObserverList<FocusObserver> focus_observers_;
base::ObserverList<CursorObserver> cursor_observers_;
base::ObserverList<TabletModeObserver> tablet_mode_observers_;
base::ObserverList<InputDeviceEventObserver> input_device_event_observers_;
base::ObserverList<DisplayConfigurationObserver> display_config_observers_;
base::ObserverList<DragDropObserver> drag_drop_observers_;
DISALLOW_COPY_AND_ASSIGN(WMHelper);
};
} // namespace exo
#endif // COMPONENTS_EXO_WM_HELPER_H_