mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-22 05:05:56 +00:00
A game started from a frontend (Playnite, RetroBat, ES-DE) or a shortcut got a console beside it, and its window opened behind other windows, out of reach without a mouse. Once the log file is open, the console is freed when no other process shares it; a terminal launch keeps its output, and show_console = 1 keeps the console. The window is raised at start, with AttachThreadInput when Windows refuses the foreground. rt_fatal writes only to the log, and a console owned by the game closed with it anyway, so no error text is lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3422952e85
commit
d2fbe0a2b1
7 files changed
+52
-7
No files matched your search
@@ -1262,6 +1262,8 @@ int plat_os_version(char *out, size_t cap) {
|
||||
|
||||
int plat_is_wine(void) { return 0; }
|
||||
|
||||
int plat_console_release_if_owned(void) { return 0; }
|
||||
|
||||
int plat_stderr_path(char *out, size_t cap) {
|
||||
struct stat st;
|
||||
if (fstat(2, &st) || !S_ISREG(st.st_mode)) return 0;
|
||||
|
||||
@@ -378,6 +378,11 @@ int plat_is_wine(void); // 1 when the Windows
|
||||
// The file the process's stderr (the log) goes to, as a UTF-8 path; 0 when stderr is not a file (a console, a pipe).
|
||||
int plat_stderr_path(char *out, size_t cap);
|
||||
|
||||
// Detaches the process from its console when no other process shares it (a frontend or a shortcut started us and
|
||||
// Windows made the console for us); a terminal the user started us from keeps its output. Returns 1 when detached.
|
||||
// Linux: 0.
|
||||
int plat_console_release_if_owned(void);
|
||||
|
||||
// ---- desktop: the in-game menu's "Copy system info" and "Open log folder"
|
||||
int plat_clipboard_set(const char *utf8); // replaces the clipboard's text; 1 on success
|
||||
int plat_open_folder(const char *path); // shows the folder in the file manager; 1 on success
|
||||
|
||||
@@ -1303,6 +1303,17 @@ int plat_stderr_path(char *out, size_t cap) {
|
||||
return WideCharToMultiByte(CP_UTF8, 0, p, -1, out, (int)cap, NULL, NULL) != 0;
|
||||
}
|
||||
|
||||
// GetConsoleProcessList counts this process alone only when the console was created for it. The window is hidden first
|
||||
// and then the console freed: under Windows Terminal as the default terminal, freeing is what closes the terminal
|
||||
// window that opened beside the game.
|
||||
int plat_console_release_if_owned(void) {
|
||||
DWORD pids[2];
|
||||
if (!GetConsoleWindow() || GetConsoleProcessList(pids, 2) != 1) return 0;
|
||||
ShowWindow(GetConsoleWindow(), SW_HIDE);
|
||||
FreeConsole();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ---- desktop
|
||||
|
||||
int plat_clipboard_set(const char *utf8) {
|
||||
|
||||
Reference in new issue
Block a user