[PATCH 0/6] MR10963: winex11: Keyboard layouts rework, part 3
From: Matteo Bruni <mbruni@codeweavers.com> --- dlls/winex11.drv/keyboard.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index ee6177a2884..fd8e2d7d3ff 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1698,6 +1698,19 @@ static LANGID langid_from_xkb_layout( const char *layout ) return MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED); }; +static const char *x11drv_xkb_layout_from_langid(LANGID langid) +{ + unsigned int i; + + /* TODO: precompute a sorted array of pointers to do bsearch here as well? */ + for (i = 0; i < ARRAY_SIZE(layout_ids); i++) + { + if (langid == layout_ids[i].langid) + return layout_ids[i].name; + } + return NULL; +} + static const struct klid_map_entry { const char *layout; @@ -2100,8 +2113,13 @@ void init_keyboard_layouts( Display *display ) XkbDescRec *xkb_desc; struct layout *entry; LANGID xkb_lang = 0; + const char *variant; + const char *layout; + char buffer[1024]; Status status; KeyCode *kcp; + DWORD klid; + LCID lcid; pthread_mutex_lock( &kbd_mutex ); XDisplayKeycodes( display, &min_keycode, &max_keycode ); @@ -2181,6 +2199,25 @@ void init_keyboard_layouts( Display *display ) WARN( "Xkb langid %04x differs from detected langid %04x\n", xkb_lang, main_key_tab[kbd_layout].lcid ); + if (!xkb_lang) + { + WARN("Xkb layout enumeration failed, falling back to fuzzy layout detection.\n"); + lcid = main_key_tab[kbd_layout].lcid; + layout = x11drv_xkb_layout_from_langid( lcid ); + if (strstr( main_key_tab[kbd_layout].comment, "dvorak" )) + { + variant = "dvorak"; + klid = 0x00010409; + } + else + { + variant = ""; + klid = 0; + } + snprintf( buffer, ARRAY_SIZE(buffer), "%s:%s", layout, variant ); + create_layout_from_xkb( xkb_state.group, buffer, lcid, klid ); + } + init_keycode_mappings( display ); pthread_mutex_unlock( &kbd_mutex ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10963
From: Matteo Bruni <mbruni@codeweavers.com> We still need main_key_tab[kbd_layout] and related data to map keycodes to VK / scancodes, so we can't quite get rid of the detect_keyboard_layout() call until we take care of that. --- dlls/winex11.drv/keyboard.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index fd8e2d7d3ff..10c0f2bfb21 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1749,9 +1749,9 @@ static DWORD klid_from_xkb_layout( const char *layout, const char *variant ) } /* fuzzy layout detection through keysym / keycode matching, kbd_section must be held */ -static void detect_keyboard_layout( Display *display, XModifierKeymap *modmap, unsigned int xkb_group ) +static unsigned int detect_keyboard_layout( Display *display, XModifierKeymap *modmap, unsigned int xkb_group ) { - unsigned current, match, mismatch, seq, i, syms; + unsigned current, match, mismatch, seq, i, syms, best_layout = 0; int score, keyc, key, pkey, ok; KeySym keysym; const char (*lkey)[MAIN_LEN][4]; @@ -1856,7 +1856,7 @@ static void detect_keyboard_layout( Display *display, XModifierKeymap *modmap, u match, mismatch, seq, score); if (score + (int)seq > max_score + (int)max_seq) { /* best match so far */ - kbd_layout = current; + best_layout = current; max_score = score; max_seq = seq; ismatch = !mismatch; @@ -1865,9 +1865,10 @@ static void detect_keyboard_layout( Display *display, XModifierKeymap *modmap, u /* we're done, report results if necessary */ if (!ismatch) WARN("Using closest match (%s) for scan/virtual codes mapping.\n", - main_key_tab[kbd_layout].comment); + main_key_tab[best_layout].comment); - TRACE("detected layout is \"%s\"\n", main_key_tab[kbd_layout].comment); + TRACE("detected layout is \"%s\"\n", main_key_tab[best_layout].comment); + return best_layout; } @@ -2192,7 +2193,7 @@ void init_keyboard_layouts( Display *display ) XkbFreeKeyboard( xkb_desc, 0, True ); } - detect_keyboard_layout( display, mmp, xkb_group ); + kbd_layout = detect_keyboard_layout( display, mmp, xkb_group ); XFreeModifiermap( mmp ); if (xkb_lang && xkb_lang != main_key_tab[kbd_layout].lcid) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10963
From: Matteo Bruni <mbruni@codeweavers.com> --- dlls/winex11.drv/keyboard.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 10c0f2bfb21..816b5f47063 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -2108,7 +2108,8 @@ static void init_keycode_mappings( Display *display ) /* initialize or update keyboard layouts */ void init_keyboard_layouts( Display *display ) { - unsigned int xkb_group; + unsigned int xkb_group, xkb_group_count; + unsigned int legacy_layout_idx; XkbStateRec xkb_state; XModifierKeymap *mmp; XkbDescRec *xkb_desc; @@ -2194,7 +2195,6 @@ void init_keyboard_layouts( Display *display ) } kbd_layout = detect_keyboard_layout( display, mmp, xkb_group ); - XFreeModifiermap( mmp ); if (xkb_lang && xkb_lang != main_key_tab[kbd_layout].lcid) WARN( "Xkb langid %04x differs from detected langid %04x\n", @@ -2203,21 +2203,28 @@ void init_keyboard_layouts( Display *display ) if (!xkb_lang) { WARN("Xkb layout enumeration failed, falling back to fuzzy layout detection.\n"); - lcid = main_key_tab[kbd_layout].lcid; - layout = x11drv_xkb_layout_from_langid( lcid ); - if (strstr( main_key_tab[kbd_layout].comment, "dvorak" )) - { - variant = "dvorak"; - klid = 0x00010409; - } - else + + xkb_group_count = status ? 1 : 4; + for (int i = 0; i < xkb_group_count; i++) { - variant = ""; - klid = 0; + legacy_layout_idx = detect_keyboard_layout( display, mmp, i ); + lcid = main_key_tab[legacy_layout_idx].lcid; + layout = x11drv_xkb_layout_from_langid( lcid ); + if (strstr( main_key_tab[legacy_layout_idx].comment, "dvorak" )) + { + variant = "dvorak"; + klid = 0x00010409; + } + else + { + variant = ""; + klid = 0; + } + snprintf( buffer, ARRAY_SIZE(buffer), "%s:%s", layout, variant ); + create_layout_from_xkb( i, buffer, lcid, klid ); } - snprintf( buffer, ARRAY_SIZE(buffer), "%s:%s", layout, variant ); - create_layout_from_xkb( xkb_state.group, buffer, lcid, klid ); } + XFreeModifiermap(mmp); init_keycode_mappings( display ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10963
From: Matteo Bruni <mbruni@codeweavers.com> This also introduces an "ActivateInitialLayout" registry setting to optionally disable it, for testing. --- dlls/winex11.drv/keyboard.c | 48 ++++++++++++++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 3 +++ dlls/winex11.drv/x11drv_main.c | 7 +++-- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 816b5f47063..0ac5f53780d 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1698,6 +1698,17 @@ static LANGID langid_from_xkb_layout( const char *layout ) return MAKELANGID(LANG_NEUTRAL, SUBLANG_CUSTOM_UNSPECIFIED); }; +static struct layout *get_xkb_layout_by_group( int xkb_group ) +{ + struct layout *layout; + + LIST_FOR_EACH_ENTRY( layout, &xkb_layouts, struct layout, entry ) + if (layout->xkb_group == xkb_group) return layout; + + WARN( "Failed to find Xkb layout for group %d\n", xkb_group ); + return NULL; +} + static const char *x11drv_xkb_layout_from_langid(LANGID langid) { unsigned int i; @@ -2231,14 +2242,28 @@ void init_keyboard_layouts( Display *display ) pthread_mutex_unlock( &kbd_mutex ); } +static HKL get_hkl( LANGID langid, WORD layout_id ) +{ + LCID locale = LOWORD(NtUserGetKeyboardLayout(0)); + + TRACE( "langid %04x, layout_id %04x\n", langid, layout_id ); + + if (layout_id) return ULongToHandle( MAKELONG(locale, 0xf000 | layout_id) ); + return ULongToHandle( MAKELONG(locale, langid) ); +} /*********************************************************************** * ActivateKeyboardLayout (X11DRV.@) */ BOOL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) { + struct x11drv_thread_data *thread_data = x11drv_thread_data(); + WARN("%p, %04x: semi-stub!\n", hkl, flags); + if (hkl == thread_data->kbd_layout) + return TRUE; + if (flags & KLF_SETFORPROCESS) { RtlSetLastWin32Error( ERROR_CALL_NOT_IMPLEMENTED ); @@ -2246,10 +2271,33 @@ BOOL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) return FALSE; } + thread_data->kbd_layout = hkl; + return TRUE; } +void x11drv_keyboard_init_thread( struct x11drv_thread_data *data ) +{ + unsigned int xkb_group; + XkbStateRec xkb_state; + struct layout *layout; + Status status; + + XkbUseExtension( data->display, NULL, NULL ); + XkbSetDetectableAutoRepeat( data->display, True, NULL ); + init_keyboard_layouts( data->display ); + status = XkbGetState( data->display, XkbUseCoreKbd, &xkb_state ); + xkb_group = status ? 0 : xkb_state.group; + TRACE( "current group %u (status %#x)\n", xkb_group, status ); + + layout = get_xkb_layout_by_group( xkb_group ); + + data->kbd_layout = get_hkl( layout->lang, layout->layout_id ); + if (activate_initial_layout) + NtUserActivateKeyboardLayout( data->kbd_layout, 0 ); +} + /*********************************************************************** * X11DRV_MappingNotify */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 3def37a8f21..88cccf5f6f9 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -404,6 +404,7 @@ struct x11drv_thread_data HWND grab_hwnd; /* window that currently grabs the mouse */ HWND last_focus; /* last window that had focus */ HWND keymapnotify_hwnd; /* window that should receive modifier release events */ + HKL kbd_layout; /* active keyboard layout */ XIM xim; /* input method */ HWND last_xic_hwnd; /* last xic window */ XFontSet font_set; /* international text drawing font set */ @@ -466,6 +467,7 @@ extern unsigned int screen_bpp; extern BOOL usexrandr; extern BOOL usexvidmode; extern BOOL use_egl; +extern BOOL activate_initial_layout; extern BOOL use_take_focus; extern BOOL use_primary_selection; extern BOOL use_system_cursors; @@ -755,6 +757,7 @@ extern void reapply_cursor_clipping(void); extern void ungrab_clipping_window(void); extern void move_resize_window( HWND hwnd, int dir, POINT pos ); extern void x11drv_init_keyboard( Display *display ); +extern void x11drv_keyboard_init_thread( struct x11drv_thread_data *data ); extern BOOL X11DRV_ProcessEvents( DWORD mask ); typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void *arg ); diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 39b23ffe0ec..7993e5fb7a7 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -68,6 +68,7 @@ BOOL usexvidmode = TRUE; BOOL usexrandr = TRUE; BOOL usexcomposite = TRUE; BOOL use_egl = TRUE; +BOOL activate_initial_layout = TRUE; BOOL use_take_focus = TRUE; BOOL use_primary_selection = FALSE; BOOL use_system_cursors = TRUE; @@ -462,6 +463,9 @@ static void setup_options(void) if (!get_config_key( hkey, appkey, "UseXRandR", buffer, sizeof(buffer) )) usexrandr = IS_OPTION_TRUE( buffer[0] ); + if (!get_config_key( hkey, appkey, "ActivateInitialLayout", buffer, sizeof(buffer) )) + activate_initial_layout = IS_OPTION_TRUE( buffer[0] ); + if (!get_config_key( hkey, appkey, "UseTakeFocus", buffer, sizeof(buffer) )) use_take_focus = IS_OPTION_TRUE( buffer[0] ); @@ -752,14 +756,13 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) fcntl( ConnectionNumber(data->display), F_SETFD, 1 ); /* set close on exec flag */ - XkbUseExtension( data->display, NULL, NULL ); - XkbSetDetectableAutoRepeat( data->display, True, NULL ); if (TRACE_ON(synchronous)) XSynchronize( data->display, True ); set_queue_display_fd( data->display ); pthread_setspecific( x11drv_thread_data_key, data ); XSelectInput( data->display, DefaultRootWindow( data->display ), PropertyChangeMask ); + x11drv_keyboard_init_thread( data ); if (use_xim) xim_thread_attach( data ); x11drv_xinput2_init( data ); net_supported_init( data ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10963
From: Matteo Bruni <mbruni@codeweavers.com> --- dlls/winex11.drv/keyboard.c | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 0ac5f53780d..7a54ee1b3c0 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1046,6 +1046,7 @@ static const struct { {0, NULL, NULL, NULL, NULL} /* sentinel */ }; static unsigned kbd_layout=0; /* index into above table of layouts */ +static int xkb_event_base, xkb_error_base; #ifdef SONAME_LIBXKBREGISTRY static struct rxkb_context *rxkb_context; @@ -2276,6 +2277,21 @@ BOOL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) return TRUE; } +static void x11drv_update_input_lang( Display *display ) +{ + unsigned old_kbd_layout = kbd_layout; + HWND hwnd; + HKL hkl; + + init_keyboard_layouts( display ); + if (kbd_layout != old_kbd_layout) + { + hwnd = get_focus(); + if (!hwnd) hwnd = get_active_window(); + hkl = get_hkl( main_key_tab[kbd_layout].lcid, 0 ); + NtUserPostMessage( hwnd, WM_INPUTLANGCHANGEREQUEST, 0, (LPARAM)hkl ); + } +} void x11drv_keyboard_init_thread( struct x11drv_thread_data *data ) { @@ -2285,6 +2301,8 @@ void x11drv_keyboard_init_thread( struct x11drv_thread_data *data ) Status status; XkbUseExtension( data->display, NULL, NULL ); + XkbSelectEvents( data->display, XkbUseCoreKbd, XkbMapNotifyMask | XkbStateNotifyMask, + XkbMapNotifyMask | XkbStateNotifyMask ); XkbSetDetectableAutoRepeat( data->display, True, NULL ); init_keyboard_layouts( data->display ); status = XkbGetState( data->display, XkbUseCoreKbd, &xkb_state ); @@ -2315,6 +2333,27 @@ BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event ) return TRUE; } +BOOL x11drv_xkb_event_handler( HWND dummy, XEvent *event ) +{ + XkbEvent *e = (XkbEvent *)event; + + switch (e->any.xkb_type) + { + case XkbStateNotify: + TRACE("Received XkbStateNotify event, changed %#x, group %u\n", e->state.changed, e->state.group); + if (!(e->state.changed & XkbGroupStateMask)) + return TRUE; + TRACE("Switching to group %u\n", e->state.group); + x11drv_update_input_lang( e->state.display ); + break; + case XkbMapNotify: + TRACE("Received XkbMapNotify event, changed %#x\n", e->map.changed); + XkbRefreshKeyboardMapping( &e->map ); + x11drv_update_input_lang( e->map.display ); + break; + } + return TRUE; +} /*********************************************************************** * x11drv_init_keyboard @@ -2322,6 +2361,9 @@ BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event ) void x11drv_init_keyboard( Display *display ) { XkbUseExtension( display, NULL, NULL ); + XkbQueryExtension( display, 0, &xkb_event_base, &xkb_error_base, 0, 0 ); + TRACE("xkb_event_base %u, xkb_error_base %u\n", xkb_event_base, xkb_error_base); + X11DRV_register_event_handler( xkb_event_base, x11drv_xkb_event_handler, "Xkb" ); #ifdef SONAME_LIBXKBREGISTRY if (!(xkbregistry_handle = dlopen( SONAME_LIBXKBREGISTRY, RTLD_NOW ))) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10963
From: Matteo Bruni <mbruni@codeweavers.com> We get this event when a new keymap is being set, usually when switching to a layout not represented by the previous keymap. --- dlls/winex11.drv/keyboard.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 7a54ee1b3c0..86579721cb8 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1047,6 +1047,7 @@ static const struct { }; static unsigned kbd_layout=0; /* index into above table of layouts */ static int xkb_event_base, xkb_error_base; +static unsigned short xkb_device_spec; #ifdef SONAME_LIBXKBREGISTRY static struct rxkb_context *rxkb_context; @@ -2121,6 +2122,7 @@ static void init_keycode_mappings( Display *display ) void init_keyboard_layouts( Display *display ) { unsigned int xkb_group, xkb_group_count; + unsigned prev_kbd_layout = kbd_layout; unsigned int legacy_layout_idx; XkbStateRec xkb_state; XModifierKeymap *mmp; @@ -2136,6 +2138,12 @@ void init_keyboard_layouts( Display *display ) LCID lcid; pthread_mutex_lock( &kbd_mutex ); + if (kbd_layout != prev_kbd_layout) + { + TRACE("Keyboard layout already updated, returning\n"); + pthread_mutex_unlock( &kbd_mutex ); + return; + } XDisplayKeycodes( display, &min_keycode, &max_keycode ); XFree( XGetKeyboardMapping( display, min_keycode, max_keycode + 1 - min_keycode, &keysyms_per_keycode ) ); @@ -2174,6 +2182,7 @@ void init_keyboard_layouts( Display *display ) char *names[4]; int count; + xkb_device_spec = xkb_desc->device_spec; XkbGetNames( display, XkbGroupNamesMask, xkb_desc ); for (count = 0; count < ARRAY_SIZE(xkb_desc->names->groups); count++) if (!xkb_desc->names->groups[count]) break; @@ -2301,8 +2310,9 @@ void x11drv_keyboard_init_thread( struct x11drv_thread_data *data ) Status status; XkbUseExtension( data->display, NULL, NULL ); - XkbSelectEvents( data->display, XkbUseCoreKbd, XkbMapNotifyMask | XkbStateNotifyMask, - XkbMapNotifyMask | XkbStateNotifyMask ); + XkbSelectEvents( data->display, XkbUseCoreKbd, + XkbMapNotifyMask | XkbStateNotifyMask | XkbNewKeyboardNotifyMask, + XkbMapNotifyMask | XkbStateNotifyMask | XkbNewKeyboardNotifyMask); XkbSetDetectableAutoRepeat( data->display, True, NULL ); init_keyboard_layouts( data->display ); status = XkbGetState( data->display, XkbUseCoreKbd, &xkb_state ); @@ -2351,6 +2361,13 @@ BOOL x11drv_xkb_event_handler( HWND dummy, XEvent *event ) XkbRefreshKeyboardMapping( &e->map ); x11drv_update_input_lang( e->map.display ); break; + case XkbNewKeyboardNotify: + TRACE("Received XkbNewKeyboardNotify event, changed %#x, device %u\n", + e->new_kbd.changed, e->new_kbd.device); + if (!xkb_device_spec || e->new_kbd.device != xkb_device_spec) + return TRUE; + x11drv_update_input_lang( e->new_kbd.display ); + break; } return TRUE; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10963
Rémi Bernon (@rbernon) commented about dlls/winex11.drv/keyboard.c:
+ XkbStateRec xkb_state; + struct layout *layout; + Status status; + + XkbUseExtension( data->display, NULL, NULL ); + XkbSetDetectableAutoRepeat( data->display, True, NULL ); + init_keyboard_layouts( data->display ); + status = XkbGetState( data->display, XkbUseCoreKbd, &xkb_state ); + xkb_group = status ? 0 : xkb_state.group; + TRACE( "current group %u (status %#x)\n", xkb_group, status ); + + layout = get_xkb_layout_by_group( xkb_group ); + + data->kbd_layout = get_hkl( layout->lang, layout->layout_id ); + if (activate_initial_layout) + NtUserActivateKeyboardLayout( data->kbd_layout, 0 ); It doesn't look right to activate the keyboard layout on every new GUI thread init.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140938
Rémi Bernon (@rbernon) commented about dlls/winex11.drv/x11drv.h:
extern BOOL usexrandr; extern BOOL usexvidmode; extern BOOL use_egl; +extern BOOL activate_initial_layout; I'm also not sure we want to add a registry option for that, especially if the behavior is enabled by default. We only need options to disable behavior if they are known to be problematic and difficult to fix. If the new behavior is known to cause problems already we should try to fix it before it gets introduced.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140940
Rémi Bernon (@rbernon) commented about dlls/winex11.drv/x11drv.h:
HWND grab_hwnd; /* window that currently grabs the mouse */ HWND last_focus; /* last window that had focus */ HWND keymapnotify_hwnd; /* window that should receive modifier release events */ + HKL kbd_layout; /* active keyboard layout */
Do we really need a x11drv specific field? Isn't the win32u thread state enough? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140939
Rémi Bernon (@rbernon) commented about dlls/winex11.drv/keyboard.c:
+ return TRUE; }
+static void x11drv_update_input_lang( Display *display ) +{ + unsigned old_kbd_layout = kbd_layout; + HWND hwnd; + HKL hkl; + + init_keyboard_layouts( display ); + if (kbd_layout != old_kbd_layout) + { + hwnd = get_focus(); + if (!hwnd) hwnd = get_active_window(); + hkl = get_hkl( main_key_tab[kbd_layout].lcid, 0 ); This seem to rely on the fuzzy layout detection which I believe is still not accurate. I don't think we should build up more features on top of it, so I would say this looks premature?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140941
On Thu May 21 09:07:05 2026 +0000, Rémi Bernon wrote:
It doesn't look right to activate the keyboard layout on every new GUI thread init. I think it's necessary? On Windows and on various Linux DE, you can have window / thread-specific keyboard layouts. Nowadays it usually defaults to a single layout for the whole system, but as far as I can see it's still possible to have the more granular behavior.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140949
On Thu May 21 09:07:05 2026 +0000, Rémi Bernon wrote:
Do we really need a x11drv specific field? Isn't the win32u thread state enough? I don't think you can get to that from the driver. At least the mac driver has the equivalent `HKL active_keyboard_layout;`, while winewayland has a global `static HKL keyboard_hkl;` which, for the reason mentioned above, doesn't seem ideal.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140950
On Thu May 21 09:07:05 2026 +0000, Rémi Bernon wrote:
This seem to rely on the fuzzy layout detection which I believe is still not accurate. I don't think we should build up more features on top of it, so I would say this looks premature? I have a couple of patches switching this to the new layout infrastructure immediately after. But, yeah, there's no reason not to introduce it directly in its final form; I think it's an artifact of reordering the patches a few times...
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140952
On Thu May 21 09:07:05 2026 +0000, Rémi Bernon wrote:
I'm also not sure we want to add a registry option for that, especially if the behavior is enabled by default. We only need options to disable behavior if they are known to be problematic and difficult to fix. If the new behavior is known to cause problems already we should try to fix it before it gets introduced. Okay, fair enough.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140951
On Thu May 21 10:58:37 2026 +0000, Matteo Bruni wrote:
I have a couple of patches switching this to the new layout infrastructure immediately after. But, yeah, there's no reason not to introduce it directly in its final form; I think it's an artifact of reordering the patches a few times... I merged the latter patches into these, it certainly makes more sense now. It still indirectly depends on `main_key_tab[kbd_layout]` though, so I think I'm going to delay these patches after all. Which is probably what you meant anyway :sweat_smile:
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10963#note_140958
participants (3)
-
Matteo Bruni -
Matteo Bruni (@Mystral) -
Rémi Bernon (@rbernon)