2024-08-22 17:07:19 -07:00
|
|
|
From 3e4287cf1f1824641954ce899abfcf68de7beaa7 Mon Sep 17 00:00:00 2001
|
2023-02-07 03:35:38 -08:00
|
|
|
From: =?UTF-8?q?R=C3=A9mi=20Bernon?= <rbernon@codeweavers.com>
|
|
|
|
Date: Fri, 6 Jan 2023 08:09:11 +0100
|
2023-03-14 21:06:52 -07:00
|
|
|
Subject: [PATCH] winex11: Use the user configured keyboard layout if any.
|
2023-02-07 03:35:38 -08:00
|
|
|
|
|
|
|
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=30984
|
|
|
|
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45605
|
|
|
|
---
|
|
|
|
dlls/winex11.drv/keyboard.c | 33 +++++++++++++++++++++++++++------
|
|
|
|
dlls/winex11.drv/x11drv.h | 2 ++
|
|
|
|
dlls/winex11.drv/x11drv_main.c | 4 ++++
|
|
|
|
3 files changed, 33 insertions(+), 6 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
|
2024-08-22 17:07:19 -07:00
|
|
|
index 5b53a1b87b3..acd9def0f64 100644
|
2023-02-07 03:35:38 -08:00
|
|
|
--- a/dlls/winex11.drv/keyboard.c
|
|
|
|
+++ b/dlls/winex11.drv/keyboard.c
|
2024-08-22 17:07:19 -07:00
|
|
|
@@ -928,7 +928,6 @@ static const struct {
|
2023-02-07 03:35:38 -08:00
|
|
|
|
|
|
|
{0, NULL, NULL, NULL, NULL} /* sentinel */
|
|
|
|
};
|
|
|
|
-static unsigned kbd_layout=0; /* index into above table of layouts */
|
|
|
|
|
|
|
|
/* maybe more of these scancodes should be extended? */
|
|
|
|
/* extended must be set for ALT_R, CTRL_R,
|
2024-08-22 17:07:19 -07:00
|
|
|
@@ -1083,6 +1082,26 @@ static const WORD xfree86_vendor_key_vkey[256] =
|
2023-02-07 03:35:38 -08:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0 /* 1008FFF8 */
|
|
|
|
};
|
|
|
|
|
|
|
|
+int x11drv_find_keyboard_layout( const WCHAR *layout )
|
|
|
|
+{
|
|
|
|
+ int i, len;
|
|
|
|
+ char *tmp;
|
|
|
|
+
|
|
|
|
+ len = lstrlenW( layout );
|
|
|
|
+ if (!(tmp = malloc( len * 3 + 1 ))) return -1;
|
|
|
|
+ ntdll_wcstoumbs( layout, len + 1, tmp, len * 3 + 1, FALSE );
|
|
|
|
+
|
|
|
|
+ for (i = 0; main_key_tab[i].comment; i++)
|
|
|
|
+ {
|
|
|
|
+ const char *name = main_key_tab[i].comment;
|
|
|
|
+ if (!strcmp( name, tmp )) break;
|
|
|
|
+ }
|
|
|
|
+ free( tmp );
|
|
|
|
+
|
|
|
|
+ if (!main_key_tab[i].comment) return -1;
|
|
|
|
+ return i;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
WCHAR *x11drv_get_keyboard_layout_list( DWORD *length )
|
|
|
|
{
|
|
|
|
WCHAR *tmp, *layouts = calloc( 1, sizeof(WCHAR) );
|
2024-08-22 17:07:19 -07:00
|
|
|
@@ -1449,11 +1468,11 @@ BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
|
2023-02-07 03:35:38 -08:00
|
|
|
* whichever matches most closely.
|
|
|
|
* kbd_section must be held.
|
|
|
|
*/
|
|
|
|
-static void
|
|
|
|
+static int
|
|
|
|
X11DRV_KEYBOARD_DetectLayout( Display *display )
|
|
|
|
{
|
|
|
|
unsigned current, match, mismatch, seq, i, syms;
|
|
|
|
- int score, keyc, key, pkey, ok;
|
|
|
|
+ int score, keyc, key, pkey, ok, kbd_layout = 0;
|
|
|
|
KeySym keysym = 0;
|
|
|
|
const char (*lkey)[MAIN_LEN][4];
|
|
|
|
unsigned max_seq = 0;
|
2024-08-22 17:07:19 -07:00
|
|
|
@@ -1550,6 +1569,7 @@ X11DRV_KEYBOARD_DetectLayout( Display *display )
|
2023-02-07 03:35:38 -08:00
|
|
|
main_key_tab[kbd_layout].comment);
|
|
|
|
|
|
|
|
TRACE("detected layout is \"%s\"\n", main_key_tab[kbd_layout].comment);
|
|
|
|
+ return kbd_layout;
|
|
|
|
}
|
|
|
|
|
2023-03-14 21:06:52 -07:00
|
|
|
|
2024-08-22 17:07:19 -07:00
|
|
|
@@ -1585,7 +1605,7 @@ void X11DRV_InitKeyboard( Display *display )
|
2023-02-07 03:35:38 -08:00
|
|
|
{ 0x41, 0x5a }, /* VK_A - VK_Z */
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
- int vkey_range;
|
|
|
|
+ int vkey_range, kbd_layout;
|
|
|
|
|
|
|
|
pthread_mutex_lock( &kbd_mutex );
|
|
|
|
XDisplayKeycodes(display, &min_keycode, &max_keycode);
|
2024-08-22 17:07:19 -07:00
|
|
|
@@ -1617,8 +1637,9 @@ void X11DRV_InitKeyboard( Display *display )
|
2023-02-07 03:35:38 -08:00
|
|
|
}
|
|
|
|
XFreeModifiermap(mmp);
|
|
|
|
|
|
|
|
- /* Detect the keyboard layout */
|
|
|
|
- X11DRV_KEYBOARD_DetectLayout( display );
|
|
|
|
+ /* use the configured layout from registry or auto detect it */
|
|
|
|
+ kbd_layout = keyboard_layout;
|
|
|
|
+ if (kbd_layout == -1) kbd_layout = X11DRV_KEYBOARD_DetectLayout( display );
|
|
|
|
lkey = main_key_tab[kbd_layout].key;
|
|
|
|
syms = (keysyms_per_keycode > 4) ? 4 : keysyms_per_keycode;
|
|
|
|
|
|
|
|
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
|
2024-08-22 17:07:19 -07:00
|
|
|
index 4f9ccd1e3f8..85012bf4bfc 100644
|
2023-02-07 03:35:38 -08:00
|
|
|
--- a/dlls/winex11.drv/x11drv.h
|
|
|
|
+++ b/dlls/winex11.drv/x11drv.h
|
2024-08-22 17:07:19 -07:00
|
|
|
@@ -429,6 +429,7 @@ extern BOOL use_take_focus;
|
2023-12-01 15:23:49 -08:00
|
|
|
extern BOOL use_primary_selection;
|
2023-11-29 16:35:48 -08:00
|
|
|
extern BOOL use_system_cursors;
|
|
|
|
extern BOOL grab_fullscreen;
|
|
|
|
+extern int keyboard_layout;
|
|
|
|
extern BOOL usexcomposite;
|
|
|
|
extern BOOL managed_mode;
|
2024-08-22 17:07:19 -07:00
|
|
|
extern BOOL private_color_map;
|
|
|
|
@@ -687,6 +688,7 @@ extern void init_recursive_mutex( pthread_mutex_t *mutex );
|
2023-02-07 03:35:38 -08:00
|
|
|
|
|
|
|
/* keyboard.c */
|
|
|
|
|
2023-11-29 16:35:48 -08:00
|
|
|
+extern int x11drv_find_keyboard_layout( const WCHAR *layout );
|
|
|
|
extern WCHAR *x11drv_get_keyboard_layout_list( DWORD *size );
|
2023-02-07 03:35:38 -08:00
|
|
|
|
|
|
|
#define DEPTH_COUNT 3
|
|
|
|
diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
|
2024-08-22 17:07:19 -07:00
|
|
|
index 56edca46f37..909de5e46eb 100644
|
2023-02-07 03:35:38 -08:00
|
|
|
--- a/dlls/winex11.drv/x11drv_main.c
|
|
|
|
+++ b/dlls/winex11.drv/x11drv_main.c
|
2023-12-01 15:23:49 -08:00
|
|
|
@@ -75,6 +75,7 @@ BOOL use_take_focus = TRUE;
|
|
|
|
BOOL use_primary_selection = FALSE;
|
2023-06-12 16:20:03 -07:00
|
|
|
BOOL use_system_cursors = TRUE;
|
2023-02-07 03:35:38 -08:00
|
|
|
BOOL grab_fullscreen = FALSE;
|
|
|
|
+int keyboard_layout = -1;
|
|
|
|
BOOL managed_mode = TRUE;
|
|
|
|
BOOL private_color_map = FALSE;
|
2024-08-22 17:07:19 -07:00
|
|
|
int primary_monitor = 0;
|
|
|
|
@@ -545,6 +546,9 @@ static void setup_options(void)
|
2023-02-07 03:35:38 -08:00
|
|
|
if (!get_config_key( hkey, appkey, "GrabFullscreen", buffer, sizeof(buffer) ))
|
|
|
|
grab_fullscreen = IS_OPTION_TRUE( buffer[0] );
|
|
|
|
|
|
|
|
+ if (!get_config_key( hkey, appkey, "KeyboardLayout", buffer, sizeof(buffer) ))
|
|
|
|
+ keyboard_layout = x11drv_find_keyboard_layout( buffer );
|
|
|
|
+
|
|
|
|
p = x11drv_get_keyboard_layout_list( &len );
|
|
|
|
if (p) set_reg_string_value( hkey, "KeyboardLayoutList", p, len * sizeof(WCHAR) );
|
|
|
|
free( p );
|
|
|
|
--
|
2024-08-22 17:07:19 -07:00
|
|
|
2.45.2
|
2023-02-07 03:35:38 -08:00
|
|
|
|