Bug 495325 - Blender intermittently stops receiving mouse/keyboard input on focus once keyboard shortcut for Lockscreen/Sleep is used.
Summary: Blender intermittently stops receiving mouse/keyboard input on focus once key...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 6.2.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-25 02:01 UTC by saucesfm
Modified: 2024-11-15 18:00 UTC (History)
3 users (show)

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


Attachments
Video of Blender not focusing (1.40 MB, video/mp4)
2024-10-25 02:01 UTC, saucesfm
Details
Select 3D cursor mode (25.35 KB, image/png)
2024-10-25 02:28 UTC, saucesfm
Details
Can't zoom in/out on Krita after locking screen (730.80 KB, video/mp4)
2024-10-25 08:38 UTC, saucesfm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description saucesfm 2024-10-25 02:01:04 UTC
Created attachment 175206 [details]
Video of Blender not focusing

SUMMARY

In KDE Wayland post Plasma 6.2.0, if I use the Lockscreen or Sleep keyboard shortcuts to lock the screen, Blender will more often than not stop responding to keyboard or mouse inputs if it loses and regains focus, see video attached. The window still gains focus, but Blender itself doesn't register the keys.

When this happens, this is repeatedly printed in the journal

> blender[41890]: WARN (ghost.wl.keyboard.depressed): intern/ghost/intern/GHOST_SystemWayland.cc:7501 getModifierKeys: modifier (OS) state is inconsistent (GHOST released keys do not match XKB)

It only happens if I use the keyboard shortcuts. If I manually go to the application launcher and sleep/lockscreen, it doesn't happen. Other keyboard shortcuts, like ALT+TAB also don't cause any issues.

To fix it, i have to log out and log in, or do a kwin_wayland --replace. Restarting Blender doesn't fix it. Relocking the screen again reintroduces the issue.

This bug started happening in Plasma 6.2.0.

STEPS TO REPRODUCE
1. Open Blender (Bug happens even if Blender is closed while locking/sleep)
2. Lock Screen/Sleep through keyboard shortcut
3. Unlock screen, and try to click on the Blender viewport, or try to zoom in/out using scrollwheel.
4. Try unfocusing Blender window, then refocusing and try to click or scroll in the blender window.

OBSERVED RESULT

Blender will sometimes not respond to mouse clicks/scrolls and keyboard input

EXPECTED RESULT

Blender should respond to mouse clicks/scrolls and keyboard input when focused

SOFTWARE/OS VERSIONS

Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.2.2
KDE Frameworks Version:  6.7.0
Qt Version: 6.8.0

ADDITIONAL INFORMATION
Tested with Blender 4.2.3 Binary from the blender website, as well as Blender 4.2.2 LTS from the flatpak repos.
Does not happen in KDE X11.

A possibly related bug with Sway on the Blender bugtracker 
https://projects.blender.org/blender/blender/issues/117225
Comment 1 saucesfm 2024-10-25 02:28:21 UTC
Created attachment 175207 [details]
Select 3D cursor mode
Comment 2 Volker 2024-10-25 08:08:07 UTC
I have the exact same issue in Blender, but a similar one in Krita as well, which is most likely related. Only the lmb input works there, so I can draw but I can't zoom and press some other keys.
Comment 3 saucesfm 2024-10-25 08:38:25 UTC
Created attachment 175216 [details]
Can't zoom in/out on Krita after locking screen

Can confirm it affects Krita as well. Drawing using left click works, but can't zoom in/out using the middle mouse scroll. Strangely, it works when its a background window, but bringing it into focus breaks it again.
Comment 4 Loginer 2024-11-03 18:22:58 UTC
Same issue here. You can fix it temporarily by mashing Ctrl + Meta or Alt + Meta.
Comment 5 Vlad Zahorodnii 2024-11-14 13:52:43 UTC
Git commit c1e3dc0e083dee84aa24f8fb0a42dc112270645d by Vlad Zahorodnii, on behalf of Adam Nydahl.
Committed on 14/11/2024 at 13:02.
Pushed by vladz into branch 'master'.

Ensure active window isn't focused when screen is locked

If the screen is locked, but the lockscreen isn't ready for painting,
pickFocus() returns the active window. This somehow leads to the
meta key getting "stuck" if you lock the screen with Meta+L.

M  +1    -0    src/keyboard_input.cpp

https://invent.kde.org/plasma/kwin/-/commit/c1e3dc0e083dee84aa24f8fb0a42dc112270645d
Comment 6 Vlad Zahorodnii 2024-11-14 16:37:24 UTC
Git commit f90ffedf14dff85c55030c2c465d166c30c7be14 by Vlad Zahorodnii.
Committed on 14/11/2024 at 16:23.
Pushed by vladz into branch 'Plasma/6.2'.

Ensure active window isn't focused when screen is locked

If the screen is locked, but the lockscreen isn't ready for painting,
pickFocus() returns the active window. This somehow leads to the
meta key getting "stuck" if you lock the screen with Meta+L.


(cherry picked from commit c1e3dc0e083dee84aa24f8fb0a42dc112270645d)

Co-authored-by: Adam Nydahl <loginer@loginer.net>

M  +1    -0    src/keyboard_input.cpp

https://invent.kde.org/plasma/kwin/-/commit/f90ffedf14dff85c55030c2c465d166c30c7be14