-
Notifications
You must be signed in to change notification settings - Fork 428
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
Fix mouse handler moving OS pen cursor #6534
base: master
Are you sure you want to change the base?
Conversation
This pr works for me. |
This seems like a bug in SDL or your desktop environment. We are calling Please enable |
public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback) | ||
public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor) | ||
{ | ||
if (!Enabled.Value) | ||
return; | ||
|
||
if (!isSelfFeedback && isActive.Value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a bug in SDL3 on X11, I would make an ugly hack to to make this work on linux. Instead of adding in a nice isOsCursor
, making this seem as expected behaviour, I would instead make FeedbackMousePositionChange(Vector2 position, InputHandler handler)
.
And them simply:
if (handler != this && isActive.Value && !(handler is PenHandler && RuntimeInfo.OS == Platform.Linux && FrameworkEnvironment.UseSDL3))
Or maybe create a LinuxSDL3MouseHandler
and override the warping decision making there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bug in X11/SDL, but I think this is also a logical issue on o!f side, too. Why should we move the 'mouse' cursor to the 'pen' position when they are essentially sharing the same cursor?
I'm fine with the diff to fix the issue on X11, but I just want to clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are not the same cursor when using Windows Ink or built-in OpenTabletDriver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Built-in OTD is not affected by this PR since it is not handled by PenHandler
. I just tested Windows Ink, and Windows (or driver?) seems to save position of tablet and mouse separately, so the cursor is moved to the most recent mouse position once mouse take the cursor back after the pen goes out of a range. I'm not sure if moving a mouse cursor for pen is a desired behavior when Windows Ink is in use since a pen cursor is also an OS cursor, but I'll make it exclusive to Linux for now.
6aa2a45
to
5e9cd1b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise.
{ | ||
if (!Enabled.Value) | ||
return; | ||
|
||
if (!isSelfFeedback && isActive.Value) | ||
// https://github.com/ppy/osu/issues/31948 | ||
// Pen malfunctions if MouseHandler tries to move the mouse cursor to pen position on Linux/X11. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original issue mentions this happening on Wayland. Maybe putting X11 here is a bit misleading, unless your testing has proven otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was only reproducible on X11 for me, but I'll just remove X11 for less confusion.
I've had this issue for a while, and just found out that the new
PenHandler
was the culprit.Whenever
PenHandler
moves the cursor,MouseHandler
tries to forcefully move the cursor to the reported position because it is not self-feedback, but SDL3PenHandler
also represents OS cursor.I think the process here is like: Pen reports a position -> PenHandler becomes mouseSource -> MouseHandler moves the OS cursor -> Pen moves -> OS cursor gets repositioned -> Pen somehow reports the forcefully moved position? -> Cursor is now stuck
I don't have a tablet driver installed on my Windows installation, so it's only tested on Linux. This is somehow only reproducible on X11 for me. The issue author was probably using Xwayland. Honestly, I don't know how moving a cursor (
SDL_WarpMouseInWindow
) is affecting an absolute positioning device, but I don't really want to dig deeper.I'm not sure if
isSelfFeedback
is needed anymore, but I just focused on fixing the issue. Please tell me if there's a better way to fix it!