From ac55fea3c953a6c81326308200d4b905cd921c3b Mon Sep 17 00:00:00 2001
From: Susko3 <16479013+Susko3@users.noreply.github.com>
Date: Fri, 11 Mar 2022 14:04:12 +0100
Subject: [PATCH 1/2] Confine the host cursor to area of 'everything' scaling
container
---
.../Graphics/Containers/ScalingContainer.cs | 45 +++++++++++++++++--
1 file changed, 42 insertions(+), 3 deletions(-)
diff --git a/osu.Game/Graphics/Containers/ScalingContainer.cs b/osu.Game/Graphics/Containers/ScalingContainer.cs
index d331b818a1..58d18e1b21 100644
--- a/osu.Game/Graphics/Containers/ScalingContainer.cs
+++ b/osu.Game/Graphics/Containers/ScalingContainer.cs
@@ -6,6 +6,8 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
+using osu.Framework.Layout;
+using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Screens;
@@ -66,7 +68,7 @@ namespace osu.Game.Graphics.Containers
this.targetMode = targetMode;
RelativeSizeAxes = Axes.Both;
- InternalChild = sizableContainer = new AlwaysInputContainer
+ InternalChild = sizableContainer = new SizeableAlwaysInputContainer(targetMode == ScalingMode.Everything)
{
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
@@ -209,13 +211,50 @@ namespace osu.Game.Graphics.Containers
}
}
- private class AlwaysInputContainer : Container
+ private class SizeableAlwaysInputContainer : Container
{
+ [Resolved]
+ private GameHost host { get; set; }
+
+ [Resolved]
+ private ISafeArea safeArea { get; set; }
+
+ private readonly bool confineHostCursor;
+ private readonly LayoutValue cursorRectCache = new LayoutValue(Invalidation.RequiredParentSizeToFit);
+
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
- public AlwaysInputContainer()
+ ///
+ /// Container used for sizing/positioning purposes in . Always receives mouse input.
+ ///
+ /// Whether to confine the host cursor to the draw area of this container.
+ /// Cursor confinement will abide by the setting.
+ public SizeableAlwaysInputContainer(bool confineHostCursor)
{
RelativeSizeAxes = Axes.Both;
+ this.confineHostCursor = confineHostCursor;
+
+ if (confineHostCursor)
+ AddLayout(cursorRectCache);
+ }
+
+ protected override void Update()
+ {
+ base.Update();
+
+ if (confineHostCursor && !cursorRectCache.IsValid)
+ {
+ updateHostCursorConfineRect();
+ cursorRectCache.Validate();
+ }
+ }
+
+ private void updateHostCursorConfineRect()
+ {
+ if (host.Window == null) return;
+
+ bool coversWholeScreen = Size == Vector2.One && safeArea.SafeAreaPadding.Value.Total == Vector2.Zero;
+ host.Window.CursorConfineRect = coversWholeScreen ? (RectangleF?)null : ToScreenSpace(DrawRectangle).AABBFloat;
}
}
}
From 8fdf2b13ac2d83b206d88940e7582ae80c91a645 Mon Sep 17 00:00:00 2001
From: Dean Herbert
Date: Mon, 14 Mar 2022 22:23:50 +0900
Subject: [PATCH 2/2] Update framework
---
osu.Android.props | 2 +-
osu.Game/osu.Game.csproj | 2 +-
osu.iOS.props | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/osu.Android.props b/osu.Android.props
index 839f7882bf..1b5461959a 100644
--- a/osu.Android.props
+++ b/osu.Android.props
@@ -52,7 +52,7 @@
-
+
diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj
index c106c373c4..5e194e2aca 100644
--- a/osu.Game/osu.Game.csproj
+++ b/osu.Game/osu.Game.csproj
@@ -36,7 +36,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/osu.iOS.props b/osu.iOS.props
index 86cf1b229c..23101c5af6 100644
--- a/osu.iOS.props
+++ b/osu.iOS.props
@@ -61,7 +61,7 @@
-
+
@@ -84,7 +84,7 @@
-
+