Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WarpMouse freezes mouse in SDL 1.2.15 pre-release #655

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

WarpMouse freezes mouse in SDL 1.2.15 pre-release #655

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
endoflife Bug might be valid, but SDL-1.2 is EOL.

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 1.2
Reported for operating system, platform: Mac OS X 10.7, x86_64

Comments on the original bug report:

On 2012-01-16 09:24:08 +0000, Jeremiah Morris wrote:

Created attachment 774
Test case, based on SDLTest's testwm.c

In the latest pre-release, calling SDL_WarpMouse appears to lock up the mouse pointer for about 250 ms. This breaks games such as mine, which call GetMouseState and WarpMouse in a tight loop.

In the attached test case, line 438 has the timer frequency: by adjusting this above 250, I can get some mouse movement between each warp.

On 2012-01-16 09:25:30 +0000, Jeremiah Morris wrote:

Created attachment 775
Code plus binaries for above test case

Attaching binaries for the test case, with 1.2.14 and pre-release 1.2.15 frameworks.

On 2012-01-16 09:34:23 +0000, Jeremiah Morris wrote:

I forgot to mention -- in the pre-release, if you grab input (Ctrl-G) and hide the cursor (mouse click), then mouse events will come in normally, even in a tight loop. The test app prints messages to stdout when it detects movement.

On 2012-01-16 10:41:21 +0000, Jeremiah Morris wrote:

Created attachment 776
Alternative method for avoiding cursor freeze

I discovered the source of the problem. In QZ_PrivateWarpCursor, there's a call to turn off Cocoa's default suppression of events for a short interval after posting. In the pre-release, this was rewritten to avoid a deprecated API; however, the re-write doesn't work. It creates a new event source and changes its settings, but that has no effect on my system. Since the created source isn't actually used anywhere, the result is not surprising.

The deprecated call still works, but I found an alternate method that avoids the delay. By disassociating the mouse and cursor position during the warp, the event suppression doesn't kick in. I can't find any documentation guaranteeing that this will work better, but it gets the job done here with non-deprecated calls.

So far, this fix has only been tested on an x86_64 machine running 10.7. The relevant APIs have been present since 10.0, so I hope the behavior is consistent on older machines.

On 2012-01-16 11:29:53 +0000, Ryan C. Gordon wrote:

Created attachment 777
Slightly better version of alternative method

Here's a slightly updated version...we use that API call with mouse grabbing elsewhere, so we need to make sure we don't trample state. Can you confirm this still works for you? If we're good, I'll push the change into revision control.

Thanks!

--ryan.

On 2012-01-16 14:28:26 +0000, Jeremiah Morris wrote:

The current callers kept the state consistent, but better safe than sorry. I tested your version on 64-bit Lion, 32-bit Snow Leopard, and 32-bit Leopard. Mouse control behaved as expected in all three cases. Thanks!

On 2012-01-16 15:41:42 +0000, Vittorio Giovara wrote:

I tried the patch as well and it actually corrects the reported mouse problems in Hedgewars.

What I see now as a minor glitch, is that if you you move the mouse way beyond the sdl window borders, the cursor, if hidden, will begin to flash and become visible until focus is lost and gained again.

This reproducible in the test code and the patched SDL framework in this way: when the app is launched the mouse is visible, press a button and it will become invisible, move it quickly past the window borders a few times and the mouse becomes visible again; press a mouse button again and it will remain visible (most likely it internally sets the visible flag), press a button another time and it will become invisible again.

On 2012-01-16 15:43:13 +0000, Vittorio Giovara wrote:

Created attachment 778
testwm with the patched 1.2.15 frameworks

On 2012-01-16 16:46:07 +0000, Jeremiah Morris wrote:

What I see now as a minor glitch, is that if you you move the mouse way beyond
the sdl window borders, the cursor, if hidden, will begin to flash and become
visible until focus is lost and gained again.

I don't think this is different than 1.2.14 behavior, or expected behavior in Cocoa. The cursor settings, including visibility, are determined by the window under the cursor: when you leave the SDL window and hit the desktop, you'll see the cursor visible on the desktop. This behavior can be useful sometimes -- in Aleph One's keyboard-only mode, we hide the cursor, but it's possible to move it outside the window and then click to a different app.

The test app causes flicker, because it's bringing the mouse back inside the window on a regular basis. There, you have plenty of time (200 ms) to leave the window, but in Aleph One's mouse mode and I assume in Hedgewars, you'd be polling the mouse too frequently for this to be an issue. And of course, there's always SDL_WMGrabInput, when you absolutely need to hang onto that mouse pointer.

On 2012-01-16 16:54:33 +0000, Jeremiah Morris wrote:

Sorry, I misunderstood. I see the glitch now; it's not hiding the cursor again when it re-enters the window. Playing with the test case, I see 1.2.14 had a small issue in that regard, but it fixed itself when the mouse was moved again.

On 2012-01-16 19:19:49 +0000, Ryan C. Gordon wrote:

My patch is now in revision control, hg changeset 6f013dd0add1. I think we're good to go now, so I'm marking this bug Resolved.

--ryan.

On 2012-12-20 16:42:22 +0000, wrote:

The new fix is not really working well. It works only if you continuously pull SDL events in your main loop. I am working on an application (Cube 2: Sauerbraten) which warps the mouse every frame, and has fps limit in menus, and the mouse on mac, with sdl 12.15, is laggy. A workaround is to disable vertical synch, so the main loop runs as fast as it can, but this should be resolved in a better way, and also, it is basically a regression from 12.14, which works fine in a setup of various users (with Mac OSX versions in the range 10.6 - 10.8).

On 2015-08-25 09:38:22 +0000, Ryan C. Gordon wrote:

Hello, and sorry if you're getting several copies of this message by email, since we are closing many bugs at once here.

We have decided to mark all SDL 1.2-related bugs as RESOLVED ENDOFLIFE, as we don't intend to work on SDL 1.2 any further, but didn't want to mark a large quantity of bugs as RESOLVED WONTFIX, to clearly show what was left unattended to and make it easily searchable.

Our current focus is on SDL 2.0.

If you are still having problems with an ENDOFLIFE bug, your absolute best option is to move your program to SDL2, as it will likely fix the problem by default, and give you access to modern platforms and tons of super-cool new features.

Failing that, we will accept small patches to fix these issues, and put them in revision control, although we do not intend to do any further official 1.2 releases.

Failing that, please feel free to contact me directly by email (icculus@icculus.org) and we'll try to find some way to help you out of your situation.

Thank you,
--ryan.

@SDLBugzilla SDLBugzilla added bug endoflife Bug might be valid, but SDL-1.2 is EOL. labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
endoflife Bug might be valid, but SDL-1.2 is EOL.
Projects
None yet
Development

No branches or pull requests

1 participant