Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1114)

Side by Side Diff: components/exo/wm_helper.cc

Issue 2242283002: Add an adapter layer (WMHelper) between exo and ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« components/exo/wm_helper.h ('K') | « components/exo/wm_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 #include "components/exo/wm_helper.h"
6
7 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
8 #include "ash/common/wm_shell.h"
9 #include "ash/display/display_manager.h"
10 #include "ash/shell.h"
11 #include "base/memory/singleton.h"
12 #include "ui/aura/client/focus_client.h"
13 #include "ui/wm/public/activation_client.h"
14
15 namespace exo {
16
17 ////////////////////////////////////////////////////////////////////////////////
18 // WMHelper, public:
19
20 WMHelper::WMHelper() {
21 ash::WmShell::Get()->AddShellObserver(this);
22 ash::Shell::GetInstance()->activation_client()->AddObserver(this);
23 aura::client::FocusClient* focus_client =
24 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow());
25 focus_client->AddObserver(this);
26 }
27
28 WMHelper::~WMHelper() {
29 if (!ash::Shell::HasInstance())
30 return;
31 aura::client::FocusClient* focus_client =
32 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow());
33 focus_client->AddObserver(this);
34 focus_client->RemoveObserver(this);
35 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this);
36 ash::WmShell::Get()->RemoveShellObserver(this);
37 }
38
39 // static
40 WMHelper* WMHelper::GetInstance() {
41 return base::Singleton<WMHelper>::get();
42 }
43
44 const ash::DisplayInfo& WMHelper::GetDisplayInfo(int64_t display_id) const {
45 return ash::Shell::GetInstance()->display_manager()->GetDisplayInfo(
46 display_id);
47 }
48
49 // static
50 aura::Window* WMHelper::GetContainer(int container_id) {
51 return ash::Shell::GetContainer(ash::Shell::GetTargetRootWindow(),
52 container_id);
53 }
54
55 aura::Window* WMHelper::GetActiveWindow() const {
56 return ash::Shell::GetInstance()->activation_client()->GetActiveWindow();
57 }
58
59 void WMHelper::AddActivationObserver(ActivationObserver* observer) {
60 activation_observers_.AddObserver(observer);
61 }
62
63 void WMHelper::RemoveActivationObserver(ActivationObserver* observer) {
64 activation_observers_.RemoveObserver(observer);
65 }
66
67 aura::Window* WMHelper::GetFocusedWindow() const {
68 aura::client::FocusClient* focus_client =
69 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow());
70 return focus_client->GetFocusedWindow();
71 }
72
73 void WMHelper::AddFocusObserver(FocusObserver* observer) {
74 focus_observers_.AddObserver(observer);
75 }
76
77 void WMHelper::RemoveFocusObserver(FocusObserver* observer) {
78 focus_observers_.RemoveObserver(observer);
79 }
80
81 ui::CursorSetType WMHelper::GetCursorSet() const {
82 return ash::Shell::GetInstance()->cursor_manager()->GetCursorSet();
83 }
84
85 void WMHelper::AddCursorObserver(CursorObserver* observer) {
86 cursor_observers_.AddObserver(observer);
87 }
88
89 void WMHelper::RemoveCursorObserver(CursorObserver* observer) {
90 cursor_observers_.RemoveObserver(observer);
91 }
92
93 void WMHelper::AddPreTargetHandler(ui::EventHandler* handler) {
94 ash::Shell::GetInstance()->AddPreTargetHandler(handler);
95 }
96
97 void WMHelper::PrependPreTargetHandler(ui::EventHandler* handler) {
98 ash::Shell::GetInstance()->PrependPreTargetHandler(handler);
99 }
100
101 void WMHelper::RemovePreTargetHandler(ui::EventHandler* handler) {
102 ash::Shell::GetInstance()->RemovePreTargetHandler(handler);
103 }
104
105 void WMHelper::AddPostTargetHandler(ui::EventHandler* handler) {
106 ash::Shell::GetInstance()->AddPostTargetHandler(handler);
107 }
108
109 void WMHelper::RemovePostTargetHandler(ui::EventHandler* handler) {
110 ash::Shell::GetInstance()->RemovePostTargetHandler(handler);
111 }
112
113 bool WMHelper::IsMaximizeModeWindowManagerEnabled() const {
114 return ash::WmShell::Get()
115 ->maximize_mode_controller()
116 ->IsMaximizeModeWindowManagerEnabled();
117 }
118
119 void WMHelper::AddMaximizeModeObserver(MaximizeModeObserver* observer) {
120 maximize_mode_observers_.AddObserver(observer);
121 }
122
123 void WMHelper::RemoveMaximizeModeObserver(MaximizeModeObserver* observer) {
124 maximize_mode_observers_.RemoveObserver(observer);
125 }
126
127 void WMHelper::OnWindowActivated(
128 aura::client::ActivationChangeObserver::ActivationReason reason,
129 aura::Window* gained_active,
130 aura::Window* lost_active) {
131 FOR_EACH_OBSERVER(ActivationObserver, activation_observers_,
132 OnWindowActivated(gained_active, lost_active));
133 }
134
135 void WMHelper::OnWindowFocused(aura::Window* gained_focus,
136 aura::Window* lost_focus) {
137 FOR_EACH_OBSERVER(FocusObserver, focus_observers_,
138 OnWindowFocused(gained_focus, lost_focus));
139 }
140
141 void WMHelper::OnCursorVisibilityChanged(bool is_visible) {
142 FOR_EACH_OBSERVER(CursorObserver, cursor_observers_,
143 OnCursorVisibilityChanged(is_visible));
144 }
145
146 void WMHelper::OnCursorSetChanged(ui::CursorSetType cursor_set) {
147 FOR_EACH_OBSERVER(CursorObserver, cursor_observers_,
148 OnCursorSetChanged(cursor_set));
149 }
150
151 void WMHelper::OnMaximizeModeStarted() {
152 FOR_EACH_OBSERVER(MaximizeModeObserver, maximize_mode_observers_,
153 OnMaximizeModeStarted());
154 }
155
156 void WMHelper::OnMaximizeModeEnded() {
157 FOR_EACH_OBSERVER(MaximizeModeObserver, maximize_mode_observers_,
158 OnMaximizeModeEnded());
159 }
160
161 } // namespace exo
OLDNEW
« components/exo/wm_helper.h ('K') | « components/exo/wm_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698