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 4467 - [Regression] Cursor movement is slow and erratic when using SDL_SetWindowGrab
Summary: [Regression] Cursor movement is slow and erratic when using SDL_SetWindowGrab
Status: RESOLVED DUPLICATE of bug 4748
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.10
Hardware: x86_64 Windows 10
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-21 12:36 UTC by Rémy Tassoux
Modified: 2019-10-23 13:25 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rémy Tassoux 2019-01-21 12:36:19 UTC
Calling SDL_SetWindowGrab with SDL_TRUE on a window makes the cursor movements very slow and jerky, making this functionality unusable.

The minimal code to reproduce this bug :

#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>

int main()
{
	SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS );

	auto sdl2_window = SDL_CreateWindow(
		"Window",
		SDL_WINDOWPOS_CENTERED,
		SDL_WINDOWPOS_CENTERED,
		800,
		600,
		SDL_WINDOW_RESIZABLE
	);

	SDL_SetWindowGrab( sdl2_window, SDL_TRUE );

	bool run{ true };
	while ( run )
	{
		SDL_Event event{};
		SDL_PollEvent( &event );

		if ( event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE )
			run = false;

	}

	SDL_DestroyWindow( sdl2_window );

	return 0;
}

In the previous SDL release (2.0.8), everything works fine.
Comment 1 Rémy Tassoux 2019-08-01 23:00:56 UTC
I retested this with the latest SDL version (2.0.10), and I can confirm that, unfortunately, this bug is still present. This is a regression as it was working fine until the 2.0.9 version.
Comment 2 Sylvain 2019-10-23 07:06:05 UTC
Not sure but maybe this is helped by
https://hg.libsdl.org/SDL/rev/9d6107cbcd66

Related to bug 4841
Comment 3 Rémy Tassoux 2019-10-23 08:35:39 UTC
I tried this change, and I can confirm that it doesn't fix this issue.
Comment 4 Sylvain 2019-10-23 08:52:35 UTC
Ok, too bad!

You said it's a regression, but maybe double-check with SDL 2.0.9 version.
That also could also be an issue while update window10 version ...

Then bisect, e.g try intermediates revision between 2.0.9 and 2.0.10 !
Comment 5 Rémy Tassoux 2019-10-23 09:46:33 UTC
As I already said, I tried the 2.0.9 version. It is a regression because this bug is not here in 2.0.8 version and earlier. I just tried it again to be 100% sure, and yes, everything still works fine with the 2.0.8 on my computer with the latest Windows 10 version (1903), while on 2.0.9 and 2.10.0 SDL_SetWindowGrab is still completely unusable.
Comment 6 Sylvain 2019-10-23 10:32:06 UTC
Sorry it wasn't clear for me if it was introduced between 2.0.8 and 2.0.9, or between 2.0.9 and 2.0.10.
And I wanted to make sure this wasn't an issue with a Window update, which you confirmed it wasn't

from https://hg.libsdl.org/SDL/tags
3 months ago 	release-2.0.10
11 months ago 	release-2.0.9
20 months ago 	release-2.0.8

SetWindowGrab() belongs to files:
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowsvideo.c

I'm not sure which revisions could introduce the issue:

https://hg.libsdl.org/SDL/log/6f0ec1079286/src/video/windows/SDL_windowsvideo.c
https://hg.libsdl.org/SDL/log/6f0ec1079286/src/video/windows/SDL_windowswindow.c

(maybe https://hg.libsdl.org/SDL/rev/de4288fa5b0b ... )

Try intermediates to spot the right one! (all: https://hg.libsdl.org/SDL/shortlog )
Comment 7 Rémy Tassoux 2019-10-23 11:00:27 UTC
No offence, but if I was able to find where it occurs accurately in the revisions, it would then probably be pretty easy for me to fix it and I would have submitted a patch instead of a bug report.

If I find the time to locate the source of this bug and fix it, I'll do it, but I cannot make any promises.
Comment 8 Sylvain 2019-10-23 11:39:47 UTC
Finding should be an easy step :)

Since, you said you tried with the latest (https://hg.libsdl.org/SDL/rev/9d6107cbcd66), it means you have the source under revision, right ? So that you can move between revisions with not much effort.
(ok maybe I'm just wrong and you applied the commit manually, or you just retried with old 2.0.10, and not the current head source ?)


So, bisect is just about trying a revision in the middle of the last known working and first not working. and then retrying until you find out the problematic revision. 
So, if you do it correctly, it's about updating 6 or 7 times, compiling, running your sample program again.
Comment 9 Sylvain 2019-10-23 11:48:11 UTC
But, this current issue is the same as bug 4748 ?
Comment 10 Rémy Tassoux 2019-10-23 12:43:54 UTC
I don't use Mercurial and never had. I'm contributing to the sdl2 port on vcpkg (I made the one for the 2.10.0 version) and that's also what I'm using to build it.

Anyway, I watched the video attached to the bug you linked, and it appears to be exactly the same problem (the cursor choppiness and OS beeps on mouse move). His bug report should be detailed enough to help fix this bug.
Comment 11 Sylvain 2019-10-23 13:03:41 UTC
So I resolved it as a duplicate.

And maybe you didn't actually try this change https://hg.libsdl.org/SDL/rev/9d6107cbcd66 ?

If you compile from source (even without using mercurial), you can apply manually this 1 line commit, or you can fetch there is a night build I think...

*** This bug has been marked as a duplicate of bug 4748 ***
Comment 12 Rémy Tassoux 2019-10-23 13:17:41 UTC
See my third post in this report, I did try it, right after you suggested it, and unfortunately it didn't fix this bug. I applied it manually to the sources before building it with vcpkg.
Comment 13 Sylvain 2019-10-23 13:25:01 UTC
Indeed, thanks!