Feedback on page SDL_SetWindowGrab
I have seen at least a few "complaints" scattered around the internet about SDL_SetWindowGrab() not working. The reason is that it is not clear on the SDL Wiki documentation that the use of the function must be followed up by an event poll of some form for it to function.
#include "SDL.h"
int main(int argc, char* argv[])
{
SDL_Window* aWindow = NULL;
SDL_Surface* aSurface = NULL;
aWindow = SDL_CreateWindow("Test Grab", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
600, 400, SDL_WINDOW_SHOWN);
aSurface = SDL_GetWindowSurface(aWindow);
SDL_RaiseWindow(aWindow);
SDL_SetWindowGrab(aWindow, SDL_TRUE);
SDL_PumpEvents(); // This is the important bit. Grabbing a window is treated as an event.
// At the very least, you must use SDL_PumpEvents().
// Using any SDL_Event loop has the same effect of enabling SDL_SetWindowGrab() functionality.
SDL_Delay(3000);
SDL_SetWindowGrab(aWindow, SDL_FALSE);
//SDL_PumpEvents(); // Not neccesary to free grab, apparently
SDL_Delay(1000);
SDL_FreeSurface(aSurface);
SDL_DestroyWindow(aWindow);
return 0;
}
A note in Remarks to this effect might be helpful, something as simple as the following would do:
"SDL_SetWindowGrab() is treated as an SDL_Event and should be followed up by any form of event polling, for example SDL_PumpEvents()"
Many thanks.
This sounds more like a bug in SDL than a behavior we should document.
CC @slouken
Ok. Thanks for the reply. So, if it is a probable bug on a todo list now, I will avoid posting any reference to the suggested walk around. All the best.
Sent from Yahoo Mail for iPad
On Thursday, December 30, 2021, 10:57 AM, Ryan C. Gordon @.***> wrote:
This sounds more like a bug in SDL than a behavior we should document.
— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>
Sending this over to the SDL issue tracker so someone can verify if this is still an issue. The original comment is in reference to SDL2.