Browse Source

Platform: expose also window events via Sdl2Application::anyEvent().

audio-import
Vladimír Vondruš 7 years ago
parent
commit
9005b3c9aa
  1. 4
      doc/changelog.dox
  2. 6
      src/Magnum/Platform/Sdl2Application.cpp
  3. 9
      src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp

4
doc/changelog.dox

@ -130,6 +130,10 @@ See also:
@subsubsection changelog-latest-changes-platform Platform libraries @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 - 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 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 @ref MAGNUM_TARGET_DESKTOP_GLES is defined. This allows for a smoother

6
src/Magnum/Platform/Sdl2Application.cpp

@ -683,9 +683,15 @@ void Sdl2Application::mainLoopIteration() {
_flags |= Flag::Redraw; _flags |= Flag::Redraw;
#endif #endif
} break; } 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: case SDL_WINDOWEVENT_EXPOSED:
_flags |= Flag::Redraw; _flags |= Flag::Redraw;
if(!(_flags & Flag::NoAnyEvent)) anyEvent(event);
break; break;
default:
if(!(_flags & Flag::NoAnyEvent)) anyEvent(event);
} break; } break;
case SDL_KEYDOWN: case SDL_KEYDOWN:

9
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()}; Debug{} << "text input event:" << std::string{event.text(), event.text().size()};
} }
/* Should fire on currently not handled events, such as minimize/maximize. /* Should fire on currently not handled events, such as minimize/maximize
Comment out to verify correct behavior with the override not present. */ or window focus/blur. Comment out to verify correct behavior with the
override not present. */
void anyEvent(SDL_Event& event) override { 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;
} }
}; };

Loading…
Cancel
Save