Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface INeedsMousePositionFeedback
/// Receives the final mouse position from an <see cref="InputManager"/>.
/// </summary>
/// <param name="position">The final mouse position.</param>
/// <param name="isSelfFeedback">Whether the feedback was triggered from this handler.</param>
void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback);
/// <param name="handler">A handler that reported the final mouse position.</param>
void FeedbackMousePositionChange(Vector2 position, InputHandler handler);
}
}
9 changes: 7 additions & 2 deletions osu.Framework/Input/Handlers/Mouse/MouseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Input/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions osu.Framework/Platform/Windows/WindowsMouseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
}
Loading