OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ash/wm/native_cursor_manager_ash_mus.h" | 5 #include "ash/wm/native_cursor_manager_ash_mus.h" |
6 | 6 |
7 #include "ash/display/cursor_window_controller.h" | 7 #include "ash/display/cursor_window_controller.h" |
8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_port.h" | |
11 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| 11 #include "ui/aura/mus/window_manager_delegate.h" |
12 #include "ui/aura/mus/window_port_mus.h" | 12 #include "ui/aura/mus/window_port_mus.h" |
13 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
14 #include "ui/aura/window_tree_host.h" | 14 #include "ui/aura/window_tree_host.h" |
15 #include "ui/base/cursor/image_cursors.h" | 15 #include "ui/base/cursor/image_cursors.h" |
16 #include "ui/base/layout.h" | 16 #include "ui/base/layout.h" |
17 #include "ui/wm/core/cursor_manager.h" | 17 #include "ui/wm/core/cursor_manager.h" |
18 | 18 |
19 #if defined(USE_OZONE) | 19 #if defined(USE_OZONE) |
20 #include "ui/base/cursor/ozone/cursor_data_factory_ozone.h" | 20 #include "ui/base/cursor/ozone/cursor_data_factory_ozone.h" |
21 #endif | 21 #endif |
(...skipping 13 matching lines...) Expand all Loading... |
35 << "Can't pass native platform cursors on non-ozone platforms"; | 35 << "Can't pass native platform cursors on non-ozone platforms"; |
36 mojo_cursor = ui::CursorData(ui::CursorType::kPointer); | 36 mojo_cursor = ui::CursorData(ui::CursorType::kPointer); |
37 #endif | 37 #endif |
38 } else { | 38 } else { |
39 mojo_cursor = ui::CursorData(cursor.native_type()); | 39 mojo_cursor = ui::CursorData(cursor.native_type()); |
40 } | 40 } |
41 | 41 |
42 // As the window manager, tell mus to use |mojo_cursor| everywhere. We do | 42 // As the window manager, tell mus to use |mojo_cursor| everywhere. We do |
43 // this instead of trying to set per-window because otherwise we run into the | 43 // this instead of trying to set per-window because otherwise we run into the |
44 // event targeting issue. | 44 // event targeting issue. |
45 ShellPort::Get()->SetGlobalOverrideCursor(mojo_cursor); | 45 Shell::window_manager_client()->SetGlobalOverrideCursor(mojo_cursor); |
46 | 46 |
47 // Make sure the local state is set properly, so that local queries show that | 47 // Make sure the local state is set properly, so that local queries show that |
48 // we set the cursor. | 48 // we set the cursor. |
49 for (aura::Window* root : Shell::Get()->GetAllRootWindows()) | 49 for (aura::Window* root : Shell::Get()->GetAllRootWindows()) |
50 root->GetHost()->SetCursor(cursor); | 50 root->GetHost()->SetCursor(cursor); |
51 | 51 |
52 Shell::Get() | 52 Shell::Get() |
53 ->window_tree_host_manager() | 53 ->window_tree_host_manager() |
54 ->cursor_window_controller() | 54 ->cursor_window_controller() |
55 ->SetCursor(cursor); | 55 ->SetCursor(cursor); |
56 } | 56 } |
57 | 57 |
58 void NotifyCursorVisibilityChange(bool visible) { | 58 void NotifyCursorVisibilityChange(bool visible) { |
59 // Communicate the cursor visibility state to the mus server. | 59 // Communicate the cursor visibility state to the mus server. |
60 if (visible) | 60 Shell::window_manager_client()->SetCursorVisible(visible); |
61 ShellPort::Get()->ShowCursor(); | |
62 else | |
63 ShellPort::Get()->HideCursor(); | |
64 | 61 |
65 // Communicate the cursor visibility change to our local root window objects. | 62 // Communicate the cursor visibility change to our local root window objects. |
66 aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows(); | 63 aura::Window::Windows root_windows = Shell::Get()->GetAllRootWindows(); |
67 for (aura::Window::Windows::iterator iter = root_windows.begin(); | 64 for (aura::Window::Windows::iterator iter = root_windows.begin(); |
68 iter != root_windows.end(); ++iter) | 65 iter != root_windows.end(); ++iter) |
69 (*iter)->GetHost()->OnCursorVisibilityChanged(visible); | 66 (*iter)->GetHost()->OnCursorVisibilityChanged(visible); |
70 | 67 |
71 Shell::Get() | 68 Shell::Get() |
72 ->window_tree_host_manager() | 69 ->window_tree_host_manager() |
73 ->cursor_window_controller() | 70 ->cursor_window_controller() |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 174 } |
178 | 175 |
179 NotifyCursorVisibilityChange(visible); | 176 NotifyCursorVisibilityChange(visible); |
180 } | 177 } |
181 | 178 |
182 void NativeCursorManagerAshMus::SetCursorSize( | 179 void NativeCursorManagerAshMus::SetCursorSize( |
183 ui::CursorSize cursor_size, | 180 ui::CursorSize cursor_size, |
184 ::wm::NativeCursorManagerDelegate* delegate) { | 181 ::wm::NativeCursorManagerDelegate* delegate) { |
185 delegate->CommitCursorSize(cursor_size); | 182 delegate->CommitCursorSize(cursor_size); |
186 | 183 |
187 ShellPort::Get()->SetCursorSize(cursor_size); | 184 Shell::window_manager_client()->SetCursorSize(cursor_size); |
188 | 185 |
189 Shell::Get() | 186 Shell::Get() |
190 ->window_tree_host_manager() | 187 ->window_tree_host_manager() |
191 ->cursor_window_controller() | 188 ->cursor_window_controller() |
192 ->SetCursorSize(cursor_size); | 189 ->SetCursorSize(cursor_size); |
193 } | 190 } |
194 | 191 |
195 void NativeCursorManagerAshMus::SetMouseEventsEnabled( | 192 void NativeCursorManagerAshMus::SetMouseEventsEnabled( |
196 bool enabled, | 193 bool enabled, |
197 ::wm::NativeCursorManagerDelegate* delegate) { | 194 ::wm::NativeCursorManagerDelegate* delegate) { |
198 delegate->CommitMouseEventsEnabled(enabled); | 195 delegate->CommitMouseEventsEnabled(enabled); |
199 | 196 |
200 if (enabled) { | 197 if (enabled) { |
201 aura::Env::GetInstance()->set_last_mouse_location( | 198 aura::Env::GetInstance()->set_last_mouse_location( |
202 disabled_cursor_location_); | 199 disabled_cursor_location_); |
203 } else { | 200 } else { |
204 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location(); | 201 disabled_cursor_location_ = aura::Env::GetInstance()->last_mouse_location(); |
205 } | 202 } |
206 | 203 |
207 SetVisibility(delegate->IsCursorVisible(), delegate); | 204 SetVisibility(delegate->IsCursorVisible(), delegate); |
208 | 205 |
209 NotifyMouseEventsEnableStateChange(enabled); | 206 NotifyMouseEventsEnableStateChange(enabled); |
210 } | 207 } |
211 | 208 |
212 } // namespace ash | 209 } // namespace ash |
OLD | NEW |