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

Replace libxcursor with custom cursor code #3749

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Conversation

notgull
Copy link
Member

@notgull notgull commented Jun 22, 2024

Another one bites the dust.

This replaces the code dependent on libxcursor with equivalent code
written using x11rb, featuring its special "cursor" module.

cc #3198

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

@notgull notgull requested a review from kchibisov as a code owner June 22, 2024 19:30
@notgull notgull force-pushed the notgull/no-xcursor branch 3 times, most recently from b591543 to f19993a Compare June 22, 2024 19:32
@notgull notgull added DS - x11 S - maintenance Repaying technical debt labels Jun 22, 2024
src/platform_impl/linux/x11/util/cursor.rs Show resolved Hide resolved
src/platform_impl/linux/x11/util/cursor.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/x11/util/cursor.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/x11/util/cursor.rs Outdated Show resolved Hide resolved
@notgull notgull force-pushed the notgull/no-xcursor branch 2 times, most recently from 92b431b to 17c60e7 Compare June 24, 2024 00:45
@notgull notgull added the C - nominated Nominated for discussion in the next meeting label Jun 27, 2024
@madsmtm madsmtm removed the C - nominated Nominated for discussion in the next meeting label Jun 28, 2024
@madsmtm
Copy link
Member

madsmtm commented Jun 28, 2024

Meeting resolution: @kchibisov will take a look once he has time

@notgull
Copy link
Member Author

notgull commented Jul 28, 2024

@kchibisov Have you had a chance to look over this one yet?

Copy link
Member

@daxpedda daxpedda left a comment

Choose a reason for hiding this comment

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

LGTM! Works flawlessly.

I'm fine with panicking if we can reasonably assume that this shouldn't happen.
But if it can happen, I believe we have two choices: print the error with tracing and move on (which other backends do as well right now), or return the error to the user, which would necessitate an API change.

I would be in favor of an API change in a follow-up, other backends could make use of that as well. So my suggestion would be to not panic and print the error in tracing in this PR, unless of course in your opinion this should never happen.

src/platform_impl/linux/x11/util/cursor.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/x11/util/cursor.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/x11/util/cursor.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/x11/xdisplay.rs Show resolved Hide resolved
@notgull
Copy link
Member Author

notgull commented Aug 2, 2024

X11 sits on top of the I/O stack and every I/O function is fallible. So every winit function would also need to return a Result. Not that I oppose this; I think this is the ideal way to go.

@daxpedda
Copy link
Member

daxpedda commented Aug 2, 2024

X11 sits on top of the I/O stack and every I/O function is fallible. So every winit function would also need to return a Result. Not that I oppose this; I think this is the ideal way to go.

I made #3844 to address at least this PR.
So for this PR I propose:

  • Return an error in create_custom_cursor().
  • If an error happens in set_cursor(), use tracing to deliver the error and do nothing instead of panicking. Lets address this in the future more globally.

WDYT?

@kchibisov
Copy link
Member

Yeah, in general, if you can not set something you just do nothing. There's no guarantee that all the functions will work, because window manager can just ignore the request and you generally don't know that until you try to query it.

So just ignore the errors for setting cursor(that's how it's done on Wayland as well here).

@notgull
Copy link
Member Author

notgull commented Aug 10, 2024

  • Return an error in create_custom_cursor().

  • If an error happens in set_cursor(), use tracing to deliver the error and do nothing instead of panicking. Lets address this in the future more globally.

I've set this up now.

@daxpedda daxpedda added the C - nominated Nominated for discussion in the next meeting label Aug 15, 2024
Another one bites the dust.

This replaces the code dependent on libxcursor with equivalent code
written using x11rb, featuring its special "cursor" module.

cc #3198

Signed-off-by: John Nunley <dev@notgull.net>
@notgull notgull merged commit aee9511 into master Aug 23, 2024
58 checks passed
@notgull notgull deleted the notgull/no-xcursor branch August 23, 2024 02:30
@daxpedda daxpedda removed the C - nominated Nominated for discussion in the next meeting label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DS - x11 S - maintenance Repaying technical debt
Development

Successfully merging this pull request may close these issues.