Skip to content

Commit 5e9cd1b

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

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-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

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Diagnostics;
77
using osu.Framework.Bindables;
88
using osu.Framework.Extensions.EnumExtensions;
9+
using osu.Framework.Input.Handlers.Pen;
910
using osu.Framework.Input.StateChanges;
1011
using osu.Framework.Platform;
1112
using osu.Framework.Statistics;
@@ -37,8 +38,6 @@ public class MouseHandler : InputHandler, IHasCursorSensitivity, INeedsMousePosi
3738
Precision = 0.01
3839
};
3940

40-
public override bool IsOsCursor => true;
41-
4241
public override string Description => "Mouse";
4342

4443
public override bool IsActive => true;
@@ -139,12 +138,16 @@ public override bool Initialize(GameHost host)
139138
return true;
140139
}
141140

142-
public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor)
141+
public virtual void FeedbackMousePositionChange(Vector2 position, InputHandler handler)
143142
{
144143
if (!Enabled.Value)
145144
return;
146145

147-
if (!isSelfFeedback && !isOsCursor && isActive.Value)
146+
// https://github.com/ppy/osu/issues/31948
147+
// Pen malfunctions if MouseHandler tries to move the mouse cursor to pen position on Linux/X11.
148+
bool disableUpdatingMousePosition = handler is PenHandler && RuntimeInfo.OS == RuntimeInfo.Platform.Linux && FrameworkEnvironment.UseSDL3;
149+
150+
if (handler != this && isActive.Value && !disableUpdatingMousePosition)
148151
// if another handler has updated the cursor position, handle updating the OS cursor so we can seamlessly revert
149152
// to mouse control at any point.
150153
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)