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

Unified Diff: components/mus/ws/display_manager.cc

Issue 1465803003: mus: Let clients set the cursor of their window. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WindowTreeAppTest.SetCursor. Created 5 years 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
Index: components/mus/ws/display_manager.cc
diff --git a/components/mus/ws/display_manager.cc b/components/mus/ws/display_manager.cc
index afbe6e9ff8ea491063d1c1e8edc2aacfc310bf88..334dd0242bdb66e5e737c2e44d3cde41991940b3 100644
--- a/components/mus/ws/display_manager.cc
+++ b/components/mus/ws/display_manager.cc
@@ -29,6 +29,7 @@
#include "mojo/converters/surfaces/surfaces_utils.h"
#include "mojo/converters/transform/transform_type_converters.h"
#include "third_party/skia/include/core/SkXfermode.h"
+#include "ui/base/cursor/cursor_loader.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/display.h"
@@ -170,6 +171,9 @@ DefaultDisplayManager::DefaultDisplayManager(
delegate_(nullptr),
draw_timer_(false, false),
frame_pending_(false),
+#if !defined(OS_ANDROID)
+ cursor_loader_(ui::CursorLoader::Create()),
+#endif
weak_factory_(this) {
metrics_.size_in_pixels = mojo::Size::New();
metrics_.size_in_pixels->width = 1024;
@@ -226,6 +230,19 @@ void DefaultDisplayManager::SetTitle(const base::string16& title) {
platform_window_->SetTitle(title);
}
+void DefaultDisplayManager::SetCursorById(int32_t cursor_id) {
+#if !defined(OS_ANDROID)
+ // 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.
+ //
+ // We probably also need to deal with different DPIs.
+ ui::Cursor cursor(cursor_id);
+ cursor_loader_->SetPlatformCursor(&cursor);
+ platform_window_->SetCursor(cursor.platform());
+#endif
+}
+
const mojom::ViewportMetrics& DefaultDisplayManager::GetViewportMetrics() {
return metrics_;
}

Powered by Google App Engine
This is Rietveld 408576698