Skip to content

Commit 6aa2a45

Browse files
committed
Disable moving mouse cursor to pen position only on Linux SDL3
1 parent 14dcd00 commit 6aa2a45

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public interface INeedsMousePositionFeedback
1414
/// Receives the final mouse position from an <see cref="InputManager"/>.
1515
/// </summary>
1616
/// <param name="position">The final mouse position.</param>
17-
/// <param name="isSelfFeedback">Whether the feedback was triggered from this handler.</param>
18-
/// <param name="isOsCursor">Whether the position represents OS cursor.</param>
19-
void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor);
17+
/// <param name="handler">A handler that reported the final mouse position.</param>
18+
void FeedbackMousePositionChange(Vector2 position, InputHandler handler);
2019
}
2120
}

osu.Framework/Input/Handlers/InputHandler.cs

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public abstract class InputHandler : IDisposable, IHasDescription
3232

3333
private bool isInitialized;
3434

35-
public virtual bool IsOsCursor => false;
36-
3735
/// <summary>
3836
/// Used to initialize resources specific to this InputHandler. It gets called once.
3937
/// </summary>

osu.Framework/Input/Handlers/Mouse/MouseHandler.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
using System.Diagnostics;
77
using osu.Framework.Bindables;
8+
using osu.Framework.Configuration;
89
using osu.Framework.Extensions.EnumExtensions;
10+
using osu.Framework.Input.Handlers.Pen;
911
using osu.Framework.Input.StateChanges;
1012
using osu.Framework.Platform;
1113
using osu.Framework.Statistics;
@@ -37,8 +39,6 @@ public class MouseHandler : InputHandler, IHasCursorSensitivity, INeedsMousePosi
3739
Precision = 0.01
3840
};
3941

40-
public override bool IsOsCursor => true;
41-
4242
public override string Description => "Mouse";
4343

4444
public override bool IsActive => true;
@@ -139,12 +139,16 @@ public override bool Initialize(GameHost host)
139139
return true;
140140
}
141141

142-
public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor)
142+
public virtual void FeedbackMousePositionChange(Vector2 position, InputHandler handler)
143143
{
144144
if (!Enabled.Value)
145145
return;
146146

147-
if (!isSelfFeedback && !isOsCursor && isActive.Value)
147+
// https://github.com/ppy/osu/issues/31948
148+
// Pen malfunctions if MouseHandler tries to move the mouse cursor to pen position on Linux/X11.
149+
bool disableUpdatingMousePosition = handler is PenHandler && RuntimeInfo.OS == RuntimeInfo.Platform.Linux && FrameworkEnvironment.UseSDL3;
150+
151+
if (handler != this && isActive.Value && !disableUpdatingMousePosition)
148152
// if another handler has updated the cursor position, handle updating the OS cursor so we can seamlessly revert
149153
// to mouse control at any point.
150154
window.UpdateMousePosition(position);

osu.Framework/Input/Handlers/Pen/PenHandler.cs

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ public class PenHandler : InputHandler
1616
{
1717
private static readonly GlobalStatistic<ulong> statistic_total_events = GlobalStatistics.Get<ulong>(StatisticGroupFor<PenHandler>(), "Total events");
1818

19-
public override bool IsOsCursor => true;
20-
2119
public override bool IsActive => true;
2220

2321
public override bool Initialize(GameHost host)

osu.Framework/Input/InputManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ protected virtual void HandleMousePositionChange(MousePositionChangeEvent e)
964964
foreach (var h in InputHandlers)
965965
{
966966
if (h.Enabled.Value && h is INeedsMousePositionFeedback handler)
967-
handler.FeedbackMousePositionChange(mouse.Position, h == mouseSource, mouseSource.IsOsCursor);
967+
handler.FeedbackMousePositionChange(mouse.Position, mouseSource);
968968
}
969969

970970
handleMouseMove(state, e.LastPosition);

osu.Framework/Platform/Windows/WindowsMouseHandler.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See the LICENCE file in the repository root for full licence text.
33

44
using System.Runtime.Versioning;
5+
using osu.Framework.Input.Handlers;
56
using osu.Framework.Input.Handlers.Mouse;
67
using osuTK;
78

@@ -31,10 +32,10 @@ public override bool Initialize(GameHost host)
3132
return base.Initialize(host);
3233
}
3334

34-
public override void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor)
35+
public override void FeedbackMousePositionChange(Vector2 position, InputHandler handler)
3536
{
3637
window.LastMousePosition = position;
37-
base.FeedbackMousePositionChange(position, isSelfFeedback, isOsCursor);
38+
base.FeedbackMousePositionChange(position, handler);
3839
}
3940
}
4041
}

0 commit comments

Comments
 (0)