OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/host/chromeos/mouse_cursor_monitor_aura.h" | 5 #include "remoting/host/chromeos/mouse_cursor_monitor_aura.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 gfx::Point position = aura::Env::GetInstance()->last_mouse_location(); | 59 gfx::Point position = aura::Env::GetInstance()->last_mouse_location(); |
60 if (position != last_mouse_location_) { | 60 if (position != last_mouse_location_) { |
61 last_mouse_location_ = position; | 61 last_mouse_location_ = position; |
62 callback_->OnMouseCursorPosition( | 62 callback_->OnMouseCursorPosition( |
63 INSIDE, webrtc::DesktopVector(position.x(), position.y())); | 63 INSIDE, webrtc::DesktopVector(position.x(), position.y())); |
64 } | 64 } |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 void MouseCursorMonitorAura::NotifyCursorChanged(const ui::Cursor& cursor) { | 68 void MouseCursorMonitorAura::NotifyCursorChanged(const ui::Cursor& cursor) { |
69 scoped_ptr<SkBitmap> cursor_bitmap(new SkBitmap()); | 69 std::unique_ptr<SkBitmap> cursor_bitmap(new SkBitmap()); |
70 gfx::Point cursor_hotspot; | 70 gfx::Point cursor_hotspot; |
71 | 71 |
72 if (cursor.native_type() == ui::kCursorNone) { | 72 if (cursor.native_type() == ui::kCursorNone) { |
73 callback_->OnMouseCursor(CreateEmptyMouseCursor()); | 73 callback_->OnMouseCursor(CreateEmptyMouseCursor()); |
74 return; | 74 return; |
75 } | 75 } |
76 | 76 |
77 if (!ui::GetCursorBitmap(cursor, cursor_bitmap.get(), &cursor_hotspot)) { | 77 if (!ui::GetCursorBitmap(cursor, cursor_bitmap.get(), &cursor_hotspot)) { |
78 LOG(ERROR) << "Failed to load bitmap for cursor type:" | 78 LOG(ERROR) << "Failed to load bitmap for cursor type:" |
79 << cursor.native_type(); | 79 << cursor.native_type(); |
80 callback_->OnMouseCursor(CreateEmptyMouseCursor()); | 80 callback_->OnMouseCursor(CreateEmptyMouseCursor()); |
81 return; | 81 return; |
82 } | 82 } |
83 | 83 |
84 // There is a bug (crbug.com/436993) in aura::GetCursorBitmap() such that it | 84 // There is a bug (crbug.com/436993) in aura::GetCursorBitmap() such that it |
85 // it would return a scale-factor-100 bitmap with a scale-factor-200 hotspot. | 85 // it would return a scale-factor-100 bitmap with a scale-factor-200 hotspot. |
86 // This causes the hotspot to go out of range. As a result, we would need to | 86 // This causes the hotspot to go out of range. As a result, we would need to |
87 // manually downscale the hotspot. | 87 // manually downscale the hotspot. |
88 float scale_factor = cursor.device_scale_factor(); | 88 float scale_factor = cursor.device_scale_factor(); |
89 cursor_hotspot.SetPoint(cursor_hotspot.x() / scale_factor, | 89 cursor_hotspot.SetPoint(cursor_hotspot.x() / scale_factor, |
90 cursor_hotspot.y() / scale_factor); | 90 cursor_hotspot.y() / scale_factor); |
91 | 91 |
92 if (cursor_hotspot.x() >= cursor_bitmap->width() || | 92 if (cursor_hotspot.x() >= cursor_bitmap->width() || |
93 cursor_hotspot.y() >= cursor_bitmap->height()) { | 93 cursor_hotspot.y() >= cursor_bitmap->height()) { |
94 LOG(WARNING) << "Cursor hotspot is out of bounds for type: " | 94 LOG(WARNING) << "Cursor hotspot is out of bounds for type: " |
95 << cursor.native_type() << ". Setting to (0,0) instead"; | 95 << cursor.native_type() << ". Setting to (0,0) instead"; |
96 cursor_hotspot.SetPoint(0, 0); | 96 cursor_hotspot.SetPoint(0, 0); |
97 } | 97 } |
98 | 98 |
99 scoped_ptr<webrtc::DesktopFrame> image( | 99 std::unique_ptr<webrtc::DesktopFrame> image( |
100 SkiaBitmapDesktopFrame::Create(std::move(cursor_bitmap))); | 100 SkiaBitmapDesktopFrame::Create(std::move(cursor_bitmap))); |
101 scoped_ptr<webrtc::MouseCursor> cursor_shape(new webrtc::MouseCursor( | 101 std::unique_ptr<webrtc::MouseCursor> cursor_shape(new webrtc::MouseCursor( |
102 image.release(), | 102 image.release(), |
103 webrtc::DesktopVector(cursor_hotspot.x(), cursor_hotspot.y()))); | 103 webrtc::DesktopVector(cursor_hotspot.x(), cursor_hotspot.y()))); |
104 | 104 |
105 callback_->OnMouseCursor(cursor_shape.release()); | 105 callback_->OnMouseCursor(cursor_shape.release()); |
106 } | 106 } |
107 | 107 |
108 } // namespace remoting | 108 } // namespace remoting |
OLD | NEW |