keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
21.06k stars 1.46k forks source link

auto-type ignores xkeyboard layout #8966

Open padrm opened 1 year ago

padrm commented 1 year ago

Hello,

xkb_layout is 'fr' (see /var/log/Xorg.0.log extract below) but is ignored by the auto-type.

For example: the word azerty will be typed qwerty.

2.6.6 version works as expected.

Best regards

/var/log/Xorg.0.log: [ 11.995] (II) XINPUT: Adding extended input device "AT Translated Set 2 keyboard" (type: KEYBOARD, id 14) [ 11.995] (**) Option "xkb_model" "pc105" [ 11.995] (**) Option "xkb_layout" "fr" [ 11.995] (**) Option "xkb_variant" "oss_latin9" [ 11.995] (**) Option "xkb_options" "compose:lwin,ctrl:nocaps"

[NOTE]: KeePassXC - Version 2.7.4 Revision: 63b2394

Qt 5.15.7 Debugging mode is disabled.

Operating system: Debian GNU/Linux bookworm/sid CPU architecture: x86_64 Kernel: linux 6.0.0-6-amd64

Enabled extensions:

Cryptographic libraries:

maximilian-walter commented 1 year ago

I can reproduce this error, also on Debian Sid using Gnome 43.2 (X11) and KeePassXC 2.7.4 (installed directly from the Debian package repository).

Auto-Type does not work properly if the keyboard layout is not english (US). Im using a german layout and in my case, auto-type replaces an ^ with an &.

If I copy the password to the clipboard (via right click -> "Copy password" instead of "Perform Auto-Type"), or if I change the keyboard layout to english, everything works fine.

stefan123t commented 1 year ago

@maximilian-walter can you provide some more details on your keyboard settings ? e.g. this is my localectl status

$ localectl status
   System Locale: LANG=en_US.UTF-8
                  LC_NUMERIC=de_DE.UTF-8
                  LC_MONETARY=de_DE.UTF-8
                  LC_PAPER=de_DE.UTF-8
                  LC_NAME=de_DE.UTF-8
                  LC_ADDRESS=de_DE.UTF-8
                  LC_TELEPHONE=de_DE.UTF-8
                  LC_MEASUREMENT=de_DE.UTF-8
                  LC_IDENTIFICATION=de_DE.UTF-8
       VC Keymap: n/a
      X11 Layout: us
       X11 Model: pc105

and my setxkbmap layout

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     de,us
variant:    ,
options:    grp:lalt_lshift_toggle

You may find some more debug details which helped to sort the actual setup / config out in the past in #6247, #6350 and the mother of IMHO all keyboard layout issues #324 so far.

I wonder whether it also has something to do with keyboard layouts and dead-keys #7881 and #7610 ?

maximilian-walter commented 1 year ago

@stefan123t Here is the output of the two commands:

$ localectl status
System Locale: LANG=de_DE.UTF-8
    VC Keymap: (unset)         
   X11 Layout: de
    X11 Model: pc105
$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     de,us
variant:    ,

And all LC_* variables:

$ locale
LANG=de_DE.UTF-8
LANGUAGE=
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES=en_US.UTF-8
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=
stefan123t commented 1 year ago

@maximilian-walter can you check the following hint https://github.com/keepassxreboot/keepassxc/issues/324#issuecomment-540927948 about primary and secondary keyboards in your setup ?

Apparently your primary keyboard is X11 Layout: de whereas mine is X11 Layout: us.

@hifi maybe we need some changes in case the primary keyboard is not us or uk, i.e. english because then the keycodes to use on a non-english keyboard might be different / opposite to what we have in the code which is keycodes on english keyboard to type non-english characters on a non-english layout ?

BTW: I have been using the xkblayout tool suggested by @frostasm to verify the currently used / set keyboard layout in the past: https://github.com/keepassxreboot/keepassxc/issues/324#issuecomment-743998173

maximilian-walter commented 1 year ago

@stefan123t What should I check exactly? The bug is definitely related to the keyboard layout, because with us layout auto-type works fine:

Auto-Type does not work properly if the keyboard layout is not english (US). Im using a german layout and in my case, auto-type replaces an ^ with an &.

eitch commented 1 year ago

The same is true for me: Using a US keyboard layout all is fine, but when using Swiss German, it does not work anymore.

eitch commented 1 year ago

Can i sponsor this issue? I know of a few people quite annoyed by it, who might also be willing to do some sponsoring @rbreitenmoser

droidmonkey commented 1 year ago

We would prefer code submissions

stefan123t commented 1 year ago

@maximilian-walter @eitch it is definitely clear that it is related to the keyboard and locale settings of your OS, environment, X11/Wayland, Xsession and Desktop environment. As you see these are a lot of variables and it is hard for both us and KeePassXC to determine what the current state of your settings are at a specific point in time, ie especially when hitting auto-type. This could even differ between windows! Probably the best would be to compile the code I referenced in the second comment above and try several combinations of primary and secondary keyboard layouts. As I recall from the first comment referenced above the problem was solved for primary keyboard us and secondary anything else. I believe we tested even with a third keyboard layout too. But we did not test with primary something else than english / us as a primary keyboard and us as secondary. You can make auto-type tests into a notepad window by setting up a dummy example entry in KeepassXC to reproduce as stated in my comment.