fix(Windows): restore console title at exit #21922

Fixes #21404
This commit is contained in:
Enan Ajmain
2023-01-23 15:45:18 +06:00
committed by GitHub
parent cb757f2663
commit b36b58d0d4
2 changed files with 15 additions and 0 deletions

View File

@@ -584,6 +584,7 @@ int main(int argc, char **argv)
if (use_builtin_ui) { if (use_builtin_ui) {
os_icon_init(); os_icon_init();
} }
os_title_save();
#endif #endif
// Adjust default register name for "unnamed" in 'clipboard'. Can only be // Adjust default register name for "unnamed" in 'clipboard'. Can only be
@@ -775,6 +776,7 @@ void getout(int exitval)
#ifdef MSWIN #ifdef MSWIN
// Restore Windows console icon before exiting. // Restore Windows console icon before exiting.
os_icon_set(NULL, NULL); os_icon_set(NULL, NULL);
os_title_reset();
#endif #endif
os_exit(exitval); os_exit(exitval);

View File

@@ -10,6 +10,7 @@
# include "os/os_win_console.c.generated.h" # include "os/os_win_console.c.generated.h"
#endif #endif
static char origTitle[256] = { 0 };
static HWND hWnd = NULL; static HWND hWnd = NULL;
static HICON hOrigIconSmall = NULL; static HICON hOrigIconSmall = NULL;
static HICON hOrigIcon = NULL; static HICON hOrigIcon = NULL;
@@ -92,3 +93,15 @@ void os_icon_init(void)
} }
} }
} }
/// Saves the original Windows console title.
void os_title_save(void)
{
GetConsoleTitle(origTitle, sizeof(origTitle));
}
/// Resets the original Windows console title.
void os_title_reset(void)
{
SetConsoleTitle(origTitle);
}