|
| 1 | +From 36cb225502f88e66423b71752dfd1f8c35aef705 Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com> |
| 3 | +Date: Fri, 6 Jan 2023 08:15:41 +0100 |
| 4 | +Subject: [PATCH 3/8] winecfg: Add a keyboard layout selection config option. |
| 5 | + |
| 6 | +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30984 |
| 7 | +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45605 |
| 8 | +--- |
| 9 | + programs/winecfg/input.c | 48 ++++++++++++++++++++++++++++++++++++- |
| 10 | + programs/winecfg/resource.h | 3 +++ |
| 11 | + programs/winecfg/winecfg.rc | 9 +++++++ |
| 12 | + 3 files changed, 59 insertions(+), 1 deletion(-) |
| 13 | + |
| 14 | +diff --git a/programs/winecfg/input.c b/programs/winecfg/input.c |
| 15 | +index 115161b9040..f2f035df80f 100644 |
| 16 | +--- a/programs/winecfg/input.c |
| 17 | ++++ b/programs/winecfg/input.c |
| 18 | +@@ -35,7 +35,9 @@ static BOOL updating_ui; |
| 19 | + |
| 20 | + static void init_dialog( HWND dialog ) |
| 21 | + { |
| 22 | +- WCHAR *buffer; |
| 23 | ++ WCHAR auto_detect_layout[256]; |
| 24 | ++ WCHAR *buffer, *layout; |
| 25 | ++ HWND layouts; |
| 26 | + |
| 27 | + convert_x11_desktop_key(); |
| 28 | + |
| 29 | +@@ -46,6 +48,23 @@ static void init_dialog( HWND dialog ) |
| 30 | + else CheckDlgButton( dialog, IDC_FULLSCREEN_GRAB, BST_UNCHECKED ); |
| 31 | + free( buffer ); |
| 32 | + |
| 33 | ++ layouts = GetDlgItem( dialog, IDC_KEYBOARD_LAYOUT ); |
| 34 | ++ LoadStringW( GetModuleHandleW( NULL ), IDS_INPUT_AUTO_DETECT_LAYOUT, auto_detect_layout, |
| 35 | ++ ARRAY_SIZE(auto_detect_layout) ); |
| 36 | ++ |
| 37 | ++ SendMessageW( layouts, CB_RESETCONTENT, 0, 0 ); |
| 38 | ++ SendMessageW( layouts, CB_ADDSTRING, 0, (LPARAM)auto_detect_layout ); |
| 39 | ++ |
| 40 | ++ buffer = get_reg_key( config_key, keypath( L"X11 Driver" ), L"KeyboardLayoutList", L"" ); |
| 41 | ++ for (layout = buffer; *layout; layout += wcslen( layout ) + 1) |
| 42 | ++ SendMessageW( layouts, CB_ADDSTRING, 0, (LPARAM)layout ); |
| 43 | ++ free( buffer ); |
| 44 | ++ |
| 45 | ++ buffer = get_reg_key( config_key, keypath( L"X11 Driver" ), L"KeyboardLayout", L"" ); |
| 46 | ++ if (!buffer || !buffer[0]) SendMessageW( layouts, CB_SETCURSEL, 0, 0 ); |
| 47 | ++ else SendMessageW( layouts, CB_SELECTSTRING, -1, (LPARAM)buffer ); |
| 48 | ++ free( buffer ); |
| 49 | ++ |
| 50 | + updating_ui = FALSE; |
| 51 | + } |
| 52 | + |
| 53 | +@@ -56,6 +75,24 @@ static void on_fullscreen_grab_clicked( HWND dialog ) |
| 54 | + else set_reg_key( config_key, keypath( L"X11 Driver" ), L"GrabFullscreen", L"N" ); |
| 55 | + } |
| 56 | + |
| 57 | ++static void on_keyboard_layout_changed( HWND dialog ) |
| 58 | ++{ |
| 59 | ++ int len, index; |
| 60 | ++ WCHAR *buffer; |
| 61 | ++ |
| 62 | ++ if (!(index = SendMessageW( GetDlgItem( dialog, IDC_KEYBOARD_LAYOUT ), CB_GETCURSEL, 0, 0 ))) |
| 63 | ++ set_reg_key( config_key, keypath( L"X11 Driver" ), L"KeyboardLayout", L"" ); |
| 64 | ++ else |
| 65 | ++ { |
| 66 | ++ len = SendMessageW( GetDlgItem( dialog, IDC_KEYBOARD_LAYOUT ), CB_GETLBTEXTLEN, index, 0 ) + 1; |
| 67 | ++ if (!(buffer = malloc( len * sizeof(WCHAR) ))) return; |
| 68 | ++ |
| 69 | ++ SendMessageW( GetDlgItem( dialog, IDC_KEYBOARD_LAYOUT ), CB_GETLBTEXT, index, (LPARAM)buffer ); |
| 70 | ++ set_reg_key( config_key, keypath( L"X11 Driver" ), L"KeyboardLayout", buffer ); |
| 71 | ++ free( buffer ); |
| 72 | ++ } |
| 73 | ++} |
| 74 | ++ |
| 75 | + INT_PTR CALLBACK InputDlgProc( HWND dialog, UINT message, WPARAM wparam, LPARAM lparam ) |
| 76 | + { |
| 77 | + TRACE( "dialog %p, message %#x, wparam %#Ix, lparam %#Ix\n", dialog, message, wparam, lparam ); |
| 78 | +@@ -77,6 +114,15 @@ INT_PTR CALLBACK InputDlgProc( HWND dialog, UINT message, WPARAM wparam, LPARAM |
| 79 | + case IDC_FULLSCREEN_GRAB: on_fullscreen_grab_clicked( dialog ); break; |
| 80 | + } |
| 81 | + break; |
| 82 | ++ |
| 83 | ++ case CBN_SELCHANGE: |
| 84 | ++ if (updating_ui) break; |
| 85 | ++ SendMessageW( GetParent( dialog ), PSM_CHANGED, 0, 0 ); |
| 86 | ++ switch (LOWORD(wparam)) |
| 87 | ++ { |
| 88 | ++ case IDC_KEYBOARD_LAYOUT: on_keyboard_layout_changed( dialog ); break; |
| 89 | ++ } |
| 90 | ++ break; |
| 91 | + } |
| 92 | + break; |
| 93 | + |
| 94 | +diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h |
| 95 | +index 8022bf4b30c..05331f9db58 100644 |
| 96 | +--- a/programs/winecfg/resource.h |
| 97 | ++++ b/programs/winecfg/resource.h |
| 98 | +@@ -235,3 +235,6 @@ |
| 99 | + |
| 100 | + /* input tab */ |
| 101 | + #define IDC_FULLSCREEN_GRAB 1501 |
| 102 | ++#define IDC_KEYBOARD_LAYOUT 1502 |
| 103 | ++ |
| 104 | ++#define IDS_INPUT_AUTO_DETECT_LAYOUT 8501 |
| 105 | +diff --git a/programs/winecfg/winecfg.rc b/programs/winecfg/winecfg.rc |
| 106 | +index f993e5eec89..6c814617f15 100644 |
| 107 | +--- a/programs/winecfg/winecfg.rc |
| 108 | ++++ b/programs/winecfg/winecfg.rc |
| 109 | +@@ -136,6 +136,11 @@ BEGIN |
| 110 | + IDC_SYSPARAMS_MENUBAR "Menu Bar" |
| 111 | + END |
| 112 | + |
| 113 | ++STRINGTABLE |
| 114 | ++BEGIN |
| 115 | ++ IDS_INPUT_AUTO_DETECT_LAYOUT "(Auto detect)" |
| 116 | ++END |
| 117 | ++ |
| 118 | + IDD_ABOUTCFG DIALOGEX 0, 0, 260, 220 |
| 119 | + STYLE WS_CHILD |
| 120 | + FONT 8, "MS Shell Dlg" |
| 121 | +@@ -340,6 +345,10 @@ FONT 8, "MS Shell Dlg" |
| 122 | + BEGIN |
| 123 | + GROUPBOX "Mouse settings",IDC_STATIC,8,4,244,64 |
| 124 | + CONTROL "Automatically capture the &mouse in full-screen windows",IDC_FULLSCREEN_GRAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,20,230,10 |
| 125 | ++ |
| 126 | ++ GROUPBOX "Keyboard settings",IDC_STATIC,8,70,244,64 |
| 127 | ++ LTEXT "&Layout:",IDC_STATIC,15,82,230,8 |
| 128 | ++ COMBOBOX IDC_KEYBOARD_LAYOUT,110,80,135,60,CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_SORT | WS_VSCROLL | WS_TABSTOP |
| 129 | + END |
| 130 | + |
| 131 | + LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL |
| 132 | +-- |
| 133 | +2.54.0 |
| 134 | + |
0 commit comments