Merge pull request #2283 from OTHGMars/SDLFocus

Adds handlers for sdl focus events.
This commit is contained in:
Areloch 2018-12-09 15:36:00 -06:00 committed by GitHub
commit 9303fa8089
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -244,7 +244,7 @@ const char * PlatformWindowSDL::getCaption()
void PlatformWindowSDL::setFocus() void PlatformWindowSDL::setFocus()
{ {
SDL_SetWindowGrab( mWindowHandle, SDL_TRUE ); SDL_SetWindowInputFocus(mWindowHandle);
} }
void PlatformWindowSDL::setClientExtent( const Point2I newExtent ) void PlatformWindowSDL::setClientExtent( const Point2I newExtent )
@ -577,9 +577,7 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
{ {
appEvent.trigger(getWindowId(), GainFocus);
_triggerMouseButtonNotify(evt); _triggerMouseButtonNotify(evt);
break; break;
} }
@ -587,6 +585,12 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt)
{ {
switch( evt.window.event ) switch( evt.window.event )
{ {
case SDL_WINDOWEVENT_FOCUS_GAINED:
appEvent.trigger(getWindowId(), GainFocus);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
appEvent.trigger(getWindowId(), LoseFocus);
break;
case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_MAXIMIZED:
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED:
{ {