From 8702b5773dec7d09e7a0702e78bdb1616dd955f4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 14 Dec 2015 23:08:02 +0200 Subject: [PATCH] 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. --- source/control.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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; -- 2.43.0