Skip to content

Commit f2e1c45

Browse files
committed
Refactor the wayland hack to IWindow.PositionAccurate
1 parent ac8a2ad commit f2e1c45

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

osu.Framework/Input/UserInputManager.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using osu.Framework.Input.StateChanges;
1111
using osu.Framework.Input.StateChanges.Events;
1212
using osu.Framework.Platform;
13-
using osu.Framework.Platform.SDL3;
1413
using osuTK;
1514
using osuTK.Input;
1615
using RectangleF = osu.Framework.Graphics.Primitives.RectangleF;
@@ -91,10 +90,7 @@ private bool mouseOutsideAllDisplays(Vector2 mousePosition)
9190
switch (Host.Window.WindowMode.Value)
9291
{
9392
case WindowMode.Windowed:
94-
// The window location on wayland is always reported as the top-left corner of the current display,
95-
// which would erroniously prevent the mouse from exiting over the top and left edge.
96-
// In windowed, always consider the mouse as inside the displays to fix this.
97-
if (Host.Window is SDL3Window sdlWindow && sdlWindow.IsWayland)
93+
if (!Host.Window.PositionAccurate)
9894
return false;
9995

10096
windowLocation = Host.Window.Position;

osu.Framework/Platform/IWindow.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ public interface IWindow : IDisposable
272272
/// </summary>
273273
Point Position { get; }
274274

275+
/// <summary>
276+
/// Whether the current <see cref="Position"/> is accurate.
277+
/// </summary>
278+
bool PositionAccurate { get; }
279+
275280
/// <summary>
276281
/// The size of the window in scaled pixels (excluding any window decoration/border).
277282
/// </summary>

osu.Framework/Platform/SDL2/SDL2Window_Windowing.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public Point Position
165165
}
166166
}
167167

168+
public bool PositionAccurate => true;
169+
168170
private bool resizable = true;
169171

170172
/// <summary>

osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ public unsafe Point Position
169169
}
170170
}
171171

172+
// On Wayland, the window position is always reported as the top-left corner of the current display,
173+
// making it inaccurate in windowed mode.
174+
public bool PositionAccurate => !(IsWayland && WindowMode.Value == Configuration.WindowMode.Windowed);
175+
172176
private bool resizable = true;
173177

174178
/// <summary>

0 commit comments

Comments
 (0)