Browse Source

AbstractXApplication: add mainLoopIteration similar to Sdl2Application

pull/387/head
Konstantinos Chatzilygeroudis 7 years ago
parent
commit
432aca900d
  1. 10
      src/Magnum/Platform/AbstractXApplication.cpp
  2. 12
      src/Magnum/Platform/AbstractXApplication.h

10
src/Magnum/Platform/AbstractXApplication.cpp

@ -126,7 +126,12 @@ int AbstractXApplication::exec() {
/* Show window */
XMapWindow(_display, _window);
while(!(_flags & Flag::Exit)) {
while(mainLoopIteration()) {}
return 0;
}
bool AbstractXApplication::mainLoopIteration() {
XEvent event;
/* Closed window */
@ -172,9 +177,8 @@ int AbstractXApplication::exec() {
_flags &= ~Flag::Redraw;
drawEvent();
} else Utility::System::sleep(5);
}
return 0;
return !(_flags & Flag::Exit);
}
void AbstractXApplication::viewportEvent(ViewportEvent& event) {

12
src/Magnum/Platform/AbstractXApplication.h

@ -109,6 +109,18 @@ class AbstractXApplication {
*/
int exec();
/**
* @brief Run one iteration of application main loop
* @return @cpp false @ce if @ref exit() was called and the application
* should exit, @cpp true @ce otherwise
*
* Called internally from @ref exec(). If you want to have better
* control over how the main loop behaves, you can call this function
* yourself from your own `main()` function instead of it being called
* automatically from @ref exec().
*/
bool mainLoopIteration();
/** @brief Exit application main loop */
void exit() { _flags |= Flag::Exit; }

Loading…
Cancel
Save