From 3ec0eda32420e1d1f6b75cdd1c01b8910fd4901e Mon Sep 17 00:00:00 2001 From: bangfire Date: Tue, 3 Dec 2024 13:09:51 +0000 Subject: [PATCH 1/3] Fix Windows Terminal hide/show functions. --- src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs b/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs index 623952b37..0ea5bbdb8 100644 --- a/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs @@ -1,12 +1,32 @@ using Ryujinx.Common.Logging; using System; using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; using System.Runtime.Versioning; namespace Ryujinx.UI.Common.Helper { public static partial class ConsoleHelper { + [SupportedOSPlatform("windows")] + [LibraryImport("kernel32")] + private static partial nint GetConsoleWindow(); + + [SupportedOSPlatform("windows")] + [LibraryImport("user32")] + [return: MarshalAs(UnmanagedType.Bool)] + private static partial bool ShowWindow(nint hWnd, int nCmdShow); + + [SupportedOSPlatform("windows")] + [LibraryImport("user32")] + private static partial nint GetForegroundWindow(); + + [SupportedOSPlatform("windows")] + [LibraryImport("user32")] + [return: MarshalAs(UnmanagedType.Bool)] + private static partial bool SetForegroundWindow(nint hWnd); + + public static bool SetConsoleWindowStateSupported => OperatingSystem.IsWindows(); public static void SetConsoleWindowState(bool show) @@ -35,16 +55,11 @@ namespace Ryujinx.UI.Common.Helper return; } + SetForegroundWindow(hWnd); + + hWnd = GetForegroundWindow(); + ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE); } - - [SupportedOSPlatform("windows")] - [LibraryImport("kernel32")] - private static partial nint GetConsoleWindow(); - - [SupportedOSPlatform("windows")] - [LibraryImport("user32")] - [return: MarshalAs(UnmanagedType.Bool)] - private static partial bool ShowWindow(nint hWnd, int nCmdShow); } } From d761b1f36fc46ab176e0f4445704c350af53c74b Mon Sep 17 00:00:00 2001 From: bangfire Date: Tue, 3 Dec 2024 13:12:14 +0000 Subject: [PATCH 2/3] Unused using --- src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs b/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs index 0ea5bbdb8..502b9a08e 100644 --- a/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs @@ -1,7 +1,6 @@ using Ryujinx.Common.Logging; using System; using System.Runtime.InteropServices; -using System.Runtime.InteropServices.Marshalling; using System.Runtime.Versioning; namespace Ryujinx.UI.Common.Helper From 9cd4fb8dea194ebbac599c59b1d18ee1687f9962 Mon Sep 17 00:00:00 2001 From: bangfire Date: Tue, 3 Dec 2024 13:18:05 +0000 Subject: [PATCH 3/3] Spacing. --- src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs b/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs index 502b9a08e..99b209c6e 100644 --- a/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/ConsoleHelper.cs @@ -25,7 +25,6 @@ namespace Ryujinx.UI.Common.Helper [return: MarshalAs(UnmanagedType.Bool)] private static partial bool SetForegroundWindow(nint hWnd); - public static bool SetConsoleWindowStateSupported => OperatingSystem.IsWindows(); public static void SetConsoleWindowState(bool show)