Linux: Work around Wayland mouse warp problem#3591
Open
ObserverHerb wants to merge 1 commit intoSFML:masterfrom
Open
Linux: Work around Wayland mouse warp problem#3591ObserverHerb wants to merge 1 commit intoSFML:masterfrom
ObserverHerb wants to merge 1 commit intoSFML:masterfrom
Conversation
4e0f0b7 to
5f05e1c
Compare
5f05e1c to
177c3d9
Compare
XWayland does allow warping the mouse if it's hidden, so hide the cursor before calling setMousePosition then unhide it.
177c3d9 to
c2d1854
Compare
Member
|
@ObserverHerb would you please test this out for me one more time after the latest changes I pushed? I expect the behavior will be unchanged but I want to be sure. |
Author
|
Tested on Plasma 6, Gnome, Hyprland, and Budgie. When starting with the cursor hidden, it will stay hidden on all four. When starting with the cursor visible, it will flicker while moving the mouse and become hidden when the mouse stops on Plasma, Gnome, and Hyprland. Budgie is the only one that leaves the cursor visible. I'm not sure why it's wrong on the other three. I was able to confirm this is the case with my code before your change, so I don't think you changed the behavior. I'll look into why the cursor is not being restored properly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Blender and SDL teams found a way to get warping the mouse cursor to work under XWayland. This is my attempt at implementing their technique in SFML.
The cursor can be warped under XWayland if it is hidden first. This change detects if the cursor is visible, and if it is, hides it, restoring it after the warp.
The
relativeToreference to theWindowBaseisconstwhen it's passed in tosf::Mouse::setPosition(), so I'm usingconst_casthere to get it working. I know this isn't ideal. I'm sure there's a better way, but I wanted to get the ball rolling on this.This PR is related to the issue #2750
Tasks
How to test this PR?