Skip to content

xkb *_Latch key doesn’t work well on Wayland #1301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ariasuni opened this issue Mar 20, 2025 · 8 comments
Open

xkb *_Latch key doesn’t work well on Wayland #1301

ariasuni opened this issue Mar 20, 2025 · 8 comments

Comments

@ariasuni
Copy link

ariasuni commented Mar 20, 2025

Summary

Ergo-L (fr-ergol) uses a key as ISO_Level5_Latch, which works as both as either a modifier (if pressed and maintained at the same time as another key) or a dead key (if pressed and released before hitting another key).

But with fcitx enabled, it doesn’t work as expected, in Wayland applications (works in Electron apps using XWayland).

(same issue than phuang/ibus#26 but with slightly different behavior)

Steps to Reproduce

  1. Configure fcitx with Ergo-L as keyboard layout.
  2. Try to hit the “typo” key (o in qwerty) and another letter (e.g. s or q, which are in the same position as qwerty, or e which is d in qwerty)

Expected Behavior

Normally, in Ergo-L only:

  • typo then s = é
  • typo then q = â
  • typo then typo = dead_diaeresis .
  • typo then typo then e = ë.

With GTK applications, pressing and releasing typo becomes dead_diaeresis with preedit (¨):

  • typo then s = ¨s, typo maintained and s = ¨é
  • typo then q = ¨q, typo maintained and q = ¨â
  • typo then e = ë, typo maintained and e = ¨è
  • typo then typo then e then e then e = ë¨ëe.

With Qt applications, pressing and releasing typo becomes dead_diaeresis like with GTK, but without the preedit for (¨):

  • typo then s = s (typo maintained works correctly)
  • typo then q = q (typo maintained works correctly)
  • typo then e = ë (typo maintained works correctly)
  • typo then typo then e = ë (in this case, the preedit appears)
  • typo then typo then e then e then e = ëëe.

Output of fcitx5-diagnose command

click here

# System Info:
1.  `uname -a`:

        Linux potipat 6.13.7-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Thu, 13 Mar 2025 18:11:42 +0000 x86_64 GNU/Linux

2.  `lsb_release -a`:

        LSB Version:	n/a
        Distributor ID:	Arch
        Description:	Arch Linux
        Release:	rolling
        Codename:	n/a

3.  `lsb_release -d`:

        Description:	Arch Linux

4.  `/etc/lsb-release`:

        DISTRIB_ID="Arch"
        DISTRIB_RELEASE="rolling"
        DISTRIB_DESCRIPTION="Arch Linux"

5.  `/etc/os-release`:

        NAME="Arch Linux"
        PRETTY_NAME="Arch Linux"
        ID=arch
        BUILD_ID=rolling
        ANSI_COLOR="38;2;23;147;209"
        HOME_URL="https://archlinux.org/"
        DOCUMENTATION_URL="https://wiki.archlinux.org/"
        SUPPORT_URL="https://bbs.archlinux.org/"
        BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
        PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
        LOGO=archlinux-logo

6.  Desktop Environment:

    Desktop environment is `kde`.

7.  XDG SESSION TYPE:

        XDG_SESSION_TYPE='wayland'

8.  Bash Version:

        BASH_VERSION='5.2.37(1)-release'

# Environment:
1.  DISPLAY:

        DISPLAY=':1'


        WAYLAND_DISPLAY='wayland-0'

2.  Keyboard Layout:

    1.  `setxkbmap`:

            WARNING: Running setxkbmap against an Xwayland server
            xkb_keymap {
            	xkb_keycodes  { include "evdev+aliases(azerty)"	};
            	xkb_types     { include "complete"	};
            	xkb_compat    { include "complete"	};
            	xkb_symbols   { include "pc+fr(ergozl)+inet(evdev)+compose(menu)"	};
            	xkb_geometry  { include "pc(pc105)"	};
            };

    2.  `xprop`:

            _XKB_RULES_NAMES(STRING) = "evdev", "pc105", "fr", "ergozl", "compose:menu"

3.  Locale:

    1.  All locales:

            C
            C.utf8
            en_US.utf8
            fr_FR.utf8
            POSIX

    2.  Current locale:

            LANG=fr_FR.UTF-8
            LC_CTYPE="fr_FR.UTF-8"
            LC_NUMERIC=fr_FR.UTF-8
            LC_TIME=fr_FR.UTF-8
            LC_COLLATE="fr_FR.UTF-8"
            LC_MONETARY=fr_FR.UTF-8
            LC_MESSAGES="fr_FR.UTF-8"
            LC_PAPER=fr_FR.UTF-8
            LC_NAME=fr_FR.UTF-8
            LC_ADDRESS=fr_FR.UTF-8
            LC_TELEPHONE=fr_FR.UTF-8
            LC_MEASUREMENT=fr_FR.UTF-8
            LC_IDENTIFICATION="fr_FR.UTF-8"
            LC_ALL=

4.  Directories:

    1.  Home:

            /home/ariasuni

    2.  `${XDG_CONFIG_HOME}`:

        Environment variable `XDG_CONFIG_HOME` is not set.

        Current value of `XDG_CONFIG_HOME` is `~/.config` (`/home/ariasuni/.config`).

    3.  Fcitx5 Settings Directory:

        Current fcitx5 settings directory is `~/.config/fcitx5` (`/home/ariasuni/.config/fcitx5`).

5.  Current user:

    The script is run as ariasuni (1000).

# Fcitx State:
1.  executable:

    Found fcitx5 at `/usr/bin/fcitx5`.

2.  version:

    Fcitx version: `5.1.12`

3.  process:

    Found 2 fcitx5 processes:

          76475 fcitx5-wayland-
          76477 fcitx5

4.  `fcitx5-remote`:

    `fcitx5-remote` works properly.

5.  DBus interface:

    Using `dbus-send` to check dbus.

    Owner of DBus name `org.fcitx.Fcitx5` is `:1.429`.

    PID of DBus name `org.fcitx.Fcitx5` owner is `76477`.

    Debug information from dbus:

           Group [x11::1] has 0 InputContext(s)
        Group [wayland:] has 3 InputContext(s)
          IC [6b35fec3566244ef8122fc21ba73ac07] program:org.kde.konsole frontend:wayland cap:72 focus:1
          IC [ee4e5597ac57404eb07f74bb9b6e8394] program:systemsettings frontend:wayland cap:72 focus:0
          IC [3401b7986d53438b96314e4e5b7d91af] program: frontend:wayland cap:72 focus:0
        Input Context without group

# Frontends setup:
The environment variable checked by this script only shows the environment under current shell. It is still possible that you did not set the environment to the whole graphic desktop session. You may inspect the actual environment variable of a certain process by using `xargs -0 -L1 /proc/$PID/environ` for a certain process that you find not working.

## Xim:
1.  `${XMODIFIERS}`:

    **XMODIFIERS is not set**

    **Please set environment variable XMODIFIERS to "@im=fcitx" using the tool your distribution provides or add `export XMODIFIERS=@im=fcitx` to your `~/.xprofile`. See [Input Method Related Environment Variables: XMODIFIERS](http://fcitx-im.org/wiki/Input_method_related_environment_variables#XMODIFIERS).**
    Xim Server Name from Environment variable is fcitx.

2.  XIM_SERVERS on root window:

    Xim server name is the same with that set in the environment variable.

## Qt:
1.  qt4 - `${QT4_IM_MODULE}`:

    **Please set environment variable QT_IM_MODULE to "fcitx" using the tool your distribution provides or add `export QT_IM_MODULE=fcitx` to your `~/.xprofile`. See [Input Method Related Environment Variables: QT_IM_MODULE](http://fcitx-im.org/wiki/Input_method_related_environment_variables#QT_IM_MODULE).**

    **`fcitx5-qt4-immodule-probing` not found.**

2.  qt5 - `${QT_IM_MODULE}`:

    **Please set environment variable QT_IM_MODULE to "fcitx" using the tool your distribution provides or add `export QT_IM_MODULE=fcitx` to your `~/.xprofile`. See [Input Method Related Environment Variables: QT_IM_MODULE](http://fcitx-im.org/wiki/Input_method_related_environment_variables#QT_IM_MODULE).**

    **It is OK to use qt5 built-in Wayland im module if your compositor fully supports text-input protocol used by qt5.**

    Using fcitx5-qt5-immodule-probing to check the actual im module to be used under current environment:

        QT_QPA_PLATFORM=wayland
        QT_IM_MODULE=
        IM_MODULE_CLASSNAME=QtWaylandClient::QWaylandInputContext

3.  qt6 - `${QT_IM_MODULE}`:

    **Please set environment variable QT_IM_MODULE to "fcitx" using the tool your distribution provides or add `export QT_IM_MODULE=fcitx` to your `~/.xprofile`. See [Input Method Related Environment Variables: QT_IM_MODULE](http://fcitx-im.org/wiki/Input_method_related_environment_variables#QT_IM_MODULE).**

    **It is OK to use qt6 built-in Wayland im module if your compositor fully supports text-input protocol used by qt6.**

    Using fcitx5-qt6-immodule-probing to check the actual im module to be used under current environment:

        QT_QPA_PLATFORM=wayland
        QT_IM_MODULE=
        IM_MODULE_CLASSNAME=QtWaylandClient::QWaylandInputContext

4.  Qt IM module files:

    Found fcitx5 qt5 module: `/usr/lib/fcitx5/qt5/libfcitx-quickphrase-editor5.so`.
    Found fcitx5 qt6 module: `/usr/lib/fcitx5/qt6/libfcitx-quickphrase-editor5.so`.
    Found fcitx5 im module for qt: `/usr/lib/qt/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so`.
    Found unknown fcitx qt module: `/usr/lib/qt6/plugins/plasma/kcms/systemsettings/kcm_fcitx5.so`.
    Found fcitx5 im module for qt6: `/usr/lib/qt6/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so`.

    Following error may not be accurate because guessing Qt version from path depends on how your distribution packages Qt. It is not a critical error if you do not use any Qt application with certain version of Qt or you are using text-input support by Qt under Wayland.
    **Cannot find fcitx5 input method module for Qt4.**

## Gtk:
1.  gtk - `${GTK_IM_MODULE}`:

    **Please set environment variable GTK_IM_MODULE to "fcitx" using the tool your distribution provides or add `export GTK_IM_MODULE=fcitx` to your `~/.xprofile`. See [Input Method Related Environment Variables: GTK_IM_MODULE](http://fcitx-im.org/wiki/Input_method_related_environment_variables#GTK_IM_MODULE).**

    **It is OK to use gtk built-in Wayland im module if your compositor fully supports text-input protocol used by gtk.**

    Using fcitx5-gtk2-immodule-probing to check the actual im module to be used under current environment:

        GTK_IM_MODULE=cedilla

    Using fcitx5-gtk3-immodule-probing to check the actual im module to be used under current environment:

        GTK_IM_MODULE=wayland

    Using fcitx5-gtk4-immodule-probing to check the actual im module to be used under current environment:

        GTK_IM_MODULE=wayland

2.  `gtk-query-immodules`:

    1.  gtk 2:

        Found `gtk-query-immodules` for gtk `2.24.33` at `/usr/bin/gtk-query-immodules-2.0`.
        Version Line:

            # Created by /usr/bin/gtk-query-immodules-2.0 from gtk+-2.24.33

        Found fcitx5 im modules for gtk `2.24.33`.

            "/usr/lib/gtk-2.0/2.10.0/immodules/im-fcitx5.so" 
            "fcitx" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 
            "fcitx5" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 

        Found `gtk-query-immodules` for gtk `2.24.33` at `/usr/bin/gtk-query-immodules-2.0-32`.
        Version Line:

            # Created by /usr/bin/gtk-query-immodules-2.0-32 from gtk+-2.24.33

        **Failed to find fcitx5 in the output of `/usr/bin/gtk-query-immodules-2.0-32`**

    2.  gtk 3:

        Found `gtk-query-immodules` for gtk `3.24.49` at `/usr/bin/gtk-query-immodules-3.0`.
        Version Line:

            # Created by /usr/bin/gtk-query-immodules-3.0 from gtk+-3.24.49

        Found fcitx5 im modules for gtk `3.24.49`.

            "/usr/lib/gtk-3.0/3.0.0/immodules/im-fcitx5.so" 
            "fcitx" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 
            "fcitx5" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 

3.  Gtk IM module cache:

    1.  gtk 2:

        Found immodules cache for gtk `2.24.33` at `/usr/lib/gtk-2.0/2.10.0/immodules.cache`.
        Version Line:

            # Created by /usr/bin/gtk-query-immodules-2.0 from gtk+-2.24.33

        Found fcitx5 im modules for gtk `2.24.33`.

            "/usr/lib/gtk-2.0/2.10.0/immodules/im-fcitx5.so" 
            "fcitx" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 
            "fcitx5" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 

        Found immodules cache for gtk `2.24.33` at `/usr/lib32/gtk-2.0/2.10.0/immodules.cache`.
        Version Line:

            # Created by /usr/bin/gtk-query-immodules-2.0-32 from gtk+-2.24.33

        **Failed to find fcitx5 in immodule cache at `/usr/lib32/gtk-2.0/2.10.0/immodules.cache`**

    2.  gtk 3:

        Found immodules cache for gtk `3.24.49` at `/usr/lib/gtk-3.0/3.0.0/immodules.cache`.
        Version Line:

            # Created by /usr/bin/gtk-query-immodules-3.0 from gtk+-3.24.49

        Found fcitx5 im modules for gtk `3.24.49`.

            "/usr/lib/gtk-3.0/3.0.0/immodules/im-fcitx5.so" 
            "fcitx" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 
            "fcitx5" "Fcitx5 (Flexible Input Method Framework5)" "fcitx5" "/usr/locale" "ja:ko:zh:*" 

4.  Gtk IM module files:

    1.  gtk 2:

        All found Gtk 2 immodule files exist.

    2.  gtk 3:

        All found Gtk 3 immodule files exist.

    3.  gtk 4:

        All found Gtk 4 immodule files exist.

# Configuration:
## Fcitx Addons:
1.  Addon Config Dir:

    Found fcitx5 addon config directory: `/usr/share/fcitx5/addon`.

2.  Addon List:

    1.  Found 21 enabled addons:

            Classic User Interface 5.1.12
            Clipboard 5.1.12
            DBus 5.1.12
            DBus Frontend 5.1.12
            Emoji 5.1.12
            Fcitx4 Frontend 5.1.12
            IBus Frontend 5.1.12
            Input method selector 5.1.12
            Keyboard 5.1.12
            KDE Input Method Panel 5.1.12
            Mozc 
            Status Notifier 5.1.12
            Notification 5.1.12
            Quick Phrase 5.1.12
            Spell 5.1.12
            Unicode 5.1.12
            DBus Virtual Keyboard 5.1.12
            Wayland 5.1.12
            Wayland Input method frontend 5.1.12
            XCB 5.1.12
            X Input Method Frontend 5.1.12

    2.  Found 0 disabled addons:

3.  Addon Libraries:

    All libraries for all addons are found.

4.  User Interface:

    Found 3 enabled user interface addons:

        Classic User Interface
        KDE Input Method Panel
        DBus Virtual Keyboard

## Input Methods:
1.  `/home/ariasuni/.config/fcitx5/profile`:

        [Groups/0]
        # Group Name
        Name="Groupe 1"
        # Layout
        Default Layout=fr-ergozl
        # Default Input Method
        DefaultIM=keyboard-fr-ergozl

        [Groups/0/Items/0]
        # Name
        Name=mozc
        # Layout
        Layout=

        [Groups/0/Items/1]
        # Name
        Name=keyboard-fr-ergozl
        # Layout
        Layout=

        [Groups/0/Items/2]
        # Name
        Name=keyboard-fr-bepo_afnor
        # Layout
        Layout=

        [Groups/0/Items/3]
        # Name
        Name=keyboard-fr-oss
        # Layout
        Layout=

        [Groups/0/Items/4]
        # Name
        Name=keyboard-us
        # Layout
        Layout=

        [GroupOrder]
        0="Groupe 1"

# Log:
1.  `date`:

        jeu. 20 mars 2025 18:54:57 CET

2.  `/home/ariasuni/.config/fcitx5/crash.log`:

    `/home/ariasuni/.config/fcitx5/crash.log` not found.

@ariasuni ariasuni changed the title xkb *_Latch key (e.g. ISO_Level5_Latch) doesn’t work well xkb *_Latch key (e.g. ISO_Level5_Latch) doesn’t work well on Wayland Mar 20, 2025
@ariasuni ariasuni changed the title xkb *_Latch key (e.g. ISO_Level5_Latch) doesn’t work well on Wayland xkb *_Latch key doesn’t work well on Wayland Mar 20, 2025
@wengxt
Copy link
Member

wengxt commented Mar 21, 2025

Please paste fcitx5-diagnose.

Setting xkb layout from fcitx5 is only supported under certain wayland desktop

@ariasuni
Copy link
Author

I pasted it, it’s hidden you have to click on “click here” (I can edit my post to unhide it if you prefer).

@wengxt
Copy link
Member

wengxt commented Mar 21, 2025

@ariasuni one thing I don't get is that there is no "ergozl" in xkeyboard-config (arch's current version 2.44). How did you configured that in fcitx? are you using fcitx5-configtool to do it?

Are you using a custom xkb config?

$ grep ergo /usr/share/X11/xkb/rules/evdev.xml
            <name>ergol</name>
            <name>ergol_iso</name>
            <name>ergonomic</name>
            <description>Georgian (ergonomic)</description>
            <name>ergonomic</name>
            <description>Latvian (ergonomic, ŪGJRMV)</description>

I can only see "ergol"

@ariasuni
Copy link
Author

Ergo-ZL is my personal variant of Ergo-L, I tested with Ergo-L and the bug is exactly the same.

@wengxt
Copy link
Member

wengxt commented Mar 21, 2025

which key is latch level 5?

I ran kbd-layout-viewer5 (from fcitx5-configtool) and didn't see it has latch level 5.

do you need a specific xkb option to enable level 5 key ?

@wengxt
Copy link
Member

wengxt commented Mar 22, 2025

ah, I think somehow latch level 5 is very special on this layout so it was not shown as I expected.

In both case, the key on fcitx side are the same, however, it is wrong on the app side.

I think the main issue is the inconsistent modifier state on fcitx side and app side.

Latch modifier was reset before input method reinject the unhandled key.

so that's why there's such inconsistency.

I think I have seen a different issue before, though, unfortunately, to fix it would require effort from both fcitx and compositor side.

Without fcitx:
[ 538326.240] {Default Queue} wl_keyboard#26.key(32930, 141711283, 24, 1)
[ 538431.704] {Default Queue} wl_keyboard#26.modifiers(32932, 0, 32, 0, 0)
[ 538433.516] {Default Queue} wl_keyboard#26.key(32934, 141711283, 24, 0)
[ 539997.035] {Default Queue} wl_keyboard#26.modifiers(32936, 0, 0, 0, 0)  <--------------------
[ 539998.725] {Default Queue} wl_keyboard#26.key(32938, 141711283, 18, 1)
[ 540118.440] {Default Queue} wl_keyboard#26.key(32940, 141711283, 18, 0)

With fcitx:
[ 584619.898] {Default Queue} wl_keyboard#26.key(33124, 141761642, 24, 0)
[ 584619.961] {Default Queue} wl_keyboard#26.modifiers(33125, 0, 32, 0, 0) <--------------------
[ 586399.265] {Default Queue} wl_keyboard#26.key(33126, 141763421, 18, 1)
[ 586399.347] {Default Queue} wl_keyboard#26.modifiers(33127, 0, 0, 0, 0)

@wengxt
Copy link
Member

wengxt commented Mar 22, 2025

I opened a bug on kwin side: https://invent.kde.org/plasma/kwin/-/issues/272

@wengxt
Copy link
Member

wengxt commented Mar 22, 2025

Issue before that has the same cause: #893

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants