Bug 466000 - Failed to grab shortcuts on X Wayland when window was unmanaged
Summary: Failed to grab shortcuts on X Wayland when window was unmanaged
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 5.27.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-18 13:36 UTC by Jiahao Li
Modified: 2023-02-26 08:22 UTC (History)
0 users

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


Attachments
X11 Unmanaged Window (37.78 KB, image/png)
2023-02-18 13:36 UTC, Jiahao Li
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiahao Li 2023-02-18 13:36:21 UTC
Created attachment 156435 [details]
X11 Unmanaged Window

SUMMARY

STEPS TO REPRODUCE
1. Open VMware workstation 17 on Kwin wayland.
2. Run Windows or Linux in VM.
2. Press shortcuts which combined with Win, Alt.

OBSERVED RESULT

The host task switcher grabed shortcuts first, the VM grabed it again.

EXPECTED RESULT

Keyboard grab should be inhibited in host. VM grab the shortcuts.

SOFTWARE/OS VERSIONS
Arch Linux 6.1.11
Linux/KDE Plasma: 5.27.0
KDE Plasma Version: 5.27.0
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION

Keyboard xwayland protocol didn't be added in kwin 5.26.5. So the shortcuts in vmware or freerdp(X11) can't be grabbed correctly. For kwin 5.27, the shortcuts feature was added, so freerdp (X11) can grab shortcuts correctly.

https://invent.kde.org/lijiahao/kwin/-/blob/master/src/wayland/keyboard_shortcuts_inhibit_v1_interface.cpp

However, the same issue existed in vmware. 

I think it may caused by the X11 unmanaged window. Xwayland can't handle the unmanaged key grab correctly? https://linux.die.net/man/3/xgrabkeyboard

VMware workstation has two windows: GTK UI and VM virtual desktop. The GTK UI was managed by X11. But the VM window was unmanaged.
Comment 1 Vlad Zahorodnii 2023-02-20 11:00:35 UTC
The unmanaged window must have keyboard focus (from kwin's perspective). Otherwise kwin is not going to inhibit global shortcuts. Can you check that it's the case?
Comment 2 Jiahao Li 2023-02-26 08:22:31 UTC
(In reply to Vlad Zahorodnii from comment #1)
> The unmanaged window must have keyboard focus (from kwin's perspective).
> Otherwise kwin is not going to inhibit global shortcuts. Can you check that
> it's the case?

I checked that with xev and xwinfo. The vmware children windows are special. It can't handle correct mouse enter event correctly. It's not bug in kwin. The input grab code implements are different in varities X11 softwares. 

Mutter can force grab it by setting. 
https://gitlab.gnome.org/GNOME/mutter/-/issues/1720

But KDE has a better way to do it. I added a troubleshooting on Archwiki. 
https://wiki.archlinux.org/title/KDE#X11_shortcuts_conflict_on_Wayland