On Windows, HKCU\Console holds global default settings, while subkeys hold any app-specific settings that differ from the defaults.
Wine's conhost.exe implementation currently saves all console settings to an app-specific subkey on the first run, while global defaults are only saved to HKCU\Console if the user selects 'Set Defaults' from the pop-up menu and saves new settings. This is the opposite of console behaviour on Windows.
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/conhost/window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/programs/conhost/window.c b/programs/conhost/window.c index 5e8c3e15a4f..019925789fd 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -850,7 +850,7 @@ static void set_first_font( struct console *console, struct console_config *conf if (fc.pass > 5) ERR("Unable to find a valid console font\n");
- /* Save font configuration to the registry */ + /* Update active configuration */ config->cell_width = console->active->font.width; config->cell_height = console->active->font.height; config->font_pitch_family = console->active->font.pitch_family; @@ -858,7 +858,8 @@ static void set_first_font( struct console *console, struct console_config *conf console->active->font.face_len * sizeof(WCHAR) ); config->face_name[console->active->font.face_len] = 0;
- save_config( console->window->config_key, config ); + /* Save default console configuration to the registry */ + save_config( NULL, config ); }
/* Sets the font specified in the LOGFONT as the new console font */
On Windows, app-specific subkeys of HKCU\Console only hold console settings that differ from the global defaults.
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/conhost/window.c | 140 +++++++++++++++++++++++++++----------- 1 file changed, 99 insertions(+), 41 deletions(-)
diff --git a/programs/conhost/window.c b/programs/conhost/window.c index 019925789fd..d5aa01dca65 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -280,69 +280,128 @@ static void load_config( const WCHAR *key_name, struct console_config *config ) TRACE( "%s\n", debugstr_config( config )); }
-static void save_registry_key( HKEY key, const struct console_config *config ) +static void save_registry_key( HKEY key, const struct console_config *config, BOOL save_all ) { + struct console_config default_config; DWORD val, width, height, i; WCHAR color_name[13];
TRACE( "%s\n", debugstr_config( config ));
+ if (!save_all) + load_config( NULL, &default_config ); + for (i = 0; i < ARRAY_SIZE(config->color_map); i++) { - wsprintfW( color_name, L"ColorTable%02d", i ); - val = config->color_map[i]; - RegSetValueExW( key, color_name, 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->color_map[i] != default_config.color_map[i]) + { + wsprintfW( color_name, L"ColorTable%02d", i ); + val = config->color_map[i]; + RegSetValueExW( key, color_name, 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + } }
- val = config->cursor_size; - RegSetValueExW( key, L"CursorSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->cursor_size != default_config.cursor_size) + { + val = config->cursor_size; + RegSetValueExW( key, L"CursorSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->cursor_visible; - RegSetValueExW( key, L"CursorVisible", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->cursor_visible != default_config.cursor_visible) + { + val = config->cursor_visible; + RegSetValueExW( key, L"CursorVisible", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->edition_mode; - RegSetValueExW( key, L"EditionMode", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->edition_mode != default_config.edition_mode) + { + val = config->edition_mode; + RegSetValueExW( key, L"EditionMode", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- RegSetValueExW( key, L"FaceName", 0, REG_SZ, (BYTE *)&config->face_name, - (lstrlenW(config->face_name) + 1) * sizeof(WCHAR) ); + if (save_all || lstrcmpW( config->face_name, default_config.face_name )) + { + RegSetValueExW( key, L"FaceName", 0, REG_SZ, (BYTE *)&config->face_name, + (lstrlenW(config->face_name) + 1) * sizeof(WCHAR) ); + }
- val = config->font_pitch_family; - RegSetValueExW( key, L"FontPitchFamily", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->font_pitch_family != default_config.font_pitch_family) + { + val = config->font_pitch_family; + RegSetValueExW( key, L"FontPitchFamily", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- width = MulDiv( config->cell_width, USER_DEFAULT_SCREEN_DPI, GetDpiForSystem() ); - height = MulDiv( config->cell_height, USER_DEFAULT_SCREEN_DPI, GetDpiForSystem() ); - val = MAKELONG( width, height ); - RegSetValueExW( key, L"FontSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->cell_height != default_config.cell_height || + config->cell_width != default_config.cell_width) + { + width = MulDiv( config->cell_width, USER_DEFAULT_SCREEN_DPI, GetDpiForSystem() ); + height = MulDiv( config->cell_height, USER_DEFAULT_SCREEN_DPI, GetDpiForSystem() ); + val = MAKELONG( width, height );
- val = config->font_weight; - RegSetValueExW( key, L"FontWeight", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + RegSetValueExW( key, L"FontSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->history_size; - RegSetValueExW( key, L"HistoryBufferSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->font_weight != default_config.font_weight) + { + val = config->font_weight; + RegSetValueExW( key, L"FontWeight", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->history_mode; - RegSetValueExW( key, L"HistoryNoDup", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->history_size != default_config.history_size) + { + val = config->history_size; + RegSetValueExW( key, L"HistoryBufferSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->insert_mode; - RegSetValueExW( key, L"InsertMode", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->history_mode != default_config.history_mode) + { + val = config->history_mode; + RegSetValueExW( key, L"HistoryNoDup", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->menu_mask; - RegSetValueExW( key, L"MenuMask", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->insert_mode != default_config.insert_mode) + { + val = config->insert_mode; + RegSetValueExW( key, L"InsertMode", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->popup_attr; - RegSetValueExW( key, L"PopupColors", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->menu_mask != default_config.menu_mask) + { + val = config->menu_mask; + RegSetValueExW( key, L"MenuMask", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + } + + if (save_all || config->popup_attr != default_config.popup_attr) + { + val = config->popup_attr; + RegSetValueExW( key, L"PopupColors", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->quick_edit; - RegSetValueExW( key, L"QuickEdit", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->quick_edit != default_config.quick_edit) + { + val = config->quick_edit; + RegSetValueExW( key, L"QuickEdit", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = MAKELONG(config->sb_width, config->sb_height); - RegSetValueExW( key, L"ScreenBufferSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->sb_width != default_config.sb_width || + config->sb_height != default_config.sb_height) + { + val = MAKELONG(config->sb_width, config->sb_height); + RegSetValueExW( key, L"ScreenBufferSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = config->attr; - RegSetValueExW( key, L"ScreenColors", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->attr != default_config.attr) + { + val = config->attr; + RegSetValueExW( key, L"ScreenColors", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + }
- val = MAKELONG( config->win_width, config->win_height ); - RegSetValueExW( key, L"WindowSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + if (save_all || config->win_width != default_config.win_width || + config->win_height != default_config.win_height) + { + val = MAKELONG( config->win_width, config->win_height ); + RegSetValueExW( key, L"WindowSize", 0, REG_DWORD, (BYTE *)&val, sizeof(val) ); + } }
static void save_config( const WCHAR *key_name, const struct console_config *config ) @@ -365,12 +424,11 @@ static void save_config( const WCHAR *key_name, const struct console_config *con } else { - /* FIXME: maybe only save the values different from the default value ? */ - save_registry_key( app_key, config ); + save_registry_key( app_key, config, FALSE ); RegCloseKey( app_key ); } } - else save_registry_key( key, config ); + else save_registry_key( key, config, TRUE ); RegCloseKey(key); }
Signed-off-by: Jacek Caban jacek@codeweavers.com
On Windows, app-specific console settings are always saved to the registry unless the user cancels the console properties dialog.
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com --- programs/conhost/conhost.h | 4 --- programs/conhost/conhost.rc | 12 ------- programs/conhost/window.c | 69 +++++-------------------------------- 3 files changed, 9 insertions(+), 76 deletions(-)
diff --git a/programs/conhost/conhost.h b/programs/conhost/conhost.h index 9f2a90cd510..4464f51032f 100644 --- a/programs/conhost/conhost.h +++ b/programs/conhost/conhost.h @@ -186,7 +186,6 @@ static inline unsigned int get_bounded_cursor_x( struct screen_buffer *screen_bu #define IDD_OPTION 0x0100 #define IDD_FONT 0x0200 #define IDD_CONFIG 0x0300 -#define IDD_SAVE_SETTINGS 0x0400
/* dialog boxes controls */ #define IDC_OPT_CURSOR_SMALL 0x0101 @@ -217,6 +216,3 @@ static inline unsigned int get_bounded_cursor_x( struct screen_buffer *screen_bu #define IDC_CNF_WIN_HEIGHT_UD 0x0308 #define IDC_CNF_CLOSE_EXIT 0x0309 #define IDC_CNF_EDITION_MODE 0x030a - -#define IDC_SAV_SAVE 0x0401 -#define IDC_SAV_SESSION 0x0402 diff --git a/programs/conhost/conhost.rc b/programs/conhost/conhost.rc index e7c4416b634..820220b9d60 100644 --- a/programs/conhost/conhost.rc +++ b/programs/conhost/conhost.rc @@ -114,18 +114,6 @@ FONT 8, "MS Shell Dlg" COMBOBOX IDC_CNF_EDITION_MODE, 119, 69, 75, 60, CBS_DROPDOWNLIST|WS_VSCROLL|WS_TABSTOP }
-IDD_SAVE_SETTINGS DIALOG 20, 20, 210, 60 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION -CAPTION "Console parameters" -FONT 8, "MS Shell Dlg" -{ - AUTORADIOBUTTON "Retain these settings for later sessions", IDC_SAV_SAVE, 10, 8, 200, 10, WS_TABSTOP - AUTORADIOBUTTON "Modify only current session", IDC_SAV_SESSION, 10, 22, 200, 10, WS_TABSTOP - - DEFPUSHBUTTON "OK", IDOK, 100, 43, 50, 14 - PUSHBUTTON "Cancel", IDCANCEL, 155, 43, 50, 14 -} - LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#define WINE_FILEDESCRIPTION_STR "Wine conhost" diff --git a/programs/conhost/window.c b/programs/conhost/window.c index d5aa01dca65..cc2df3e6e7b 100644 --- a/programs/conhost/window.c +++ b/programs/conhost/window.c @@ -1756,34 +1756,6 @@ static INT_PTR WINAPI config_dialog_proc( HWND dialog, UINT msg, WPARAM wparam, return TRUE; }
-/* dialog proc for choosing how to handle modification to the console settings */ -static INT_PTR WINAPI save_dialog_proc( HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam ) -{ - switch (msg) - { - case WM_INITDIALOG: - SendMessageW( dialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem( dialog, IDC_SAV_SESSION ), TRUE ); - SendDlgItemMessageW( dialog, IDC_SAV_SESSION, BM_SETCHECK, BST_CHECKED, 0 ); - return FALSE; - - case WM_COMMAND: - switch (LOWORD(wparam)) - { - case IDOK: - EndDialog( dialog, - (IsDlgButtonChecked(dialog, IDC_SAV_SAVE) == BST_CHECKED) ? - IDC_SAV_SAVE : IDC_SAV_SESSION ); - break; - case IDCANCEL: - EndDialog( dialog, IDCANCEL ); break; - } - break; - default: - return FALSE; - } - return TRUE; -} - static void apply_config( struct console *console, const struct console_config *config ) { if (console->active->width != config->sb_width || console->active->height != config->sb_height) @@ -1901,19 +1873,17 @@ static BOOL config_dialog( struct console *console, BOOL current ) PROPSHEETPAGEW psp; WNDCLASSW wndclass; WCHAR buff[256]; - BOOL modify_session = FALSE; - BOOL save = FALSE;
InitCommonControls();
memset( &di, 0, sizeof(di) ); di.console = console; - if (!current) - { + + if (current) + current_config( console, &di.config ); + else load_config( NULL, &di.config ); - save = TRUE; - } - else current_config( console, &di.config ); + prev_config = di.config;
wndclass.style = 0; @@ -1979,35 +1949,14 @@ static BOOL config_dialog( struct console *console, BOOL current )
TRACE( "%s\n", debugstr_config(&di.config) );
- if (!save) - { - switch (DialogBoxW( GetModuleHandleW( NULL ), MAKEINTRESOURCEW(IDD_SAVE_SETTINGS), - console->win, save_dialog_proc )) - { - case IDC_SAV_SAVE: - save = TRUE; - modify_session = TRUE; - break; - case IDC_SAV_SESSION: - modify_session = TRUE; - break; - default: - ERR( "dialog failed\n" ); - /* fall through */ - case IDCANCEL: - modify_session = FALSE; - save = FALSE; - break; - } - } - - if (modify_session) + if (current) { apply_config( console, &di.config ); update_window( di.console ); } - if (save) - save_config( current ? console->window->config_key : NULL, &di.config ); + + save_config( current ? console->window->config_key : NULL, &di.config ); + return TRUE; }
Signed-off-by: Jacek Caban jacek@codeweavers.com