SUMMARY SDL_SetWindowGrab doesn't work with mouse not hidden (SDL2, X11 video driver only, Wayland plasma session). An example program to compile with SDL2 with minimal code can be found here, including a video of the bug: https://github.com/libsdl-org/SDL/issues/9162#issue-2156980130 An SDL2 contributor suggests it works with GNOME, and therefore is likely to be a KWin bug: https://github.com/libsdl-org/SDL/issues/9162#issuecomment-1977620580 My apologies if it isn't, I hope this bug report is useful to determine if that's the case. STEPS TO REPRODUCE 1. Run a plasma wayland session 2. Compile program found in https://github.com/libsdl-org/SDL/issues/9162#issue-2156980130 3. Run program with `SDL_VIDEODRIVER=x11` env var, it should open a window 4. Click into the window. Now move the mouse toward the border and outside. OBSERVED RESULT The mouse freely leaves the window. EXPECTED RESULT The mouse stays confined in the window. SOFTWARE/OS VERSIONS Linux/KDE Plasma: openSUSE Slowroll 20240213 (available in About System) KDE Plasma Version: 5.27.10 KDE Frameworks Version: Version 5.113.0 Qt Version: not sure which one was used ADDITIONAL INFORMATION
will take a look
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5358
Thank you for providing that test app. It really helped with debugging.
Git commit bfd755aee9282882dc82d8ce2e44ff4277cc5830 by Vlad Zahorodnii. Committed on 05/03/2024 at 13:23. Pushed by vladz into branch 'master'. Fix confined pointer being able to escape the surface When using fractional scaling, an xwayland window's client geometry can have some fractional part. When that's the case, .toRect() can shrink the client geometry or extruding the decoration borders inside the surface. On the other hand, the pointer is going to be confined as long as the wl_surface is focused. If the focus jumps to the decoration, the pointer constraint is going to be broken. Unfortunately, the focus can shift to the decoration even though the wl_surface is still focused because of the pesky .toRect(). Related: bug 477124 M +1 -1 src/input.cpp https://invent.kde.org/plasma/kwin/-/commit/bfd755aee9282882dc82d8ce2e44ff4277cc5830
Git commit 7da6ecb3df5edc940eede219dec7efed764e4c22 by Vlad Zahorodnii. Committed on 05/03/2024 at 13:35. Pushed by vladz into branch 'Plasma/6.0'. Fix confined pointer being able to escape the surface When using fractional scaling, an xwayland window's client geometry can have some fractional part. When that's the case, .toRect() can shrink the client geometry or extruding the decoration borders inside the surface. On the other hand, the pointer is going to be confined as long as the wl_surface is focused. If the focus jumps to the decoration, the pointer constraint is going to be broken. Unfortunately, the focus can shift to the decoration even though the wl_surface is still focused because of the pesky .toRect(). Related: bug 477124 (cherry picked from commit bfd755aee9282882dc82d8ce2e44ff4277cc5830) M +1 -1 src/input.cpp https://invent.kde.org/plasma/kwin/-/commit/7da6ecb3df5edc940eede219dec7efed764e4c22
Thanks so much for the fix! That was super fast