UI/AppKit: Support image cursors

This commit is contained in:
Sam Atkins 2025-02-21 12:47:53 +00:00 committed by Andreas Kling
commit fc4a2eeba8
Notes: github-actions[bot] 2025-02-28 12:51:08 +00:00

View file

@ -450,14 +450,14 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
if (self == nil) { if (self == nil) {
return; return;
} }
if (!cursor.template has<Gfx::StandardCursor>()) { cursor.template visit(
// FIXME: Implement image cursors in AppKit. [](Gfx::ImageCursor const& image_cursor) {
[[NSCursor arrowCursor] set]; auto* cursor_image = Ladybird::gfx_bitmap_to_ns_image(*image_cursor.bitmap.bitmap());
return; auto hotspot = Ladybird::gfx_point_to_ns_point(image_cursor.hotspot);
}
auto standard_cursor = cursor.template get<Gfx::StandardCursor>();
[[[NSCursor alloc] initWithImage:cursor_image hotSpot:hotspot] set];
},
[&self](Gfx::StandardCursor standard_cursor) {
if (standard_cursor == Gfx::StandardCursor::Hidden) { if (standard_cursor == Gfx::StandardCursor::Hidden) {
if (!m_hidden_cursor.has_value()) { if (!m_hidden_cursor.has_value()) {
m_hidden_cursor.emplace(); m_hidden_cursor.emplace();
@ -534,6 +534,7 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
default: default:
break; break;
} }
});
}; };
m_web_view_bridge->on_zoom_level_changed = [weak_self]() { m_web_view_bridge->on_zoom_level_changed = [weak_self]() {