Bug 502364 - Xwayland keyboard grab not working
Summary: Xwayland keyboard grab not working
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: xwayland (other bugs)
Version First Reported In: 6.3.4
Platform: Arch Linux Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland-only
Depends on:
Blocks:
 
Reported: 2025-04-03 16:37 UTC by ogamal523
Modified: 2025-06-15 11:31 UTC (History)
4 users (show)

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


Attachments
Video demonstrating the issue (1.77 MB, video/mp4)
2025-05-30 18:15 UTC, ogamal523
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ogamal523 2025-04-03 16:37:05 UTC
SUMMARY
xwayland keyboard grabs don't work, which affects apps like vmware, passing the shortcuts of the virtual machine to the host
This bug was reported before and supposedly fixed in Bug 455159, but the problem still persists

OBSERVED RESULT
  Keyboard shortcuts get passed to the host

EXPECTED RESULT
  Keyboard shortcuts don't get passed to the host

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.3.4
KDE Frameworks Version: 6.12.0
Qt Version: 6.8.3
Kernel Version: 6.13.8-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12700H
Memory: 31.0 GiB of RAM

ADDITIONAL INFORMATION
Comment 1 ogamal523 2025-05-30 18:12:29 UTC
Hello, so to get this issue going I will try to explain how this gets handled in gnome to find if there is a qdbus equivalent .
Gnome handles keyboard capture through GSettings, which comes with the GTK package. There is an option in mutter to allow key grabs which gets enabled by doing the following
gsettings set org.gnome.mutter.wayland xwayland-allow-grabs "true"
gsettings set org.gnome.mutter.wayland xwayland-grab-access-rules "['vmplayer','vmware-vmx','mksSandbox']"

of course this won't on kwin as it doesn't get configured through gsettings and if it was configured through gsettings i doubt the option would have the name, so I am wondering if there is a qdbus equivalent for this command to rectify the issue for the xwayland grabs in vmware
Comment 2 ogamal523 2025-05-30 18:15:22 UTC
Created attachment 181906 [details]
Video demonstrating the issue

Here i am pressing the meta key while "being grabbed" by the guest, the key press shouldn't get passed to the host, but it does
Comment 3 John Kizer 2025-06-14 00:50:26 UTC
Hi! While I'm not a VMware user, it seems like this is a widely-experienced issue with that software across Wayland compositors:

https://community.broadcom.com/vmware-cloud-foundation/question/wayland-support#16dabab5-9203-460b-9e74-019745d204cd
https://www.reddit.com/r/gnome/comments/rwfm19/grab_keyboard_input_in_vmware_with_wayland_in/
https://www.reddit.com/r/vmware/comments/15ln1ap/vmware_workstation_17_on_debian_question/

If what you described on GNOME/Mutter is a workaround to force global shortcuts to be passed through to an application, then KWin would have an equivalent workaround with the Window rule to "Ignore global shortcuts".

If there's information indicating that there's an issue unique to KWin here, please feel free to reopen. Thanks!
Comment 4 ogamal523 2025-06-15 11:24:36 UTC
> equivalent workaround with the Window rule to "Ignore global shortcuts".
The thing is that the ignore global shortcuts window rule is a hack(not real keyboard grabbing like in x11 or the gnome workaround) and makes it extremely annoying to deal with vmware as you would have to either close vmware or open another application to get access to the keyboard shortcuts, which becomes problematic while multitasking.
If you would like a video demonstrating the behavior with the ignore global shortcuts rule I would be happy to send it.

>If there's information indicating that there's an issue unique to KWin here, please feel free to reopen. Thanks!
My theory is that xwayland keyboard grabbing is broken on KDE hence the current behavior, unfortunately i don't know of any other xwayland app that does keyboard grabbing to be able to test it on.
Comment 5 ogamal523 2025-06-15 11:31:02 UTC
ignore my previous comment after reading this post:
>https://community.broadcom.com/vmware-cloud-foundation/question/wayland-support#16dabab5-9203-460b-9e74-019745d204cd
it seems like Workstation won't work properly unless it gets ported to Wayland.
Thank you for your time.