From: Mikko Rasa Date: Mon, 14 Dec 2015 21:08:02 +0000 (+0200) Subject: Only repaint the control interface when necessary X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8702b5773dec7d09e7a0702e78bdb1616dd955f4;p=geometrycompositor.git Only repaint the control interface when necessary Rendering after every event can cause key repeat events to pile up in the event queue and delay processing the selection events. --- diff --git a/source/control.c b/source/control.c index 292c108..b268f36 100644 --- a/source/control.c +++ b/source/control.c @@ -383,9 +383,11 @@ int interactive(Display *display, GeometryCorrection *corrections, GeometryCorre { XEvent event; KeySym keysym; + int repaint; XNextEvent(display, &event); + repaint = 0; switch(event.type) { case KeyPress: @@ -428,19 +430,26 @@ int interactive(Display *display, GeometryCorrection *corrections, GeometryCorre { update_view(display, &view, &event.xselection); update_pending = 0; + repaint = 1; } break; + case Expose: + repaint = 1; + break; default: printf("event %d\n", event.type); break; } - glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); - glUseProgram(view.programs[0]); - glDrawElements(GL_TRIANGLE_STRIP, view.nelements, GL_UNSIGNED_SHORT, (void *)(12*sizeof(unsigned short))); - glUseProgram(view.programs[1]); - glDrawElements(GL_LINE_STRIP, 11, GL_UNSIGNED_SHORT, NULL); - glXSwapBuffers(display, view.glx_window); + if(repaint) + { + glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glUseProgram(view.programs[0]); + glDrawElements(GL_TRIANGLE_STRIP, view.nelements, GL_UNSIGNED_SHORT, (void *)(12*sizeof(unsigned short))); + glUseProgram(view.programs[1]); + glDrawElements(GL_LINE_STRIP, 11, GL_UNSIGNED_SHORT, NULL); + glXSwapBuffers(display, view.glx_window); + } } return 0;