Desktop: Custom cursor support (#3452)

custom cursors with caching
This commit is contained in:
Timon
2025-12-07 00:16:14 +00:00
committed by GitHub
parent 2e4481880e
commit a5cf62a90b
6 changed files with 68 additions and 16 deletions

View File

@@ -12,16 +12,19 @@
//!
//! The system gracefully falls back to CPU textures when hardware acceleration is unavailable.
use crate::event::{AppEvent, AppEventScheduler};
use crate::render::FrameBufferRef;
use crate::wrapper::{WgpuContext, deserialize_editor_message};
use std::fs::File;
use std::io::{Cursor, Read};
use std::io;
use std::io::Read;
use std::path::PathBuf;
use std::sync::mpsc::Receiver;
use std::sync::{Arc, Mutex};
use std::time::Instant;
use crate::event::{AppEvent, AppEventScheduler};
use crate::render::FrameBufferRef;
use crate::window::Cursor;
use crate::wrapper::{WgpuContext, deserialize_editor_message};
mod consts;
mod context;
mod dirs;
@@ -42,7 +45,7 @@ pub(crate) trait CefEventHandler: Send + Sync + 'static {
#[cfg(feature = "accelerated_paint")]
fn draw_gpu(&self, shared_texture: SharedTextureHandle);
fn load_resource(&self, path: PathBuf) -> Option<Resource>;
fn cursor_change(&self, cursor: winit::cursor::Cursor);
fn cursor_change(&self, cursor: Cursor);
/// Schedule the main event loop to run the CEF event loop after the timeout.
/// See [`_cef_browser_process_handler_t::on_schedule_message_pump_work`] for more documentation.
fn schedule_cef_message_loop_work(&self, scheduled_time: Instant);
@@ -105,7 +108,7 @@ pub(crate) struct Resource {
#[expect(dead_code)]
#[derive(Clone)]
pub(crate) enum ResourceReader {
Embedded(Cursor<&'static [u8]>),
Embedded(io::Cursor<&'static [u8]>),
File(Arc<File>),
}
impl Read for ResourceReader {
@@ -227,7 +230,7 @@ impl CefEventHandler for CefHandler {
&& let Some(file) = resources.get_file(&path)
{
return Some(Resource {
reader: ResourceReader::Embedded(Cursor::new(file.contents())),
reader: ResourceReader::Embedded(io::Cursor::new(file.contents())),
mimetype,
});
}
@@ -252,7 +255,7 @@ impl CefEventHandler for CefHandler {
None
}
fn cursor_change(&self, cursor: winit::cursor::Cursor) {
fn cursor_change(&self, cursor: Cursor) {
self.app_event_scheduler.schedule(AppEvent::CursorChange(cursor));
}