Merge pull request #259 from Areloch/SecondaryWindowCloseFix

Captures secondary window close events
This commit is contained in:
Brian Roberts 2020-07-26 20:08:56 -05:00 committed by GitHub
commit 017f7fafa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View file

@ -101,7 +101,8 @@ mPosition(0,0),
mMouseLocked(false),
mShouldLockMouse(false),
mSuppressReset(false),
mMenuHandle(NULL)
mMenuHandle(NULL),
mClosing(false)
{
mCursorController = new PlatformCursorControllerSDL( this );
@ -583,8 +584,10 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
case SDL_WINDOWEVENT:
{
switch( evt.window.event )
if (!mClosing)
{
switch (evt.window.event)
{
case SDL_WINDOWEVENT_FOCUS_GAINED:
appEvent.trigger(getWindowId(), GainFocus);
break;
@ -595,15 +598,21 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
case SDL_WINDOWEVENT_RESIZED:
{
int width, height;
SDL_GetWindowSize( mWindowHandle, &width, &height );
mVideoMode.resolution.set( width, height );
SDL_GetWindowSize(mWindowHandle, &width, &height);
mVideoMode.resolution.set(width, height);
getGFXTarget()->resetMode();
resizeEvent.trigger(getWindowId(), width, height);
break;
}
case SDL_WINDOWEVENT_CLOSE:
{
appEvent.trigger(getWindowId(), WindowClose);
mClosing = true;
}
default:
break;
}
}
}
}
@ -648,4 +657,4 @@ void PlatformWindowSDL::setKeyboardTranslation(const bool enabled)
mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::TEXT_INPUT);
else
mOwningManager->updateSDLTextInputState(PlatformWindowManagerSDL::KeyboardInputState::RAW_INPUT);
}
}

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.
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);