diff --git a/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs b/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs index d98eaf1bea..1111210fdb 100644 --- a/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs +++ b/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs @@ -14,7 +14,7 @@ public interface INeedsMousePositionFeedback /// Receives the final mouse position from an . /// /// The final mouse position. - /// Whether the feedback was triggered from this handler. - void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback); + /// A handler that reported the final mouse position. + void FeedbackMousePositionChange(Vector2 position, InputHandler handler); } } diff --git a/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs b/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs index aa480152c3..8c815f2c1e 100644 --- a/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs +++ b/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using osu.Framework.Bindables; using osu.Framework.Extensions.EnumExtensions; +using osu.Framework.Input.Handlers.Pen; using osu.Framework.Input.StateChanges; using osu.Framework.Platform; using osu.Framework.Statistics; @@ -137,12 +138,16 @@ public override bool Initialize(GameHost host) return true; } - public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback) + public virtual void FeedbackMousePositionChange(Vector2 position, InputHandler handler) { 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. + bool disableUpdatingMousePosition = handler is PenHandler && RuntimeInfo.OS == RuntimeInfo.Platform.Linux && FrameworkEnvironment.UseSDL3; + + if (handler != this && isActive.Value && !disableUpdatingMousePosition) // if another handler has updated the cursor position, handle updating the OS cursor so we can seamlessly revert // to mouse control at any point. window.UpdateMousePosition(position); diff --git a/osu.Framework/Input/InputManager.cs b/osu.Framework/Input/InputManager.cs index 87efb4345b..8e039c4c9e 100644 --- a/osu.Framework/Input/InputManager.cs +++ b/osu.Framework/Input/InputManager.cs @@ -964,7 +964,7 @@ protected virtual void HandleMousePositionChange(MousePositionChangeEvent e) foreach (var h in InputHandlers) { if (h.Enabled.Value && h is INeedsMousePositionFeedback handler) - handler.FeedbackMousePositionChange(mouse.Position, h == mouseSource); + handler.FeedbackMousePositionChange(mouse.Position, mouseSource); } handleMouseMove(state, e.LastPosition); diff --git a/osu.Framework/Platform/Windows/WindowsMouseHandler.cs b/osu.Framework/Platform/Windows/WindowsMouseHandler.cs index 4abe150a6e..4e3d86714e 100644 --- a/osu.Framework/Platform/Windows/WindowsMouseHandler.cs +++ b/osu.Framework/Platform/Windows/WindowsMouseHandler.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Runtime.Versioning; +using osu.Framework.Input.Handlers; using osu.Framework.Input.Handlers.Mouse; using osuTK; @@ -31,10 +32,10 @@ public override bool Initialize(GameHost host) return base.Initialize(host); } - public override void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback) + public override void FeedbackMousePositionChange(Vector2 position, InputHandler handler) { window.LastMousePosition = position; - base.FeedbackMousePositionChange(position, isSelfFeedback); + base.FeedbackMousePositionChange(position, handler); } } }