From c1c47d308d5267c3d085d356c287cba8a86be760 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 3 May 2026 16:27:51 +0000 Subject: [PATCH] revert 96f8d519e6 (#76) Reviewed-on: https://git.ryujinx.app/projects/Ryubing/pulls/76 --- src/Ryujinx.Common/Helpers/ConsoleHelper.cs | 13 +++++++++ src/Ryujinx/Program.cs | 30 +++++---------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/Ryujinx.Common/Helpers/ConsoleHelper.cs b/src/Ryujinx.Common/Helpers/ConsoleHelper.cs index 776ff13d7..2b3c11b1e 100644 --- a/src/Ryujinx.Common/Helpers/ConsoleHelper.cs +++ b/src/Ryujinx.Common/Helpers/ConsoleHelper.cs @@ -16,6 +16,15 @@ namespace Ryujinx.Common.Helper [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) @@ -44,6 +53,10 @@ namespace Ryujinx.Common.Helper return; } + SetForegroundWindow(hWnd); + + hWnd = GetForegroundWindow(); + ShowWindow(hWnd, show ? SW_SHOW : SW_HIDE); } } diff --git a/src/Ryujinx/Program.cs b/src/Ryujinx/Program.cs index ce2a0eb11..cb219b216 100644 --- a/src/Ryujinx/Program.cs +++ b/src/Ryujinx/Program.cs @@ -24,11 +24,9 @@ using Ryujinx.Headless; using Ryujinx.SDL3.Common; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Security.Principal; -using System.Text; using System.Threading.Tasks; namespace Ryujinx.Ava @@ -54,22 +52,6 @@ namespace Ryujinx.Ava if (OperatingSystem.IsWindows()) { -#if !DEBUG - // this fixes the "hide console" option by forcing the emulator to launch in an old-school cmd - if (!Console.Title.Contains("conhost.exe")) - { - StringBuilder sb = new(); - - foreach (string arg in args) - { - sb.Append(arg.Contains(' ') ? $" \"{arg}\"" : $" {arg}"); - } - - Process.Start("conhost.exe", $"{Environment.ProcessPath} {sb}"); - return 0; - } -#endif - if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041)) { _ = Win32NativeInterop.MessageBoxA(nint.Zero, "You are running an outdated version of Windows.\n\nRyujinx supports Windows 10 version 20H1 and newer.\n", $"Ryujinx {Version}", MbIconwarning); @@ -103,7 +85,7 @@ namespace Ryujinx.Ava CoreDumpArg = coreDumpArg; // TODO: Ryujinx causes core dumps on Linux when it exits "uncleanly", eg. through an unhandled exception. - // This is undesirable and causes very odd behavior during development (the process stops responding, + // This is undesirable and causes very odd behavior during development (the process stops responding, // the .NET debugger freezes or suddenly detaches, /tmp/ gets filled etc.), unless explicitly requested by the user. // This needs to be investigated, but calling prctl() is better than modifying system-wide settings or leaving this be. if (!coreDumpArg) @@ -260,7 +242,7 @@ namespace Ryujinx.Ava ConfigurationPath = appDataConfigurationPath; } } - + if (ConfigurationPath == null) { // No configuration, we load the default values and save it to disk @@ -331,28 +313,28 @@ namespace Ryujinx.Ava _ => ConfigurationState.Instance.HideCursor, }; - // Check if memoryManagerMode was overridden. + // Check if memoryManagerMode was overridden. if (CommandLineState.OverrideMemoryManagerMode is not null) if (Enum.TryParse(CommandLineState.OverrideMemoryManagerMode, true, out MemoryManagerMode result)) { ConfigurationState.Instance.System.MemoryManagerMode.Value = result; } - // Check if PPTC was overridden. + // Check if PPTC was overridden. if (CommandLineState.OverridePPTC is not null) if (Enum.TryParse(CommandLineState.OverridePPTC, true, out bool result)) { ConfigurationState.Instance.System.EnablePtc.Value = result; } - // Check if region was overridden. + // Check if region was overridden. if (CommandLineState.OverrideSystemRegion is not null) if (Enum.TryParse(CommandLineState.OverrideSystemRegion, true, out Region result)) { ConfigurationState.Instance.System.Region.Value = result; } - //Check if language was overridden. + //Check if language was overridden. if (CommandLineState.OverrideSystemLanguage is not null) if (Enum.TryParse(CommandLineState.OverrideSystemLanguage, true, out Language result)) {