cursor: refactor CustomCursor to be dyn

cursor: refactor `CustomCursor` to be `dyn`

Same as for `MonitorHandle`, the source was changed to support
all kinds of sources.
This commit is contained in:
Kirill Chibisov 2025-03-13 17:18:37 +03:00 committed by GitHub
parent a0464ae83b
commit ae28eea406
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 329 additions and 333 deletions

View file

@ -36,7 +36,7 @@ use objc2_foundation::{
use tracing::{trace, warn};
use super::app_state::AppState;
use super::cursor::cursor_from_icon;
use super::cursor::{cursor_from_icon, CustomCursor};
use super::monitor::{self, flip_window_screen_coordinates, get_display_id};
use super::observer::RunLoop;
use super::util::cgerr;
@ -1249,7 +1249,13 @@ impl WindowDelegate {
let cursor = match cursor {
Cursor::Icon(icon) => cursor_from_icon(icon),
Cursor::Custom(cursor) => cursor.inner.0,
Cursor::Custom(cursor) => match cursor.cast_ref::<CustomCursor>() {
Some(cursor) => cursor.0.clone(),
None => {
tracing::error!("unrecognized cursor passed to macOS backend");
return;
},
},
};
if view.cursor_icon() == cursor {