mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-11-04 01:34:38 +00:00 
			
		
		
		
	@@ -1943,6 +1943,30 @@ extern "C" {
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
#define SDL_HINT_X11_WINDOW_TYPE "SDL_X11_WINDOW_TYPE"
 | 
					#define SDL_HINT_X11_WINDOW_TYPE "SDL_X11_WINDOW_TYPE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 *  \brief  A variable that decides whether to send SDL_QUIT when closing the final window.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  By default, SDL sends an SDL_QUIT event when there is only one window
 | 
				
			||||||
 | 
					 *  and it receives an SDL_WINDOWEVENT_CLOSE event, under the assumption most
 | 
				
			||||||
 | 
					 *  apps would also take the loss of this window as a signal to terminate the
 | 
				
			||||||
 | 
					 *  program.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  However, it's not unreasonable in some cases to have the program continue
 | 
				
			||||||
 | 
					 *  to live on, perhaps to create new windows later.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  Changing this hint to "0" will cause SDL to not send an SDL_QUIT event
 | 
				
			||||||
 | 
					 *  when the final window is requesting to close. Note that in this case,
 | 
				
			||||||
 | 
					 *  there are still other legitimate reasons one might get an SDL_QUIT
 | 
				
			||||||
 | 
					 *  event: choosing "Quit" from the macOS menu bar, sending a SIGINT (ctrl-c)
 | 
				
			||||||
 | 
					 *  on Unix, etc.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  The default value is "1".  This hint can be changed at any time.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *  This hint is available since SDL 2.0.22. Before then, you always get
 | 
				
			||||||
 | 
					 *  an SDL_QUIT event when closing the final window.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					#define SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE "SDL_QUIT_ON_LAST_WINDOW_CLOSE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *  \brief  An enumeration of hint priorities
 | 
					 *  \brief  An enumeration of hint priorities
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@
 | 
				
			|||||||
#include "SDL_events.h"
 | 
					#include "SDL_events.h"
 | 
				
			||||||
#include "SDL_events_c.h"
 | 
					#include "SDL_events_c.h"
 | 
				
			||||||
#include "SDL_mouse_c.h"
 | 
					#include "SDL_mouse_c.h"
 | 
				
			||||||
 | 
					#include "SDL_hints.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int SDLCALL
 | 
					static int SDLCALL
 | 
				
			||||||
RemovePendingSizeChangedAndResizedEvents(void * userdata, SDL_Event *event)
 | 
					RemovePendingSizeChangedAndResizedEvents(void * userdata, SDL_Event *event)
 | 
				
			||||||
@@ -201,8 +201,9 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (windowevent == SDL_WINDOWEVENT_CLOSE) {
 | 
					    if (windowevent == SDL_WINDOWEVENT_CLOSE) {
 | 
				
			||||||
        if ( !window->prev && !window->next ) {
 | 
					        if ( !window->prev && !window->next ) {
 | 
				
			||||||
            /* This is the last window in the list so send the SDL_QUIT event */
 | 
					            if (SDL_GetHintBoolean(SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE, SDL_TRUE)) {
 | 
				
			||||||
            SDL_SendQuit();
 | 
					                SDL_SendQuit();  /* This is the last window in the list so send the SDL_QUIT event */
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user