Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make (Active)EventLoop::create_custom_cursor() return a Result<CustomCursor, ExternalError> #3844

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

daxpedda
Copy link
Member

@daxpedda daxpedda commented Aug 2, 2024

This PR changes (Active)EventLoop::create_custom_cursor() to return a Result<CustomCursor, ExternalError>.

  • Android, iOS and Orbital now return ExternalError::Unsupported.
  • MacOS, Windows and X11 can now return an error instead of panicking or doing nothing.
  • Wayland doesn't implement custom cursor like other platforms (yet?) and actually creates it in set_custom_cursor() instead, so it currently panics there.
  • Web will continue to do nothing, because errors are delivered asynchronously. However it already had create_custom_cursor_async() to properly return an error.

Related #3306.
Follow-up to #3749.

@daxpedda daxpedda added S - enhancement Wouldn't this be the coolest? S - api Design and usability labels Aug 2, 2024
@daxpedda daxpedda changed the title Make (Active)EventLoop::create_custom_error() return a Result<CustomCursor, ExternalError> Make (Active)EventLoop::create_custom_cursor() return a Result<CustomCursor, ExternalError> Aug 6, 2024
Copy link
Member

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

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

Approved for Android.

&self,
_source: CustomCursorSource,
) -> Result<CustomCursor, ExternalError> {
Err(ExternalError::NotSupported(NotSupportedError::new()))
Copy link
Member

Choose a reason for hiding this comment

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

In the future, if we do more JNI wrapping, we can provide custom Bitmaps in the future using https://developer.android.com/reference/android/view/PointerIcon. Only when the user attaches a mouse to their Android device :)

Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

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

Should be fine, though, I'd probably change the type of error we return in the future.

@daxpedda daxpedda merged commit f530481 into rust-windowing:master Aug 6, 2024
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - api Design and usability S - enhancement Wouldn't this be the coolest?
Development

Successfully merging this pull request may close these issues.

3 participants