Bug 448377 - Everything broke recently in Keyboard layouts land
Summary: Everything broke recently in Keyboard layouts land
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_keyboard (show other bugs)
Version: master
Platform: Other Linux
: VHI normal
Target Milestone: ---
Assignee: Fabian Vogt
URL:
Keywords: regression
: 448456 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-01-13 17:52 UTC by ratijas
Modified: 2022-01-15 21:36 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
My broken config which I haven't modified directly (385 bytes, text/plain)
2022-01-13 17:52 UTC, ratijas
Details
Screenshot of «Keyboard Layout» applet with grp:win_space_toggle instead of English (41.64 KB, image/png)
2022-01-13 18:01 UTC, ratijas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ratijas 2022-01-13 17:52:12 UTC
Created attachment 145420 [details]
My broken config which I haven't modified directly

SUMMARY

It's hard to pick one particular thing that stopped working, or even tell if that's one huge thing or a combination of smaller bugs in various subsystems.

My usual setup (attached as a file) includes the following settings:

- 2 keyboard layouts: English and Russian.
- Meta+Space (aka Win+Space aka Cmd+Space call it whatever) to switch two layouts.
- OSD on layout change is enabled (a popup with current layout's name and icon, just like for volume and brightness).
- CapsLock acts as a Ctrl (but not vice-versa).
- Compose key is mapped to Pause key.

First, the OSD broke. It stopped showing up a while ago (like, a half year or so). It painful, since I lost ability to quickly tap Meta+Space twice to check my current keyboard language in full-screen apps where Plasma panel and system tray are not visible.

At some point, Meta+Space shortcut stopped working. At the same time, English layout got "renamed" in sys-tray «Keyboard Layout» applet to «grp:win_space_toggle» which turns out to be one of the xkb option. Earlier this year I had similar issue where English layout similarly got renamed as «compose:paus». I have no idea how or when I was resolved last time.

At this point, switching layouts is broken, but special buttons are still remapped just fine. I had to turn on an alternative shortcut for switching layouts (namely, Alt+Shift which also messed up / clashed with some most important shortcuts in my daily text editor).

After a brief discussion in KDE Development chat, I tried removing `VariantList=,` option and re-comfigure / reboot -- it didn't help.

Next thing I tried is yeeting ~/.config/kxkbrc completely to start from scratch. Here are some observation I made before reverting an old config:

+ Spelling of English (US) layout got back to normal. No more inappropriate compose:paus or grp:win_space_toggle options in the list.
+ Meta+Space works again.
- Can't remap Ctrl and CapsLock.
- Neither does Compose key.
- In fact, none of the settings in the "Advanced" tab apply. Which means, the layout is unusable for me (I used to press CapsLock as if it were Ctrl, and now my muscle memory is playing against me).

STEPS TO REPRODUCE

Unknown.

OBSERVED RESULT

Everything is LiTeRaLlY UnUsAbLe.

EXPECTED RESULT

Everything should work as normal.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.80
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.2
Kernel Version: 5.15.13-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 970M/PCIe/SSE2

ADDITIONAL INFORMATION
Comment 1 ratijas 2022-01-13 18:01:32 UTC
Created attachment 145421 [details]
Screenshot of «Keyboard Layout» applet with grp:win_space_toggle instead of English

With this semi-broken config I get these results:

>    $ setxkbmap -query
>    rules:      evdev
>    model:      pc104
>    layout:     us,ru
>    variant:    grp:win_space_toggle
>    options:    compose:paus,ctrl:nocaps,grp:alt_shift_toggle

And the «Keyboard Layout» applet looks like this (with its context menu): ugh… actually, see the attached screenshot.
Comment 2 ratijas 2022-01-13 18:36:27 UTC
A magical "fix" to all these problems at once:

Set English layout's variant to something other than empty/default one. For example, «English (Macintosh)» will do.

As a result:

- Spelling of the layout is fixed in applet, at lock screen, and in `setxkbmap -query`
- Meta+Space shortcut works again.

Conclusion: something is lost along the lines when parsing config with an empty `VariantList=,` record.

It's almost like if it consumes the next line instead on stopping at the \n, except the `VariantList` is on the last line in my config, so this theory does not hold water. Other possible scenario might be some kind of memory leak or out-of-bounds access. In any case, the kxkb subsystem is clearly the culprit here, and KCM code couldn't do much about it.
Comment 3 Bug Janitor Service 2022-01-13 22:01:24 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/797
Comment 4 Fabian Vogt 2022-01-13 22:02:18 UTC
The first attachment is the broken config you got directly after starting 5.23.80 for the first time, right?

It looks fine to me, and should result in these settings:
Layouts: us,ru
(no variants)
Options: compose:paus,grp:win_space_toggle,ctrl:nocaps,grp:alt_shift_toggle

I have a suspicion what the issue might be and submitted a possible fix: https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/797

Can you give it a try?
Comment 5 ratijas 2022-01-13 22:35:02 UTC
> The first attachment is the broken config you got directly after starting 5.23.80 for the first time, right?

I'm living on git-master since ~about October; and before that I used normal Arch Linux rolling release. The config has just migrated on its own or something, idk, I only learned about its existence today.

> Can you give it a try?

Will do now. Hopefully, my yesterday's build is fresh enough :)
I'll use that merge request's page for further comments and discussions about it.
Comment 6 Bug Janitor Service 2022-01-14 15:44:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/800
Comment 7 ratijas 2022-01-15 07:40:25 UTC
*** Bug 448456 has been marked as a duplicate of this bug. ***
Comment 8 Fabian Vogt 2022-01-15 21:26:36 UTC
Git commit 6ea241704c486260e870ddd26b6c666ccc6ef634 by Fabian Vogt.
Committed on 15/01/2022 at 21:22.
Pushed by fvogt into branch 'master'.

[kcms/keyboard] Fix setting more than one option

Instead of passing the ,-delimited list of options to setkbmap's -option
option, it appended each list element, leading to e.g. -option foo:bar as:df.

The setxkbmap man page says that each option should be passed separately
anyway, so change the code to do that.

M  +3    -2    kcms/keyboard/xkb_helper.cpp

https://invent.kde.org/plasma/plasma-desktop/commit/6ea241704c486260e870ddd26b6c666ccc6ef634
Comment 9 Fabian Vogt 2022-01-15 21:36:40 UTC
Git commit de2fdda9eb3f97a249f0930c10d96970ab8510d5 by Fabian Vogt.
Committed on 15/01/2022 at 21:36.
Pushed by fvogt into branch 'Plasma/5.24'.

[kcms/keyboard] Fix setting more than one option

Instead of passing the ,-delimited list of options to setkbmap's -option
option, it appended each list element, leading to e.g. -option foo:bar as:df.

The setxkbmap man page says that each option should be passed separately
anyway, so change the code to do that.
(cherry picked from commit 6ea241704c486260e870ddd26b6c666ccc6ef634)

M  +3    -2    kcms/keyboard/xkb_helper.cpp

https://invent.kde.org/plasma/plasma-desktop/commit/de2fdda9eb3f97a249f0930c10d96970ab8510d5