When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
authorkrogoway
Thu, 27 Jan 2011 15:58:30 -0600
changeset 5113686d795b1b29
parent 5112 39772ccf7ddd
child 5114 e337f792c6a7
When the last window is closed and the SDL_WINDOWEVENT_CLOSE event is sent, send the SDL_QUIT event.
Common.c now destroys the SDL_Window upon a SDL_WINDOWEVENT_CLOSE event to ensure that all windows get closed properly and the new code to handle the last window closes gets executed.
src/events/SDL_windowevents.c
test/common.c
     1.1 --- a/src/events/SDL_windowevents.c	Thu Jan 27 14:54:20 2011 -0800
     1.2 +++ b/src/events/SDL_windowevents.c	Thu Jan 27 15:58:30 2011 -0600
     1.3 @@ -176,6 +176,14 @@
     1.4  
     1.5          posted = (SDL_PushEvent(&event) > 0);
     1.6      }
     1.7 +	
     1.8 +	if (windowevent == SDL_WINDOWEVENT_CLOSE) {
     1.9 +		if ( !window->prev && !window->next ) {
    1.10 +			// This is the last window in the list so send the SDL_QUIT event
    1.11 +			SDL_SendQuit();
    1.12 +		}
    1.13 +	}
    1.14 +
    1.15      return (posted);
    1.16  }
    1.17  
     2.1 --- a/test/common.c	Thu Jan 27 14:54:20 2011 -0800
     2.2 +++ b/test/common.c	Thu Jan 27 15:58:30 2011 -0600
     2.3 @@ -1038,7 +1038,12 @@
     2.4      case SDL_WINDOWEVENT:
     2.5          switch (event->window.event) {
     2.6          case SDL_WINDOWEVENT_CLOSE:
     2.7 -            *done = 1;
     2.8 +			{
     2.9 +				SDL_Window *pWindow = SDL_GetWindowFromID(event->window.windowID);
    2.10 +				if ( pWindow ) {
    2.11 +					SDL_DestroyWindow( pWindow );
    2.12 +				}
    2.13 +			}
    2.14              break;
    2.15          }
    2.16          break;