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

Should SDL_WM_GrabInput()/X11_GrabInputNoLock() block? #616

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

Should SDL_WM_GrabInput()/X11_GrabInputNoLock() block? #616

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

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: Linux, x86_64

Comments on the original bug report:

On 2011-03-01 06:50:35 +0000, Petr Pisar wrote:

There was a thread on SDL mailing list http://lists.libsdl.org/htdig.cgi/sdl-libsdl.org/2009-February/068334.html regarding waiting for X11 input grab. I have been poked by an SDL application developer https://bugzilla.redhat.com/show_bug.cgi?id=664771 who has the same problem.

In short: Public SDL_WM_GrabInput() calls X11_GrabInputNoLock() that loops around XGrabPointer() until it succeeds.

According X11 manual, XGrabPointer() will fail, if window is not visible (return value GrabNotViewable), if other window holds grab already (AlreadyGrabbed), if other window holds grab and has frozen the input (GrabFrozen) and if invalid arguments (window ID etc.) are supplied.

SDL-1.2 branch does not handle these errors. It just waits until it grabs pointer. On the other hand it does not loop on grabbing keyboard focus.

There is also a comment in SDL code that raises this question: What to do in case of error.

Application developers want to return SDL_GRAB_OFF immediately. I worry it will break SDL 1.2 API. OTOH, SDL-1.3 tries to grab only if the window has focus. However it still loops (e.g. on AlreadyGrabbed).

What's your opinion?

On 2011-03-01 08:25:39 +0000, Sam Lantinga wrote:

I was actually thinking about this, this morning! SDL 1.3 is not going to block, and I'll probably be implementing that code today.

See ya!

On 2011-07-20 07:10:50 +0000, Petr Pisar wrote:

Created attachment 648
Proposed patch for SDL-1.2 unblocking GrabNotViewable case

This patch changes behavior of SDL-1.2. If SDL window is not viewable, SDL_WM_GrabInput() will not block and will return failure.

My question is whether this patch is acceptable for inclusion into SDL-1.2 or whether it changes API that applications could expect inappropriately.

On 2011-07-20 07:12:24 +0000, Petr Pisar wrote:

Created attachment 649
Test case

It links to SDL and X11. It moves SDL window out of root window to create not viewable window where XGrabPointer fails.

On 2011-12-29 01:37:04 +0000, Sam Lantinga wrote:

I don't want to change application behavior in 1.2, but you're welcome to submit a patch for SDL 1.3.

Thanks!

On 2018-08-13 06:57:40 +0000, Rene Dudfield wrote:

Note, at least Arch linux includes this: https://git.archlinux.org/svntogit/packages.git/tree/trunk/SDL-1.2.10-GrabNotViewable.patch?h=packages/sdl

On 2018-08-16 20:37:03 +0000, Ozkan Sezer wrote:

Sam: At least two distros (RedHat/Fedora and Arch) has been applying
this patch for quite some time, e.g. for about 7 years. Can we at
least provide it under a 'contrib' directory along with its testcase?

On 2018-08-28 20:07:54 +0000, Sam Lantinga wrote:

Patch added, thanks!
https://hg.libsdl.org/SDL/rev/0f469a8b5110

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant