Skip to content

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

Merged
daxpedda merged 1 commit into
rust-windowing:masterfrom
daxpedda:custom-cursor-error-2
Aug 6, 2024
Merged

daxpedda merged 1 commit into
rust-windowing:masterfrom
daxpedda:custom-cursor-error-2

Conversation

@daxpedda

@daxpedda daxpedda commented Aug 2, 2024 •

Copy link
Copy Markdown
Member

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 mentioned this pull request Aug 2, 2024
5 tasks done
@daxpedda
daxpedda force-pushed the custom-cursor-error-2 branch from 2f20dac to 08a3734 Compare August 2, 2024 09:46
Comment thread src/changelog/unreleased.md Resolved
@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
@daxpedda
daxpedda force-pushed the custom-cursor-error-2 branch from 08a3734 to e0f2d1a Compare August 6, 2024 11:47

@MarijnS95 MarijnS95 left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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 :)

@kchibisov kchibisov left a comment

Copy link
Copy Markdown
Member

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 force-pushed the custom-cursor-error-2 branch from e0f2d1a to 1bfa5ae Compare August 6, 2024 13:54
@daxpedda
daxpedda merged commit f530481 into rust-windowing:master Aug 6, 2024
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