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

Unified 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, 8 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/platform_display_default.cc
diff --git a/services/ui/ws/platform_display_default.cc b/services/ui/ws/platform_display_default.cc
index 93611c80645ea38269be79af8d4767060cee7d03..b879e33517207034f050e1fbb4829724526a6401 100644
--- a/services/ui/ws/platform_display_default.cc
+++ b/services/ui/ws/platform_display_default.cc
@@ -26,6 +26,7 @@
#elif defined(OS_ANDROID)
#include "ui/platform_window/android/platform_window_android.h"
#elif defined(USE_OZONE)
+#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/ozone_platform.h"
#endif
@@ -100,22 +101,43 @@ void PlatformDisplayDefault::ReleaseCapture() {
platform_window_->ReleaseCapture();
}
-void PlatformDisplayDefault::SetCursorById(mojom::CursorType cursor_id) {
+void PlatformDisplayDefault::SetCursor(const ui::CursorData& cursor_data) {
if (!image_cursors_)
return;
- // TODO(erg): This still isn't sufficient, and will only use native cursors
- // that chrome would use, not custom image cursors. For that, we should
- // delegate to the window manager to load images from resource packs.
+ ui::Cursor native_cursor(cursor_data.cursor_type());
+
+#if defined(USE_OZONE)
+ if (cursor_data.cursor_type() != ui::CursorType::kCustom) {
+ image_cursors_->SetPlatformCursor(&native_cursor);
+ } else {
+ // In Ozone builds, we have an interface available which turns bitmap data
+ // into platform cursors.
+ ui::CursorFactoryOzone* cursor_factory =
+ delegate_->GetOzonePlatform()->GetCursorFactoryOzone();
+ native_cursor.SetPlatformCursor(cursor_factory->CreateAnimatedCursor(
+ cursor_data.cursor_frames(), cursor_data.hotspot_in_pixels(),
+ cursor_data.frame_delay().InMilliseconds(),
+ cursor_data.scale_factor()));
+ }
+#else
+ // Outside of ozone builds, there isn't a single interface for creating
+ // PlatformCursors. The closest thing to one is in //content/ instead of
+ // //ui/ which means we can't use it from here. For now, just don't handle
+ // custom image cursors.
//
- // We probably also need to deal with different DPIs.
- ui::CursorType type;
- if (mojo::EnumTraits<ui::mojom::CursorType, ui::CursorType>::FromMojom(
- cursor_id, &type)) {
- ui::Cursor cursor(type);
- image_cursors_->SetPlatformCursor(&cursor);
- platform_window_->SetCursor(cursor.platform());
+ // TODO(erg): Once blink speaks directly to mus, make blink perform its own
+ // cursor management on its own mus windows so we can remove Webcursor from
+ // //content/ and do this in way that's safe cross-platform, instead of as an
+ // ozone-specific hack.
+ if (cursor_data.cursor_type() == ui::CursorType::kCustom) {
+ NOTIMPLEMENTED() << "No custom cursor support on non-ozone yet.";
+ native_cursor = ui::Cursor(ui::CursorType::kPointer);
}
+ image_cursors_->SetPlatformCursor(&native_cursor);
+#endif
+
+ platform_window_->SetCursor(native_cursor.platform());
}
void PlatformDisplayDefault::UpdateTextInputState(
« 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