Merge pull request #9253 from swoolcock/sdl2-hide-cursor

Fix cursor not hiding with SDL2 backend
This commit is contained in:
Dan Balasescu 2020-06-12 13:18:25 +09:00 committed by GitHub
commit ef81873ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,6 @@ using Microsoft.Win32;
using osu.Desktop.Overlays;
using osu.Framework.Platform;
using osu.Game;
using osuTK.Input;
using osu.Desktop.Updater;
using osu.Framework;
using osu.Framework.Logging;
@ -122,21 +121,27 @@ namespace osu.Desktop
{
base.SetHost(host);
if (host.Window is DesktopGameWindow desktopWindow)
switch (host.Window)
{
desktopWindow.CursorState |= CursorState.Hidden;
// Legacy osuTK DesktopGameWindow
case DesktopGameWindow desktopGameWindow:
desktopGameWindow.CursorState |= CursorState.Hidden;
desktopGameWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
desktopGameWindow.Title = Name;
desktopGameWindow.FileDrop += (_, e) => fileDrop(e.FileNames);
break;
desktopWindow.SetIconFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico"));
desktopWindow.Title = Name;
desktopWindow.FileDrop += fileDrop;
// SDL2 DesktopWindow
case DesktopWindow desktopWindow:
desktopWindow.CursorState.Value |= CursorState.Hidden;
desktopWindow.Title = Name;
desktopWindow.DragDrop += f => fileDrop(new[] { f });
break;
}
}
private void fileDrop(object sender, FileDropEventArgs e)
private void fileDrop(string[] filePaths)
{
var filePaths = e.FileNames;
var firstExtension = Path.GetExtension(filePaths.First());
if (filePaths.Any(f => Path.GetExtension(f) != firstExtension)) return;