diff --git a/src/Contexts/AbstractXContext.cpp b/src/Contexts/AbstractXContext.cpp index e125604c7..c73d8ecdd 100644 --- a/src/Contexts/AbstractXContext.cpp +++ b/src/Contexts/AbstractXContext.cpp @@ -26,7 +26,7 @@ using namespace std; namespace Magnum { namespace Contexts { -AbstractXContext::AbstractXContext(AbstractGlInterface* glInterface, int&, char**, const string& title, const Math::Vector2& size): glInterface(glInterface), viewportSize(size) { +AbstractXContext::AbstractXContext(AbstractGlInterface* glInterface, int&, char**, const string& title, const Math::Vector2& size): glInterface(glInterface), viewportSize(size), _redraw(true) { /* Get default X display */ display = XOpenDisplay(0); @@ -105,6 +105,7 @@ int AbstractXContext::exec() { if(size != viewportSize) { viewportSize = size; viewportEvent(size); + _redraw = true; } } break; @@ -124,7 +125,10 @@ int AbstractXContext::exec() { } } - drawEvent(); + if(_redraw) { + _redraw = false; + drawEvent(); + } else Corrade::Utility::sleep(5); } return 0; diff --git a/src/Contexts/AbstractXContext.h b/src/Contexts/AbstractXContext.h index 971240d98..c8cca51fb 100644 --- a/src/Contexts/AbstractXContext.h +++ b/src/Contexts/AbstractXContext.h @@ -74,8 +74,8 @@ class AbstractXContext: public AbstractContext { /** @copydoc GlutContext::swapBuffers() */ inline void swapBuffers() { glInterface->swapBuffers(); } - /** @todo implement */ - inline void redraw() {} + /** @copydoc GlutContext::redraw() */ + inline void redraw() { _redraw = true; } /*@}*/ @@ -214,6 +214,8 @@ class AbstractXContext: public AbstractContext { /** @todo Get this from the created window */ Math::Vector2 viewportSize; + + bool _redraw; }; inline void AbstractXContext::keyPressEvent(AbstractXContext::Key, const Math::Vector2&) {}