From: Hugh McMaster hugh.mcmaster@outlook.com
On Windows, application-specific console settings are stored in the registry under HKCU\Console\<identifier>, where <identifier> is either the process path or the window title.
Wine currently uses the path to wineconsole.exe when loading or saving application-specific console settings, which is incorrect.
To ensure we load the correct console settings, we wait until the console process has initialized before converting the process path or window title into a registry key name. --- programs/conhost/conhost.c | 4 ++- programs/conhost/conhost.h | 2 ++ programs/conhost/window.c | 51 ++++++++++++++++++++++++-------------- 3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index c3a106c9321..a331216f62b 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -2753,6 +2753,9 @@ static NTSTATUS process_console_ioctls( struct console *console ) return status; }
+ if (!console->init && console->win) + init_window_config( console ); + if (code == IOCTL_CONDRV_INIT_OUTPUT) { TRACE( "initializing output %x\n", output ); @@ -2947,7 +2950,6 @@ int __cdecl wmain(int argc, WCHAR *argv[]) if (!init_window( &console )) return 1; GetStartupInfoW( &si ); set_console_title( &console, si.lpTitle, wcslen( si.lpTitle ) * sizeof(WCHAR) ); - ShowWindow( console.win, (si.dwFlags & STARTF_USESHOWWINDOW) ? si.wShowWindow : SW_SHOW ); }
return main_loop( &console, signal ); diff --git a/programs/conhost/conhost.h b/programs/conhost/conhost.h index 4464f51032f..e03d6239ce8 100644 --- a/programs/conhost/conhost.h +++ b/programs/conhost/conhost.h @@ -75,6 +75,7 @@ struct edit_line struct console { HANDLE server; /* console server handle */ + BOOL init; /* TRUE if console has initialized */ unsigned int mode; /* input mode */ struct screen_buffer *active; /* active screen buffer */ int is_unix; /* UNIX terminal mode */ @@ -145,6 +146,7 @@ NTSTATUS change_screen_buffer_size( struct screen_buffer *screen_buffer, int new void update_console_font( struct console *console, const WCHAR *face_name, size_t face_name_size, unsigned int height, unsigned int weight ); BOOL init_window( struct console *console ); +void init_window_config( struct console *console ); void init_message_window( struct console *console ); void update_window_region( struct console *console, const RECT *update ); void update_window_config( struct console *console, BOOL delay ); diff --git a/programs/conhost/window.c b/programs/conhost/window.c index 3db4b159696..cd02d60f40a 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -2392,33 +2392,25 @@ void update_window_region( struct console *console, const RECT *update ) update_window_config( console, TRUE ); }
-BOOL init_window( struct console *console ) +void init_window_config( struct console *console ) { + size_t len, i; struct console_config config; - WNDCLASSW wndclass; STARTUPINFOW si; - CHARSETINFO ci; - - static struct console_window console_window;
- console->window = &console_window; - if (!TranslateCharsetInfo( (DWORD *)(INT_PTR)GetACP(), &ci, TCI_SRCCODEPAGE )) - return FALSE; + console->init = TRUE; + if (!console->window || console->no_window) return;
- console->window->ui_charset = ci.ciCharset; + len = console->title ? wcslen( console->title ) : 0; + console->window->config_key = malloc( (len + 1) * sizeof(WCHAR) );
- GetStartupInfoW(&si); - if (si.lpTitle) - { - size_t i, title_len = wcslen( si.lpTitle ); - if (!(console->window->config_key = malloc( (title_len + 1) * sizeof(WCHAR) ))) - return FALSE; - for (i = 0; i < title_len; i++) - console->window->config_key[i] = si.lpTitle[i] == '\' ? '_' : si.lpTitle[i]; - console->window->config_key[title_len] = 0; - } + for (i = 0; i < len; i++) + console->window->config_key[i] = console->title[i] == '\' ? '_' : console->title[i]; + console->window->config_key[len] = 0;
load_config( console->window->config_key, &config ); + + GetStartupInfoW( &si ); if (si.dwFlags & STARTF_USECOUNTCHARS) { config.sb_width = si.dwXCountChars; @@ -2427,6 +2419,25 @@ BOOL init_window( struct console *console ) if (si.dwFlags & STARTF_USEFILLATTRIBUTE) config.attr = si.dwFillAttribute;
+ apply_config( console, &config ); + + ShowWindow( console->win, (si.dwFlags & STARTF_USESHOWWINDOW) ? si.wShowWindow : SW_SHOW ); +} + +BOOL init_window( struct console *console ) +{ + struct console_config config; + WNDCLASSW wndclass; + CHARSETINFO ci; + + static struct console_window console_window; + + console->window = &console_window; + if (!TranslateCharsetInfo( (DWORD *)(INT_PTR)GetACP(), &ci, TCI_SRCCODEPAGE )) + return FALSE; + + console->window->ui_charset = ci.ciCharset; + wndclass.style = CS_DBLCLKS; wndclass.lpfnWndProc = window_proc; wndclass.cbClsExtra = 0; @@ -2445,6 +2456,8 @@ BOOL init_window( struct console *console ) 0, 0, 0, 0, wndclass.hInstance, console )) return FALSE;
+ load_config( NULL, &config ); + if (!config.face_name[0]) set_first_font( console, &config );