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

Side by Side Diff: services/ui/ws/platform_display_default.cc

Issue 2830703003: [views-mus] Support custom cursors. (Closed)
Patch Set: fix cast_shell_linux Created 3 years, 7 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
« no previous file with comments | « services/ui/ws/platform_display_default.h ('k') | services/ui/ws/server_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "services/ui/ws/platform_display_default.h" 5 #include "services/ui/ws/platform_display_default.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "gpu/ipc/client/gpu_channel_host.h" 10 #include "gpu/ipc/client/gpu_channel_host.h"
11 #include "services/ui/display/screen_manager.h" 11 #include "services/ui/display/screen_manager.h"
12 #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h" 12 #include "services/ui/public/interfaces/cursor/cursor_struct_traits.h"
13 #include "services/ui/ws/display_client_compositor_frame_sink.h" 13 #include "services/ui/ws/display_client_compositor_frame_sink.h"
14 #include "services/ui/ws/server_window.h" 14 #include "services/ui/ws/server_window.h"
15 #include "ui/base/cursor/image_cursors.h" 15 #include "ui/base/cursor/image_cursors.h"
16 #include "ui/display/display.h" 16 #include "ui/display/display.h"
17 #include "ui/events/event.h" 17 #include "ui/events/event.h"
18 #include "ui/events/event_utils.h" 18 #include "ui/events/event_utils.h"
19 #include "ui/platform_window/platform_ime_controller.h" 19 #include "ui/platform_window/platform_ime_controller.h"
20 #include "ui/platform_window/platform_window.h" 20 #include "ui/platform_window/platform_window.h"
21 21
22 #if defined(OS_WIN) 22 #if defined(OS_WIN)
23 #include "ui/platform_window/win/win_window.h" 23 #include "ui/platform_window/win/win_window.h"
24 #elif defined(USE_X11) && !defined(OS_CHROMEOS) 24 #elif defined(USE_X11) && !defined(OS_CHROMEOS)
25 #include "ui/platform_window/x11/x11_window.h" 25 #include "ui/platform_window/x11/x11_window.h"
26 #elif defined(OS_ANDROID) 26 #elif defined(OS_ANDROID)
27 #include "ui/platform_window/android/platform_window_android.h" 27 #include "ui/platform_window/android/platform_window_android.h"
28 #elif defined(USE_OZONE) 28 #elif defined(USE_OZONE)
29 #include "ui/ozone/public/cursor_factory_ozone.h"
29 #include "ui/ozone/public/ozone_platform.h" 30 #include "ui/ozone/public/ozone_platform.h"
30 #endif 31 #endif
31 32
32 namespace ui { 33 namespace ui {
33 namespace ws { 34 namespace ws {
34 35
35 PlatformDisplayDefault::PlatformDisplayDefault( 36 PlatformDisplayDefault::PlatformDisplayDefault(
36 ServerWindow* root_window, 37 ServerWindow* root_window,
37 const display::ViewportMetrics& metrics, 38 const display::ViewportMetrics& metrics,
38 std::unique_ptr<ImageCursors> image_cursors) 39 std::unique_ptr<ImageCursors> image_cursors)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 94 }
94 95
95 void PlatformDisplayDefault::SetCapture() { 96 void PlatformDisplayDefault::SetCapture() {
96 platform_window_->SetCapture(); 97 platform_window_->SetCapture();
97 } 98 }
98 99
99 void PlatformDisplayDefault::ReleaseCapture() { 100 void PlatformDisplayDefault::ReleaseCapture() {
100 platform_window_->ReleaseCapture(); 101 platform_window_->ReleaseCapture();
101 } 102 }
102 103
103 void PlatformDisplayDefault::SetCursorById(mojom::CursorType cursor_id) { 104 void PlatformDisplayDefault::SetCursor(const ui::CursorData& cursor_data) {
104 if (!image_cursors_) 105 if (!image_cursors_)
105 return; 106 return;
106 107
107 // TODO(erg): This still isn't sufficient, and will only use native cursors 108 ui::Cursor native_cursor(cursor_data.cursor_type());
108 // that chrome would use, not custom image cursors. For that, we should 109
109 // delegate to the window manager to load images from resource packs. 110 #if defined(USE_OZONE)
111 if (cursor_data.cursor_type() != ui::CursorType::kCustom) {
112 image_cursors_->SetPlatformCursor(&native_cursor);
113 } else {
114 // In Ozone builds, we have an interface available which turns bitmap data
115 // into platform cursors.
116 ui::CursorFactoryOzone* cursor_factory =
117 delegate_->GetOzonePlatform()->GetCursorFactoryOzone();
118 native_cursor.SetPlatformCursor(cursor_factory->CreateAnimatedCursor(
119 cursor_data.cursor_frames(), cursor_data.hotspot_in_pixels(),
120 cursor_data.frame_delay().InMilliseconds(),
121 cursor_data.scale_factor()));
122 }
123 #else
124 // Outside of ozone builds, there isn't a single interface for creating
125 // PlatformCursors. The closest thing to one is in //content/ instead of
126 // //ui/ which means we can't use it from here. For now, just don't handle
127 // custom image cursors.
110 // 128 //
111 // We probably also need to deal with different DPIs. 129 // TODO(erg): Once blink speaks directly to mus, make blink perform its own
112 ui::CursorType type; 130 // cursor management on its own mus windows so we can remove Webcursor from
113 if (mojo::EnumTraits<ui::mojom::CursorType, ui::CursorType>::FromMojom( 131 // //content/ and do this in way that's safe cross-platform, instead of as an
114 cursor_id, &type)) { 132 // ozone-specific hack.
115 ui::Cursor cursor(type); 133 if (cursor_data.cursor_type() == ui::CursorType::kCustom) {
116 image_cursors_->SetPlatformCursor(&cursor); 134 NOTIMPLEMENTED() << "No custom cursor support on non-ozone yet.";
117 platform_window_->SetCursor(cursor.platform()); 135 native_cursor = ui::Cursor(ui::CursorType::kPointer);
118 } 136 }
137 image_cursors_->SetPlatformCursor(&native_cursor);
138 #endif
139
140 platform_window_->SetCursor(native_cursor.platform());
119 } 141 }
120 142
121 void PlatformDisplayDefault::UpdateTextInputState( 143 void PlatformDisplayDefault::UpdateTextInputState(
122 const ui::TextInputState& state) { 144 const ui::TextInputState& state) {
123 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); 145 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController();
124 if (ime) 146 if (ime)
125 ime->UpdateTextInputState(state); 147 ime->UpdateTextInputState(state);
126 } 148 }
127 149
128 void PlatformDisplayDefault::SetImeVisibility(bool visible) { 150 void PlatformDisplayDefault::SetImeVisibility(bool visible) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 274 }
253 275
254 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { 276 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() {
255 NOTREACHED(); 277 NOTREACHED();
256 } 278 }
257 279
258 void PlatformDisplayDefault::OnActivationChanged(bool active) {} 280 void PlatformDisplayDefault::OnActivationChanged(bool active) {}
259 281
260 } // namespace ws 282 } // namespace ws
261 } // namespace ui 283 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/platform_display_default.h ('k') | services/ui/ws/server_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698