Create custom cursor with directly with event loop
Replace the `CustomCursorBuilder` with the `CustomCursorSource` and perform the loading of the cursor via the `EventLoop::create_custom_cursor` instead of passing it to the builder itself. This follows the `EventLoop::create_window` API.
This commit is contained in:
parent
3fb93b4f83
commit
7abd427216
26 changed files with 213 additions and 175 deletions
|
|
@ -81,6 +81,7 @@ use crate::{
|
|||
dark_mode::try_theme,
|
||||
dpi::{become_dpi_aware, dpi_to_scale_factor},
|
||||
drop_handler::FileDropHandler,
|
||||
icon::WinCursor,
|
||||
ime::ImeContext,
|
||||
keyboard::KeyEventBuilder,
|
||||
keyboard_layout::LAYOUT_CACHE,
|
||||
|
|
@ -90,7 +91,7 @@ use crate::{
|
|||
window_state::{CursorFlags, ImeState, WindowFlags, WindowState},
|
||||
wrap_device_id, Fullscreen, WindowId, DEVICE_ID,
|
||||
},
|
||||
window::WindowId as RootWindowId,
|
||||
window::{CustomCursor as RootCustomCursor, CustomCursorSource, WindowId as RootWindowId},
|
||||
};
|
||||
use runner::{EventLoopRunner, EventLoopRunnerShared};
|
||||
|
||||
|
|
@ -531,6 +532,18 @@ impl ActiveEventLoop {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn create_custom_cursor(&self, source: CustomCursorSource) -> RootCustomCursor {
|
||||
let inner = match WinCursor::new(&source.inner.0) {
|
||||
Ok(cursor) => cursor,
|
||||
Err(err) => {
|
||||
log::warn!("Failed to create custom cursor: {err}");
|
||||
WinCursor::Failed
|
||||
}
|
||||
};
|
||||
|
||||
RootCustomCursor { inner }
|
||||
}
|
||||
|
||||
// TODO: Investigate opportunities for caching
|
||||
pub fn available_monitors(&self) -> VecDeque<MonitorHandle> {
|
||||
monitor::available_monitors()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue