Skip to content

Windows: cache custom cursor#3293

Merged
daxpedda merged 1 commit intorust-windowing:masterfrom
daxpedda:windows-cache-custom-cursor
Jan 5, 2024
Merged

Windows: cache custom cursor#3293
daxpedda merged 1 commit intorust-windowing:masterfrom
daxpedda:windows-cache-custom-cursor

Conversation

@daxpedda
Copy link
Member

@daxpedda daxpedda commented Dec 23, 2023

We might want to let CustomCursorBuilder::build() be able to return an error, but that's a discussion for the future.
For now, the behavior doesn't actually change, because before this PR we didn't return an error from Window::set_custom_cursor() as well.

@daxpedda daxpedda marked this pull request as draft December 23, 2023 14:55
@daxpedda daxpedda added DS - appkit Affects the AppKit/macOS backend DS - win32 Affects the Win32/Windows backend and removed DS - appkit Affects the AppKit/macOS backend labels Dec 23, 2023
@daxpedda daxpedda force-pushed the windows-cache-custom-cursor branch from d891314 to 8f682c4 Compare December 23, 2023 15:15
@daxpedda daxpedda marked this pull request as ready for review December 23, 2023 15:15
@daxpedda daxpedda force-pushed the windows-cache-custom-cursor branch 2 times, most recently from 49d7b8a to 1d0854e Compare December 23, 2023 15:24
Ok(cursor) => cursor,
Err(err) => {
warn!("Failed to create custom cursor: {err}");
WinCursor::Failed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this, I think the API should actually be something like:

impl CustomCursor {
    pub fn from_rgba(
        rgba: impl Into<Vec<u8>>,
        width: u16,
        height: u16,
        hotspot_x: u16,
        hotspot_y: u16,
    ) -> CustomCursorBuilder;
}

impl CustomCursorBuilder {
    pub fn build<T>(self, window_target: &EventLoopWindowTarget<T>) -> Result<CustomCursor, BadImage>;
}

But that can be done later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, will do that in a follow-up.

@daxpedda daxpedda force-pushed the windows-cache-custom-cursor branch from 1d0854e to c89a673 Compare December 23, 2023 15:36
@daxpedda daxpedda mentioned this pull request Dec 24, 2023
25 tasks
@daxpedda daxpedda force-pushed the windows-cache-custom-cursor branch from c89a673 to 9798664 Compare December 25, 2023 09:08
@daxpedda daxpedda added this to the Version 0.30.0 milestone Dec 25, 2023
@daxpedda daxpedda force-pushed the windows-cache-custom-cursor branch from 9798664 to 5b3c25f Compare January 5, 2024 15:17
@daxpedda daxpedda force-pushed the windows-cache-custom-cursor branch from 5b3c25f to a50581f Compare January 5, 2024 15:19
@daxpedda daxpedda merged commit 787b2d7 into rust-windowing:master Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - win32 Affects the Win32/Windows backend

Development

Successfully merging this pull request may close these issues.

3 participants