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 4720

Summary: SDL_SetRelativeMouseMode doesn't limit mouse if window has moved
Product: SDL Reporter: Steve <steve>
Component: *don't know*Assignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz, stfx, superfury
Version: 2.0.9Keywords: target-2.0.12
Hardware: x86   
OS: Windows 10   

Description Steve 2019-07-12 08:20:44 UTC
SDL_SetRelativeMouseMode: According to the docs, the hardware mouse should be hidden and relative movements should be reported. 

However, if the window has been moved using the top bar the call will fail to hide the mouse and it can wander out of the game window and click on other things causing the game to lose focus.
Comment 1 Steve 2019-07-12 08:22:06 UTC
Here's the original forum post:
https://discourse.libsdl.org/t/sdl-setrelativemousemode-not-hiding-hardware-mouse/26374
Comment 2 Steve 2019-07-12 12:47:16 UTC
Additional: I tried a few tests and the mouse can still leave the bounds of the window even if you don't move it. So that's a red herring.

However, minimising and maximising the window does fix it.
Comment 3 Ryan C. Gordon 2019-07-30 17:49:38 UTC
(Sorry if you get several emails like this, we're marking a bunch of bugs.)

We're hoping to ship SDL 2.0.11 on a much shorter timeframe than we have historically done releases, so I'm starting to tag bugs we hope to have closed in this release cycle.

Note that this tag means we just intend to scrutinize this bug for the 2.0.11 release: we may fix it, reject it, or even push it back to a later release for now, but this helps give us both a goal and a wishlist for the next release.

If this bug has been quiet for a few months and you have new information (such as, "this is definitely still broken" or "this got fixed at some point"), please feel free to retest and/or add more notes to the bug.

--ryan.
Comment 4 superfury 2019-07-31 05:33:49 UTC
Just noticed this with my app as well. Perhaps an issue in the 1903 version itself without mouse warping or 1903 + KB4505903/KB4508433?
Comment 5 superfury 2019-07-31 05:36:06 UTC
And minimizing and maximizing it again does fix the issue.
Comment 6 superfury 2019-07-31 05:45:11 UTC
I'm on version 2.0.10 btw.
Comment 7 Ryan C. Gordon 2019-09-20 20:47:37 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 8 Ryan C. Gordon 2019-09-20 20:48:40 UTC
We're changing how we do SDL release versions; now releases will be even numbers (2.0.10, 2.0.12, etc), and as soon as we tag a release, we'll move the internal version number to an odd number (2.0.12 ships, we tag the latest in revision control as 2.0.13 immediately, which will become 2.0.14 on release, etc).

As such, I'm moving the bugs tagged with target-2.0.11 to target 2.0.12. Sorry if you get a lot of email from this change!

Thanks,
--ryan.
Comment 9 Sam Lantinga 2020-02-11 15:54:45 UTC
Are you able to reproduce this with the latest code?
http://www.libsdl.org/tmp/SDL-2.0.zip

I tried using the testsprite2 test application, using Ctrl-R to toggle relative mode, and wasn't able to reproduce this.
Comment 10 Dom 2020-02-11 23:00:42 UTC
I am kind of able to reproduce this with the testrelative test application. If you alt+tab away and then click the title bar with the mouse the window will stop receiving mouse events.

This seems to be a well known issue since at least 2.0.9 as described here: https://gist.github.com/Costava/6f41383a57a5445a71f12f3e0ef25e74

While the issue seems to be caused with the exact same steps as described in the first post the mouse itself however correctly gets hidden for me on Win10 1909.
Comment 11 Sam Lantinga 2020-02-12 05:20:21 UTC
(In reply to Dom from comment #10)
> I am kind of able to reproduce this with the testrelative test application.
> If you alt+tab away and then click the title bar with the mouse the window
> will stop receiving mouse events.
> 
> This seems to be a well known issue since at least 2.0.9 as described here:
> https://gist.github.com/Costava/6f41383a57a5445a71f12f3e0ef25e74
> 
> While the issue seems to be caused with the exact same steps as described in
> the first post the mouse itself however correctly gets hidden for me on
> Win10 1909.

This isn't the original bug, but this is fixed now:
https://hg.libsdl.org/SDL/rev/1bc601a25155

Thanks!
Comment 12 Sam Lantinga 2020-03-01 20:24:44 UTC
I believe this is fixed, please reopen if you can reproduce it with the latest code.