Bug 478705

Summary: Legacy X11 keyboard support does not receive key mask state update when Alt+tab is used
Product: [Plasma] kwin Reporter: Weng Xuetian <wengxt>
Component: inputAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: fanzhuyifan, nate, unblended_icing552
Priority: NOR Keywords: qt6
Version First Reported In: 5.90.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.0.1
Sentry Crash Report:

Description Weng Xuetian 2023-12-19 03:38:24 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Set "All" to X11 legacy app support under kwin wayland
2. start xinput test-xi2 --root
3. first press any key like "a", and see modifier line is "base 0".
4. make sure alt+tab is set for window switching, and the focused window is wayland window.
5. press alt + tab with alt being held.
6. release all key.
7. press "a" again

OBSERVED RESULT
After that, the any key pressed is with "modifier base 0x8", which means alt mask is set.
Press alt again will make the state back to normal.

EXPECTED RESULT
modifier is return to "base 0" because alt is released.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.90.0
(available in About System)
KDE Plasma Version: 5.90.0
KDE Frameworks Version: 5.246.0
Qt Version: 6.6.1

ADDITIONAL INFORMATION
I suspect that alt is not forwarded to xwayland at all since kwin captured it for alt+tab, and later xwayland's key state is kept in a wrong state until the next X window is focused.
Comment 1 fanzhuyifan 2023-12-19 04:55:13 UTC
Can reproduce
Comment 2 Bug Janitor Service 2024-02-28 13:33:40 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5322
Comment 3 David Edmundson 2024-03-03 12:50:09 UTC
Git commit 2025bf4c6b99950e104eb0fd79992bb3912ae3a4 by David Edmundson.
Committed on 03/03/2024 at 12:41.
Pushed by davidedmundson into branch 'master'.

xwayland: Send to xwayland even when no window is focussed

In the codepath to keep xwayland notified of key presses we have to
check the focussed window is not already an xwayland client. To avoid a
null dereference a guard is added that the focussed window is not null,
however the current code incorrectly returns early intead of skipping
just the relevant check.

M  +24   -23   src/xwayland/xwayland.cpp

https://invent.kde.org/plasma/kwin/-/commit/2025bf4c6b99950e104eb0fd79992bb3912ae3a4
Comment 4 Vlad Zahorodnii 2024-03-06 12:54:31 UTC
Git commit 18e6256dd6a3c97b57180319edbe5f8559892556 by Vlad Zahorodnii, on behalf of David Edmundson.
Committed on 06/03/2024 at 12:42.
Pushed by vladz into branch 'Plasma/6.0'.

xwayland: Send to xwayland even when no window is focussed

In the codepath to keep xwayland notified of key presses we have to
check the focussed window is not already an xwayland client. To avoid a
null dereference a guard is added that the focussed window is not null,
however the current code incorrectly returns early intead of skipping
just the relevant check.

M  +16   -15   src/xwayland/xwayland.cpp

https://invent.kde.org/plasma/kwin/-/commit/18e6256dd6a3c97b57180319edbe5f8559892556
Comment 5 unblended_icing552 2024-03-21 04:48:34 UTC
*** Bug 479011 has been marked as a duplicate of this bug. ***