https://bugs.kde.org/show_bug.cgi?id=510404

            Bug ID: 510404
           Summary: XWayland apps get stray keystrokes if you release
                    modifier before shortcut character
    Classification: Plasma
           Product: kwin
      Version First 6.4.5
       Reported In:
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: xwayland
          Assignee: kwin-bugs-n...@kde.org
          Reporter: nyanpas...@tuta.io
  Target Milestone: ---

Created attachment 185615
  --> https://bugs.kde.org/attachment.cgi?id=185615&action=edit
Video of the Ctrl+A bug happening on Plasma 6.5.80.

SUMMARY
If you press a shortcut like Ctrl+C in a Wayland app, then release the modifier
Ctrl before the letter, the key remains held down in XWayland and can randomly
be sent to a X11 app when you click on it.

STEPS TO REPRODUCE
1. In Legacy X11 App Support, ensure "Allow legacy X11 apps to read keystrokes
typed in all apps:" is set to the default of "As above, plus any key typed
while the Control, Alt, or Meta keys are pressed".
2. Open a Wayland window (like a KDE app) and a X11 window (like Flatpak
Obsidian).
3. Focus the Wayland app, type Ctrl+C, and release Ctrl before C.
4. Click on the X11 app.

OBSERVED RESULT
Randomly a C keystroke will be sent to the X11 app. This may take many tries.

To see what keystrokes are delivered to X11 apps, you can install Screenkey
from your distro package manager or by running `uvx
https://gitlab.com/screenkey/screenkey.git`, then use Window Rules to set the
popup to "Keep above other windows", "No titlebar and frame", and "Accept
focus" force = No.

I found that if I release Ctrl before C, XWayland usually enters a state where
it sends an endless string of C keystrokes to screenkey (these may not be
visible until you move your mouse over a X11 app); I think the key repeats
forever because kwin_wayland fails to deliver the C key release to XWayland.
When you click on a X11 app, there's a chance a key repeat gets delivered to
the app before XWayland realizes C is no longer being pressed and stops
repeating it.

EXPECTED RESULT
XWayland apps should receive key release events regardless of modifier state,
if the original key press event was received (eg. because modifier was held, or
before changing the "Allow legacy X11 apps to read keystrokes typed in all
apps:" option).

SOFTWARE/OS VERSIONS
This reproduces on Plasma 6.4.5, as well as 6.5.80 from KDE Linux 2025-09-21.

Operating System: Fedora Linux 42
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.18.0
Qt Version: 6.9.2
Kernel Version: 6.16.10-200.fc42.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8559U CPU @ 2.70GHz
Memory: 16 GiB of RAM (15.5 GiB usable)
Graphics Processor: Intel® Iris® Plus Graphics 655
Manufacturer: Intel(R) Client Systems
Product Name: NUC8i7BEH
System Version: J72992-303

ADDITIONAL INFORMATION

The "possible duplicates" list pointed to Bug 478705, which has a command
`xinput test-xi2 --root` to log received keyboard/mouse events in the terminal.
By running this command and doing testing, I found that if we press C (not
received) then Ctrl, then release C, xinput never receives the C release event
even though Ctrl is being held. I wonder if it's kwin filtering the unpaired
release before reaching XWayland, or XWayland/xinput rejecting a stray key
release KDE mistakenly sends.

Previous testing at https://bugs.kde.org/show_bug.cgi?id=484992#c34 and
https://bugs.kde.org/show_bug.cgi?id=484992#c59.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to