Bug 484439

Summary: Regression with Alt+Shift layout switching
Product: [Plasma] kwin Reporter: Kirill Zhumarin <kirill.zhumarin>
Component: inputAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: dev, fanzhuyifan, oded
Priority: NOR    
Version: 6.0.2   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Kirill Zhumarin 2024-03-25 09:10:01 UTC
SUMMARY
It is impossible to normally use `Alt+Shift`.

STEPS TO REPRODUCE
1. Add 2+ input layouts.
2. Enable `Input devices` -\> `Keyboard` -\> `Advanced` -\> `Switching to another layout` -\> `[x] Alt+Shift`

OBSERVED RESULT
1. Press `Alt`
2. Press `Shift`
3. Release ONLY `Alt`
4. Try to type text. Typed text is lowercase, `Shift` is ignored.

EXPECTED RESULT
1. Press `Alt`
2. Press `Shift`
3. Release ONLY `Alt`
4. Try to type text. Typed text is uppercase.

SOFTWARE/OS VERSIONS
Bug is present in both Plasma 5 and Plasma 6.

ADDITIONAL INFORMATION
Comment 1 Kirill Zhumarin 2024-03-25 09:11:27 UTC
Workaround: https://github.com/Azq2/alt-shift-kbd-layout-switcher
Comment 2 Kirill Zhumarin 2024-03-25 09:14:22 UTC
P.S. In Unity, GNOME, Windows works fine.
Comment 3 fanzhuyifan 2024-03-27 16:24:10 UTC
Can reproduce on wayland, git build. This only happens when Alt is pressed before Shift.
Comment 4 fanzhuyifan 2024-03-27 16:49:22 UTC
I can also reproduce this on x11. So I think this is an upstream xkb issue.
Comment 5 fanzhuyifan 2024-03-27 17:38:48 UTC
(In reply to fanzhuyifan from comment #4)
> I can also reproduce this on x11. So I think this is an upstream xkb issue.

I confirmed that I can also reproduce this on XFCE, with a command like `setxkbmap -layout rs,rs,us,de -variant latin,,dvp, -option 'grp:alt_shift_toggle'`

So please report this issue to xkb.
Comment 6 Wismill 2024-04-12 10:20:23 UTC
This is another occurrence of the infamous “need to kick hotkeys on release, not press” (see: https://gitlab.freedesktop.org/xorg/xserver/-/issues/258). This is not a bug per se, but a known limitation of the XKB protocol.
Comment 7 Oded Arbel 2024-06-14 10:28:39 UTC
(In reply to Wismill from comment #6)
> This is another occurrence of the infamous “need to kick hotkeys on release,
> not press” (see: https://gitlab.freedesktop.org/xorg/xserver/-/issues/258).
> This is not a bug per se, but a known limitation of the XKB protocol.

With Plasma 6.1 this is no longer a problem - if you stop using the XKB configuration grp:alt_shift_toggle and instead use the KDE "alternative shortcut" that can now be configured to be Alt+Shift. With that configuration the repro looks like this:
1. Set up 2+ input layouts
2. Clear "main shorcuts" and set up "alternative shortcut" to "Alt+Shift".
3. Go to a text editor - hold [Alt]; hold [Shift]; release [Alt]; start typing

Observerd result:
The text is typed using the second layout's 2nd level. For example for me the second layout is Hebrew, whose 2nd level is Latin caps so typing produces uppercase English.
Comment 8 Kirill Zhumarin 2024-06-14 12:12:27 UTC
(In reply to Wismill from comment #6)
> This is another occurrence of the infamous “need to kick hotkeys on release,
> not press” (see: https://gitlab.freedesktop.org/xorg/xserver/-/issues/258).
> This is not a bug per se, but a known limitation of the XKB protocol.

Any reasons why broken XCB is still used for layout switching? This can be implemented on the KDE side.
Comment 9 Kirill Zhumarin 2024-06-14 12:15:16 UTC
Oh, sorry, I mean XKB, not XCB :)
Comment 10 Oded Arbel 2024-06-14 12:31:35 UTC
(In reply to Kirill Zhumarin from comment #8)
> Any reasons why broken XCB is still used for layout switching? This can be
> implemented on the KDE side.

As noted in comment #7, using the xkb configuration is optional and with Plasma 6.1 is no longer necessary to have modifier only layout switching shortcuts.

I believe the XKB configuration is still useful for some users - especially on X11 - so I don't expect support for it in the Plasma keyboard KCM will be removed anytime soon, but if people use the new "alternative shortcut" configuration and find generally better, we may be able to make that the primary configuration and relegate the XKB configuration to a "legacy" status.

The main feature I expect people will still want to use the XKB configuration for is that it can have multiple different shortcuts for laytout switching, and some finer behaviors then just "next layout", "last layout".