We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5096

Summary: Implement SDL_SetWindowGrab for Wayland
Product: SDL Reporter: Tudor <me>
Component: videoAssignee: Tudor <me>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: HG 2.1Keywords: target-2.0.14
Hardware: All   
OS: Linux   
Attachments: SDL_SetWindowGrab.patch - attempt #1
SDL_SetWindowGrab.patch - attempt #2

Description Tudor 2020-04-16 17:38:03 UTC
Currently, `SDL_SetRelativeMouseMode` is implemented through `pointer-constraints-unstable-v1`'s `lock_pointer` request. `confine_pointer` from the same protocol can be used to implement `SDL_SetWindowGrab`.

I'm happy to work on this myself in the near future, but decided to open a ticket for tracking/visibility.
Comment 1 Sam Lantinga 2020-04-16 18:34:27 UTC
Sure, if you want to provide a patch, that would be great.

Thanks!
Comment 2 Tudor 2020-04-17 18:07:47 UTC
Created attachment 4309 [details]
SDL_SetWindowGrab.patch - attempt #1

Alright, I've put together a first attempt at a patch and confirmed it matches X11 single-confine behaviour (to the best of my knowledge) with a small test program. It's largely based off the existing locked pointer support.

I'm not sure what the behaviour should be if the user requests another confine while one is currently active. Currently, I've made it a no-op.
Comment 3 Tudor 2020-05-10 19:09:45 UTC
Hi, just wanted to bump this in case it slipped under the radar. Any feedback on the patch would be much appreciated so that I may make any requested changes :)
Comment 4 Tudor 2020-05-10 19:18:11 UTC
Sorry, forgot to mention in my earlier comment that I've been running this patch locally with a game that requires it, and I haven't noticed any wrong behavior since then.(In reply to Sam Lantinga from comment #1)
Comment 5 Sam Lantinga 2020-05-11 21:32:58 UTC
It generally looks good. New window grabs should replace older ones. Can you update your patch with that change?
Comment 6 Ryan C. Gordon 2020-05-12 02:27:13 UTC
Tentatively marking this as target-2.0.14, since this patch seems pretty close.
Comment 7 Tudor 2020-05-12 02:42:00 UTC
Created attachment 4338 [details]
SDL_SetWindowGrab.patch - attempt #2

Sounds good, I've uploaded a patch that destroys the old confine when creating a new one.
Comment 8 Sam Lantinga 2020-05-13 00:48:21 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/4709c1dfeabb