Index: ash/wm/cursor_manager.cc |
diff --git a/ash/wm/cursor_manager.cc b/ash/wm/cursor_manager.cc |
index 1ebc72bfc7196f67fa71b3bda4523b0aafae1960..2f0847829e9e06f0e10fecec50ad97f5c077f3b8 100644 |
--- a/ash/wm/cursor_manager.cc |
+++ b/ash/wm/cursor_manager.cc |
@@ -5,8 +5,10 @@ |
#include "ash/wm/cursor_manager.h" |
#include "ash/wm/cursor_delegate.h" |
+#include "ash/wm/image_cursors.h" |
#include "base/logging.h" |
#include "ui/aura/env.h" |
+#include "ui/base/cursor/cursor.h" |
namespace ash { |
@@ -15,7 +17,9 @@ CursorManager::CursorManager() |
cursor_lock_count_(0), |
did_cursor_change_(false), |
cursor_to_set_on_unlock_(0), |
- cursor_visible_(true) { |
+ cursor_visible_(true), |
+ current_cursor_(ui::kCursorNone), |
+ image_cursors_(new ImageCursors) { |
} |
CursorManager::~CursorManager() { |
@@ -39,10 +43,21 @@ void CursorManager::UnlockCursor() { |
} |
} |
+gfx::NativeCursor CursorManager::GetCursorFromNativeType( |
+ gfx::NativeCursor cursor) { |
+ image_cursors_->SetPlatformCursor(&cursor); |
+ cursor.set_device_scale_factor(image_cursors_->GetDeviceScaleFactor()); |
+ return cursor; |
+} |
+ |
+void CursorManager::HideHostCursor() { |
+ image_cursors_->HideHostCursor(); |
+} |
+ |
void CursorManager::SetCursor(gfx::NativeCursor cursor) { |
if (cursor_lock_count_ == 0) { |
if (delegate_) |
- delegate_->SetCursor(cursor); |
+ SetCursorInternal(cursor); |
} else { |
cursor_to_set_on_unlock_ = cursor; |
did_cursor_change_ = true; |
@@ -59,4 +74,17 @@ bool CursorManager::IsCursorVisible() const { |
return cursor_visible_; |
} |
+void CursorManager::SetDeviceScaleFactor(float device_scale_factor) { |
+ if (image_cursors_->GetDeviceScaleFactor() == device_scale_factor) |
+ return; |
+ image_cursors_->Reload(device_scale_factor); |
+ SetCursorInternal(current_cursor_); |
+} |
+ |
+void CursorManager::SetCursorInternal(gfx::NativeCursor cursor) { |
+ DCHECK(delegate_); |
+ current_cursor_ = GetCursorFromNativeType(cursor); |
+ delegate_->SetCursor(current_cursor_); |
+} |
+ |
} // namespace ash |