OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/exo/wm_helper_ash.h" | 5 #include "components/exo/wm_helper_ash.h" |
6 | 6 |
7 #include "ash/public/cpp/config.h" | 7 #include "ash/public/cpp/config.h" |
| 8 #include "ash/root_window_controller.h" |
8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
9 #include "ash/shell_port.h" | 10 #include "ash/shell_port.h" |
10 #include "ash/system/tray/system_tray_notifier.h" | 11 #include "ash/system/tray/system_tray_notifier.h" |
| 12 #include "ash/wm/ash_native_cursor_manager.h" |
11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 13 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
12 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
13 #include "ui/aura/client/focus_client.h" | 15 #include "ui/aura/client/focus_client.h" |
14 #include "ui/display/manager/display_manager.h" | 16 #include "ui/display/manager/display_manager.h" |
15 #include "ui/events/devices/input_device_manager.h" | 17 #include "ui/events/devices/input_device_manager.h" |
16 #include "ui/wm/public/activation_client.h" | 18 #include "ui/wm/public/activation_client.h" |
17 | 19 |
18 namespace exo { | 20 namespace exo { |
19 | 21 |
20 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
21 // WMHelperAsh, public: | 23 // WMHelperAsh, public: |
22 | 24 |
23 WMHelperAsh::WMHelperAsh() { | 25 WMHelperAsh::WMHelperAsh() { |
24 ash::Shell::Get()->AddShellObserver(this); | 26 ash::Shell::Get()->AddShellObserver(this); |
25 ash::Shell::Get()->activation_client()->AddObserver(this); | 27 ash::Shell::Get()->activation_client()->AddObserver(this); |
26 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. | 28 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
27 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) | 29 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) { |
28 ash::Shell::Get()->cursor_manager()->AddObserver(this); | 30 ash::Shell::Get()->cursor_manager()->AddObserver(this); |
| 31 ash::Shell::Get()->native_cursor_manager()->AddObserver(this); |
| 32 } |
29 ash::ShellPort::Get()->AddDisplayObserver(this); | 33 ash::ShellPort::Get()->AddDisplayObserver(this); |
30 aura::client::FocusClient* focus_client = | 34 aura::client::FocusClient* focus_client = |
31 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 35 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
32 focus_client->AddObserver(this); | 36 focus_client->AddObserver(this); |
33 ui::InputDeviceManager::GetInstance()->AddObserver(this); | 37 ui::InputDeviceManager::GetInstance()->AddObserver(this); |
34 } | 38 } |
35 | 39 |
36 WMHelperAsh::~WMHelperAsh() { | 40 WMHelperAsh::~WMHelperAsh() { |
37 if (!ash::Shell::HasInstance()) | 41 if (!ash::Shell::HasInstance()) |
38 return; | 42 return; |
39 aura::client::FocusClient* focus_client = | 43 aura::client::FocusClient* focus_client = |
40 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 44 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
41 focus_client->RemoveObserver(this); | 45 focus_client->RemoveObserver(this); |
42 ash::ShellPort::Get()->RemoveDisplayObserver(this); | 46 ash::ShellPort::Get()->RemoveDisplayObserver(this); |
43 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. | 47 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
44 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) | 48 if (ash::ShellPort::Get()->GetAshConfig() != ash::Config::MUS) { |
45 ash::Shell::Get()->cursor_manager()->RemoveObserver(this); | 49 ash::Shell::Get()->cursor_manager()->RemoveObserver(this); |
| 50 ash::Shell::Get()->native_cursor_manager()->RemoveObserver(this); |
| 51 } |
46 ash::Shell::Get()->activation_client()->RemoveObserver(this); | 52 ash::Shell::Get()->activation_client()->RemoveObserver(this); |
47 ash::Shell::Get()->RemoveShellObserver(this); | 53 ash::Shell::Get()->RemoveShellObserver(this); |
48 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); | 54 ui::InputDeviceManager::GetInstance()->RemoveObserver(this); |
49 } | 55 } |
50 | 56 |
51 //////////////////////////////////////////////////////////////////////////////// | 57 //////////////////////////////////////////////////////////////////////////////// |
52 // WMHelperAsh, private: | 58 // WMHelperAsh, private: |
53 | 59 |
54 const display::ManagedDisplayInfo WMHelperAsh::GetDisplayInfo( | 60 const display::ManagedDisplayInfo& WMHelperAsh::GetDisplayInfo( |
55 int64_t display_id) const { | 61 int64_t display_id) const { |
56 return ash::Shell::Get()->display_manager()->GetDisplayInfo(display_id); | 62 return ash::Shell::Get()->display_manager()->GetDisplayInfo(display_id); |
57 } | 63 } |
58 | 64 |
59 aura::Window* WMHelperAsh::GetContainer(int container_id) { | 65 aura::Window* WMHelperAsh::GetContainer(int64_t display_id, int container_id) { |
60 // TODO(domlaskowski): Use target root window once multi-display support lands | 66 ash::RootWindowController* controller = |
61 // in ARC. See crbug.com/718627. | 67 ash::Shell::GetRootWindowControllerWithDisplayId(display_id); |
62 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 68 if (!controller) |
63 container_id); | 69 return nullptr; |
| 70 return ash::Shell::GetContainer(controller->GetRootWindow(), container_id); |
64 } | 71 } |
65 | 72 |
66 aura::Window* WMHelperAsh::GetActiveWindow() const { | 73 aura::Window* WMHelperAsh::GetActiveWindow() const { |
67 return ash::Shell::Get()->activation_client()->GetActiveWindow(); | 74 return ash::Shell::Get()->activation_client()->GetActiveWindow(); |
68 } | 75 } |
69 | 76 |
70 aura::Window* WMHelperAsh::GetFocusedWindow() const { | 77 aura::Window* WMHelperAsh::GetFocusedWindow() const { |
71 aura::client::FocusClient* focus_client = | 78 aura::client::FocusClient* focus_client = |
72 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); | 79 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
73 return focus_client->GetFocusedWindow(); | 80 return focus_client->GetFocusedWindow(); |
74 } | 81 } |
75 | 82 |
76 ui::CursorSetType WMHelperAsh::GetCursorSet() const { | 83 ui::CursorSetType WMHelperAsh::GetCursorSet() const { |
77 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. | 84 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
78 if (ash::ShellPort::Get()->GetAshConfig() == ash::Config::MUS) | 85 if (ash::ShellPort::Get()->GetAshConfig() == ash::Config::MUS) |
79 return ui::CURSOR_SET_NORMAL; | 86 return ui::CURSOR_SET_NORMAL; |
80 return ash::Shell::Get()->cursor_manager()->GetCursorSet(); | 87 return ash::Shell::Get()->cursor_manager()->GetCursorSet(); |
81 } | 88 } |
82 | 89 |
| 90 const display::Display& WMHelperAsh::GetCursorDisplay() const { |
| 91 // TODO(crbug.com/631103): Mushrome doesn't have a cursor manager yet. |
| 92 if (ash::ShellPort::Get()->GetAshConfig() == ash::Config::MUS) { |
| 93 static const display::Display display; |
| 94 return display; |
| 95 } |
| 96 return ash::Shell::Get()->native_cursor_manager()->cursor_display(); |
| 97 } |
| 98 |
83 void WMHelperAsh::AddPreTargetHandler(ui::EventHandler* handler) { | 99 void WMHelperAsh::AddPreTargetHandler(ui::EventHandler* handler) { |
84 ash::Shell::Get()->AddPreTargetHandler(handler); | 100 ash::Shell::Get()->AddPreTargetHandler(handler); |
85 } | 101 } |
86 | 102 |
87 void WMHelperAsh::PrependPreTargetHandler(ui::EventHandler* handler) { | 103 void WMHelperAsh::PrependPreTargetHandler(ui::EventHandler* handler) { |
88 ash::Shell::Get()->PrependPreTargetHandler(handler); | 104 ash::Shell::Get()->PrependPreTargetHandler(handler); |
89 } | 105 } |
90 | 106 |
91 void WMHelperAsh::RemovePreTargetHandler(ui::EventHandler* handler) { | 107 void WMHelperAsh::RemovePreTargetHandler(ui::EventHandler* handler) { |
92 ash::Shell::Get()->RemovePreTargetHandler(handler); | 108 ash::Shell::Get()->RemovePreTargetHandler(handler); |
(...skipping 26 matching lines...) Expand all Loading... |
119 } | 135 } |
120 | 136 |
121 void WMHelperAsh::OnCursorVisibilityChanged(bool is_visible) { | 137 void WMHelperAsh::OnCursorVisibilityChanged(bool is_visible) { |
122 NotifyCursorVisibilityChanged(is_visible); | 138 NotifyCursorVisibilityChanged(is_visible); |
123 } | 139 } |
124 | 140 |
125 void WMHelperAsh::OnCursorSetChanged(ui::CursorSetType cursor_set) { | 141 void WMHelperAsh::OnCursorSetChanged(ui::CursorSetType cursor_set) { |
126 NotifyCursorSetChanged(cursor_set); | 142 NotifyCursorSetChanged(cursor_set); |
127 } | 143 } |
128 | 144 |
| 145 void WMHelperAsh::OnCursorDisplayChanged(const display::Display& display) { |
| 146 NotifyCursorDisplayChanged(display); |
| 147 } |
| 148 |
129 void WMHelperAsh::OnMaximizeModeStarted() { | 149 void WMHelperAsh::OnMaximizeModeStarted() { |
130 NotifyMaximizeModeStarted(); | 150 NotifyMaximizeModeStarted(); |
131 } | 151 } |
132 | 152 |
133 void WMHelperAsh::OnMaximizeModeEnding() { | 153 void WMHelperAsh::OnMaximizeModeEnding() { |
134 NotifyMaximizeModeEnding(); | 154 NotifyMaximizeModeEnding(); |
135 } | 155 } |
136 | 156 |
137 void WMHelperAsh::OnMaximizeModeEnded() { | 157 void WMHelperAsh::OnMaximizeModeEnded() { |
138 NotifyMaximizeModeEnded(); | 158 NotifyMaximizeModeEnded(); |
139 } | 159 } |
140 | 160 |
141 void WMHelperAsh::OnDisplayConfigurationChanged() { | 161 void WMHelperAsh::OnDisplayConfigurationChanged() { |
142 NotifyDisplayConfigurationChanged(); | 162 NotifyDisplayConfigurationChanged(); |
143 } | 163 } |
144 | 164 |
145 void WMHelperAsh::OnKeyboardDeviceConfigurationChanged() { | 165 void WMHelperAsh::OnKeyboardDeviceConfigurationChanged() { |
146 NotifyKeyboardDeviceConfigurationChanged(); | 166 NotifyKeyboardDeviceConfigurationChanged(); |
147 } | 167 } |
148 | 168 |
149 } // namespace exo | 169 } // namespace exo |
OLD | NEW |