Advice to handle SDL_EVENT_QUIT for multi-window applications

Hi, I am trying to build a multi-window application and I am looking for advice for handling Alt+F4 AKA SDL_EVENT_QUIT when having multiple windows open. My application structure is 1 main window and then any number of auxiliary windows. Ideally I want to have Alt+F4 work in any window to close it and only close the entire application if the main window is Alt+F4’d. But as far as I can tell there’s no way to determine the active window from the SDL_EVENT_QUIT like there is from SDL_KeyboardEvent which contains a window id field.

Any advice on how to achieve the kind of behaviour I am looking for?

You probably want to disable quit events from closing windows using SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, and then handle SDL_EVENT_WINDOW_CLOSE_REQUESTED to have the behavior you want.

1 Like

Thanks, this is exactly what I was looking for