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 3232

Summary: Window grabbing do not work on Linux
Product: SDL Reporter: Imants <capsexe>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED ABANDONED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: philipp.wiesemann
Version: 2.0.4   
Hardware: x86_64   
OS: Linux   

Description Imants 2016-01-10 11:09:16 UTC
SetWindowGrab, SDL_GetGrabbedWindow() and GetWindowGrab do not work how intended on Linux. 

example:

window = SDL_CreateWindow( "test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
SDL_SetWindowGrab(window, SDL_TRUE);
SDL_Window* wnd = SDL_GetGrabbedWindow(); //returns NULL
SDL_bool grabed = SDL_GetWindowGrab(window); //returns SDL_FALSE
if (wnd != window && grabed != SDL_TRUE)
  return 0; //Fails and exits
Comment 1 Philipp Wiesemann 2016-01-10 16:29:15 UTC
The example works with SDL_PumpEvents() after SDL_SetWindowGrab().
Comment 2 Imants 2016-01-10 18:19:41 UTC
Unfortunately it did not help me :(

Full test example:

int main( int argc, char* args[] )
{
	SDL_Window* window = NULL;

	if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
	{
		printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
		return 0;
	}

    window = SDL_CreateWindow( "test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );

    SDL_SetWindowGrab(window, SDL_TRUE);
    SDL_PumpEvents();
    SDL_Window* wnd = SDL_GetGrabbedWindow();
    SDL_bool grabed = SDL_GetWindowGrab(window);
    if (wnd != window && grabed != SDL_TRUE)
        return 0; //Application exits

    SDL_Event e;
    while (1) {
        if (SDL_WaitEvent(&e)) {
            if (e.type == SDL_QUIT) {
                break;
            }
        }
    }
    //Destroy window
    SDL_DestroyWindow( window );

    //Quit SDL subsystems
    SDL_Quit();

    return 0;

}
Comment 3 Ryan C. Gordon 2018-08-06 21:20:23 UTC
Hello, and sorry if you're getting dozens of copies of this message by email.

We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc.

Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report.

So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues.

(please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!)

Thanks,
--ryan.