Bug 348198 - xkb keymap reset when external keyboard plugged in
Summary: xkb keymap reset when external keyboard plugged in
Status: RESOLVED FIXED
Alias: None
Product: kxkb
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Kubuntu Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Andriy Rysin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-25 08:31 UTC by chris.taylor
Modified: 2019-06-04 14:22 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Initial state of xkb keymap with required layouts. (355 bytes, text/plain)
2015-05-25 08:34 UTC, chris.taylor
Details
X.org log (41.75 KB, text/x-log)
2015-09-24 13:52 UTC, Marcus Better
Details

Note You need to log in before you can comment on or make changes to this bug.
Description chris.taylor 2015-05-25 08:31:27 UTC
When I plug in an external keyboard, the xkb keymap is reset so that keyboard layout switching is disabled.

Results from setxkbmap -print will follow this bug report.

Possibly a regression, or duplicate of #295438.

Reproducible: Always

Steps to Reproduce:
1. Plug in external keyboard.


Actual Results:  
1. Attempt to switch keyboard layouts (using keyboard shortcut or system tray). No change.
2. Load keyboard layout config. Make random change and apply.
3. Keyboard switching occurs again.

Expected Results:  
Keyboard switching remains working.

Might be duplicate of apparently resolved bug 295438.

Results from setxkbmap -print to follow.
Comment 1 chris.taylor 2015-05-25 08:34:04 UTC
Created attachment 92814 [details]
Initial state of xkb keymap with required layouts.

Initial state of xkb keymap with required layouts.
Comment 2 chris.taylor 2015-05-25 08:36:18 UTC
(Sorry, I'll print the outputs below instead of attaching them...)

Initial state of xkb keymap with required layouts:
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+gb+gr:2+il(biblicalSIL):3+inet(evdev)+group(alt_shift_toggle)+compose(paus)+nbsp(none)"  };
        xkb_geometry  { include "pc(pc101)"     };
};

Final state of xkb keymap after plugging in external keyboard:
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+gb+inet(evdev)"     };
        xkb_geometry  { include "pc(pc105)"     };
};
Comment 3 Marcus Better 2015-09-24 13:51:33 UTC
I have the same problem. KDE framework 5.14.0, Plasma 5.4.1, Debian.

Here is .xsession-errors after unplugging and re-plugging an external USB keyboard with US layout:

### now unplugging keyboard

Solid::Backends::UDev::input_str_to_bitmask can't handle some bits ("2a0", "0", "0", "0", "0", "0", "10000", "2000000", "3878", "d801d001", "1e0000", "0", "0", "0") 
QXcbConnection: XCB error: 6 (BadCursor), sequence: 25250, resource id: 37748777, major code: 2 (ChangeWindowAttributes), minor code: 0
kcm_keyboard: configuring layouts true configuring options true

### layout switching now works
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("us", "se")   variants: ("euro", "")

### now plugging in keyboard again

Solid::Backends::UDev::input_str_to_bitmask can't handle some bits ("2a0", "0", "0", "0", "0", "0", "10000", "2000000", "3878", "d801d001", "1e0000", "0", "0", "0") 
kcm_keyboard: configuring layouts true configuring options true
kcm_keyboard: Fetched layout groups from X server:      layouts: ("se")         variants: ("")
kcm_keyboard: Layout map change:  "us(euro),se," --> "se,"
kcm_keyboard: Layout map change from external source: clearing layout memory
kcm_keyboard: Fetched layout groups from X server:      layouts: ("se")         variants: ("")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("se")         variants: ("")
kcm_keyboard: Fetched layout groups from X server:      layouts: ("se")         variants: ("")

### layout switching does not work

The workaround mentioned by the OP works for me too.
Comment 4 Marcus Better 2015-09-24 13:52:04 UTC
Created attachment 94709 [details]
X.org log
Comment 5 Oleg Solovyov 2019-05-29 12:49:20 UTC
I revealed that xkb layout reset when any USB device is plugged in when there is no config at ~/.config/kxkbrc
Comment 6 Andriy Rysin 2019-06-03 14:49:00 UTC
That's the behavior of X.org - when new input device is connected the xkb layouts are reset.
In KDE we have a workaround - we are catching new device event and reapplying mouse and keyboard configuration. But if your KDE keyboard configuration setting is off you're on your own.
Comment 7 Oleg Solovyov 2019-06-03 14:50:27 UTC
(In reply to Andriy Rysin from comment #6)
> That's the behavior of X.org - when new input device is connected the xkb
> layouts are reset.
> In KDE we have a workaround - we are catching new device event and
> reapplying mouse and keyboard configuration. But if your KDE keyboard
> configuration setting is off you're on your own.

made a patch https://phabricator.kde.org/D21497
in case of patch is ok I'll land it tomorrow
Comment 8 Oleg Solovyov 2019-06-04 14:22:47 UTC
Git commit a14258a0cd60f99e4585d7d1e34f3e029715f342 by Oleg Solovyov.
Committed on 04/06/2019 at 14:22.
Pushed by osolovyov into branch 'master'.

fill layouts from X server when there are no layouts in config

Summary: BUG: 348198

Test Plan:
1) move ~/.config/kxkbrc
2) connect a USB keyboard
3) layout changing works

Reviewers: ngraham, broulik, hein, #plasma

Reviewed By: ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21497

M  +10   -5    kcms/keyboard/keyboard_config.cpp
M  +1    -0    kcms/keyboard/keyboard_daemon.cpp

https://commits.kde.org/plasma-desktop/a14258a0cd60f99e4585d7d1e34f3e029715f342