diff --git a/doc/changelog.dox b/doc/changelog.dox index 88dad9497..0e4191d7b 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -130,6 +130,10 @@ See also: @subsubsection changelog-latest-changes-platform Platform libraries +- @ref Platform::Sdl2Application::anyEvent() is now fired also for window + events that are not exposed through + @ref Platform::Sdl2Application::viewportEvent() "viewportEvent()" or + @ref Platform::Sdl2Application::exitEvent() "exitEvent()" - On OpenGL ES builds, @ref Platform::Sdl2Application now tells SDL whether to use a system GL driver or a dedicated GLES driver based on whether @ref MAGNUM_TARGET_DESKTOP_GLES is defined. This allows for a smoother diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 44ad30403..1ce0d4f44 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -683,9 +683,15 @@ void Sdl2Application::mainLoopIteration() { _flags |= Flag::Redraw; #endif } break; + /* Direct everything that wasn't exposed via a callback to + anyEvent(), so users can implement event handling for + things not present in the Application APIs */ case SDL_WINDOWEVENT_EXPOSED: _flags |= Flag::Redraw; + if(!(_flags & Flag::NoAnyEvent)) anyEvent(event); break; + default: + if(!(_flags & Flag::NoAnyEvent)) anyEvent(event); } break; case SDL_KEYDOWN: diff --git a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp index 688fc39db..70047e24e 100644 --- a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp +++ b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp @@ -70,10 +70,13 @@ struct Sdl2ApplicationTest: Platform::Application { Debug{} << "text input event:" << std::string{event.text(), event.text().size()}; } - /* Should fire on currently not handled events, such as minimize/maximize. - Comment out to verify correct behavior with the override not present. */ + /* Should fire on currently not handled events, such as minimize/maximize + or window focus/blur. Comment out to verify correct behavior with the + override not present. */ void anyEvent(SDL_Event& event) override { - Debug{} << "any event:" << event.type; + Debug d; + d << "any event:" << event.type; + if(event.type == SDL_WINDOWEVENT) d << event.window.event; } };