Bug 482448 - SDL_SetWindowGrab doesn't work with mouse not hidden (SDL2, X11 video driver only, Wayland plasma session)
Summary: SDL_SetWindowGrab doesn't work with mouse not hidden (SDL2, X11 video driver ...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.27.10
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-05 09:01 UTC by Ellie
Modified: 2024-03-05 15:10 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 6.0.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ellie 2024-03-05 09:01:56 UTC
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
Comment 1 Vlad Zahorodnii 2024-03-05 09:32:18 UTC
will take a look
Comment 2 Bug Janitor Service 2024-03-05 10:12:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5358
Comment 3 Vlad Zahorodnii 2024-03-05 10:12:34 UTC
Thank you for providing that test app. It really helped with debugging.
Comment 4 Vlad Zahorodnii 2024-03-05 13:31:45 UTC
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
Comment 5 Vlad Zahorodnii 2024-03-05 13:46:46 UTC
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
Comment 6 Ellie 2024-03-05 15:10:06 UTC
Thanks so much for the fix! That was super fast