1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 10:23:03 +08:00

Merge pull request #23720 from peppy/fix-mouse-disappear-screenshot-fail

Fix mouse cursor potentially disappearing for good if screenshot capture fails
This commit is contained in:
Bartłomiej Dach 2023-06-01 23:09:23 +02:00 committed by GitHub
commit f8289927d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Configuration;
using osu.Game.Input.Bindings;
using osu.Game.Online.Multiplayer;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
using SixLabors.ImageSharp;
@ -69,7 +70,7 @@ namespace osu.Game.Graphics
{
case GlobalAction.TakeScreenshot:
shutter.Play();
TakeScreenshotAsync();
TakeScreenshotAsync().FireAndForget();
return true;
}
@ -86,6 +87,8 @@ namespace osu.Game.Graphics
{
Interlocked.Increment(ref screenShotTasks);
try
{
if (!captureMenuCursor.Value)
{
cursorVisibility.Value = false;
@ -113,9 +116,6 @@ namespace osu.Game.Graphics
using (var image = await host.TakeScreenshotAsync().ConfigureAwait(false))
{
if (Interlocked.Decrement(ref screenShotTasks) == 0 && cursorVisibility.Value == false)
cursorVisibility.Value = true;
host.GetClipboard()?.SetImage(image);
(string filename, var stream) = getWritableStream();
@ -151,6 +151,12 @@ namespace osu.Game.Graphics
}
});
}
}
finally
{
if (Interlocked.Decrement(ref screenShotTasks) == 0)
cursorVisibility.Value = true;
}
});
private static readonly object filename_reservation_lock = new object();