Bug 383113 - Ctrl+Shift+letter shortcuts don't work if Ctrl+Shift is used for layout switching in wayland
Summary: Ctrl+Shift+letter shortcuts don't work if Ctrl+Shift is used for layout switc...
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: input (show other bugs)
Version: 5.10.4
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
: 387500 478323 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-08-04 10:16 UTC by Igor Poboiko
Modified: 2023-12-18 23:13 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
mgraesslin: Wayland+
mgraesslin: X11-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Poboiko 2017-08-04 10:16:39 UTC
This is a long-standing bug for X.org (see https://bugs.freedesktop.org/show_bug.cgi?id=865, 13 years already; although it has a proposed patch, which is not accepted to upstream yet), and there is even an old bug in KDE bugzilla (Bug 114326). 

In wayland, apparently, things are quite different as the compositor - KWin - now handles everything including shortcuts, which brings a hope to resolve this issue once and for all.

The current behavior is following: 
1) I have two keyboard layouts, russian and english, and I use ctrl+shift for layout switching. 
2) I open Konsole and press Ctrl+Shift+N in order to open new window
3) Right after I pressed Ctrl+Shift, the layout immediately switches. After I press "N", Konsole thinks I've pressed just Ctrl+N and thus ignores the shortcut (this I've checked via the KWin Debug Console), writing the "n" letter in the terminal.

Clearly, switching the layout is not something I intended to do and this behavior is wrong. The original idea proposed in bugs.fd.o 865 is to trigger the shortcut (e.g. ctrl+shift) on key release instead of key press. Actually, there is a lot of discussion there, which might be useful.
Comment 1 Martin Flöser 2017-08-06 14:45:38 UTC
I'm sorry, but I fear there is nothing we can do about this. The layout handling is handled by xkbcommon. That is we pass all key events to xkbcommon and xkbcommon transforms it to a key symbol and handles changes to the keyboard layout transparently. Whatever comes out from xkbcommon is then fed into other parts of KWin such as global shortcuts or send to other applications. We don't have any control over this at this point.

In fact KWin is completely out of the game here as the shortcut matching is done inside Konsole, so inside Qt. Which again just forwards keys into xkbcommon.

I don't know whether this can be fixed at all - I don't know the internals of all involved components enough. But I fear this is just an unfixable situation.
Comment 2 David 2019-06-30 11:55:13 UTC
(In reply to Martin Flöser from comment #1)
> I'm sorry, but I fear there is nothing we can do about this. The layout
> handling is handled by xkbcommon. That is we pass all key events to
> xkbcommon and xkbcommon transforms it to a key symbol and handles changes to
> the keyboard layout transparently. Whatever comes out from xkbcommon is then
> fed into other parts of KWin such as global shortcuts or send to other
> applications. We don't have any control over this at this point.
> 
> In fact KWin is completely out of the game here as the shortcut matching is
> done inside Konsole, so inside Qt. Which again just forwards keys into
> xkbcommon.
> 
> I don't know whether this can be fixed at all - I don't know the internals
> of all involved components enough. But I fear this is just an unfixable
> situation.

If it helps, XFCE seems to somehow have fixed this issue in whatever library they use, while all other DEs (KDE, Mate, old Gnome, etc.) still encounter this problem.
Comment 3 Nate Graham 2019-06-30 13:27:48 UTC
*** Bug 387500 has been marked as a duplicate of this bug. ***
Comment 4 David 2019-09-08 07:35:32 UTC
Also if the issue is with xkbcommon, does it mean it can be fixed in wayland?
Comment 5 Nate Graham 2023-12-12 18:23:36 UTC
*** Bug 478323 has been marked as a duplicate of this bug. ***
Comment 6 ezh 2023-12-13 12:29:05 UTC
FYI. I have opened an issue in libxkbcommon. 
https://github.com/xkbcommon/libxkbcommon/issues/420

If someone could raise it priority or put attention to it...