Captures secondary window close events so secondary windows can be closed via hitting the x on the window itself.

This commit is contained in:
Areloch 2020-07-26 15:58:53 -05:00
parent b2c4ff7745
commit 7d0831143c
2 changed files with 17 additions and 5 deletions

View file

@ -101,7 +101,8 @@ mPosition(0,0),
mMouseLocked(false), mMouseLocked(false),
mShouldLockMouse(false), mShouldLockMouse(false),
mSuppressReset(false), mSuppressReset(false),
mMenuHandle(NULL) mMenuHandle(NULL),
mClosing(false)
{ {
mCursorController = new PlatformCursorControllerSDL( this ); mCursorController = new PlatformCursorControllerSDL( this );
@ -582,6 +583,8 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
} }
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
{
if (!mClosing)
{ {
switch (evt.window.event) switch (evt.window.event)
{ {
@ -601,12 +604,18 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
resizeEvent.trigger(getWindowId(), width, height); resizeEvent.trigger(getWindowId(), width, height);
break; break;
} }
case SDL_WINDOWEVENT_CLOSE:
{
appEvent.trigger(getWindowId(), WindowClose);
mClosing = true;
}
default: default:
break; break;
} }
} }
} }
}
} }

View file

@ -87,6 +87,9 @@ private:
/// Menu associated with this window. This is a passive property of the window and is not required to be used at all. /// Menu associated with this window. This is a passive property of the window and is not required to be used at all.
void* mMenuHandle; void* mMenuHandle;
/// Indicates if the window is being closed. This allows us to safely ignore other events like focus being gained or losed after cleanup has begun
bool mClosing;
/// @} /// @}
void _processSDLEvent(SDL_Event &evt); void _processSDLEvent(SDL_Event &evt);