Bug 440340

Summary: keyboard combinations not captured by guest OS (kwin_wayland issue?)
Product: [Plasma] kwin Reporter: Jelle Geerts <bughunter2>
Component: platform-wayland-nestedAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: nate, temptempor
Priority: NOR Keywords: wayland-only
Version First Reported In: 5.22.2   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Jelle Geerts 2021-07-27 21:46:49 UTC
SUMMARY


STEPS TO REPRODUCE
1. Start a VM in VirtualBox while using 'kwin_wayland' on the host rather than 'kwin_x11'.
2. Click inside the VM to make sure it's the active window.
3. Press the combination Meta+E on the keyboard.

OBSERVED RESULT
Observe that keyboard combinations such as Meta+E are processed by the host rather than by the guest.


EXPECTED RESULT
The VM (the guest) should process the keyboard combination, and it should have no effect on the host.


SOFTWARE/OS VERSIONS
Linux: kernel 5.12.14
KDE Plasma Version: 5.22.2
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

In VirtualBox, keyboard combinations trigger shortcuts on the host machine rather than in the VM's guest OS.
This doesn't occur when the host is using 'kwin_x11'.
It only happens with 'kwin_wayland'.
(Think of keyboard combinations like Meta+E to open the file manager.)

From what I know, this is in some sense normal on Wayland since Wayland is more secure. But, as you're probably aware, in recent years Wayland has provided extensions so that well-behaved programs can grab the keyboard if they wish.

Of course, it may be a VirtualBox bug, so I looked into a that:

Currently, VirtualBox tries to be well-behaved, because it is sending the '_XWAYLAND_MAY_GRAB_KEYBOARD' message ( see https://www.virtualbox.org/ticket/19650 ). This helps it grab the keyboard on mutter (GNOME's Wayland compositor).

However, that virtualbox fix seems specific to mutter, and doesn't appear to help for kwin (or 'kwin_wayland').

Questions:

  - Is there anything else VirtualBox needs to do to properly grab the keyboard?

    Is there some 'standard' method? One that works on both 'kwin_wayland' and 'mutter'?
    Or is the '_XWAYLAND_MAY_GRAB_KEYBOARD' message the standard way?
    That message seems to be mutter-specific, but I could be wrong.

  - Or, should kwin listen for the above message and handle it properly?

    If so, consider this to be a feature request.

Related:

  vbox: https://www.virtualbox.org/ticket/19650
  kwin: https://phabricator.kde.org/T12988
  kwin: https://bugs.kde.org/show_bug.cgi?id=405877
  mutter: https://bugzilla.redhat.com/show_bug.cgi?id=1285770
Comment 1 temptempor 2022-05-29 15:48:18 UTC
Hello, 

This is still an issue for me as well.


# SOFTWARE/OS VERSIONS

Operating System: Arch Linux
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4
Kernel Version: 5.17.9-zen1-1-zen (64-bit)
Graphics Platform: Wayland

VirtualBox: 6.1.34

VirtualBox appears to have done what was necessary on their end 2 years ago: 
https://www.virtualbox.org/ticket/19650

Does KWIN_WAYLAND implement the mentioned "_XWAYLAND_MAY_GRAB_KEYBOARD" parameter and behaves accordingly?

Thanks.
Comment 2 David Edmundson 2023-09-06 10:39:09 UTC
This bug was reported against an outdated version of KWin. We have made many changes since the. 
If the issue persists in newer versions can you reopen the bug report updating the version number.