]> git.tdb.fi Git - geometrycompositor.git/commitdiff
Only repaint the control interface when necessary
authorMikko Rasa <tdb@tdb.fi>
Mon, 14 Dec 2015 21:08:02 +0000 (23:08 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 14 Dec 2015 21:08:02 +0000 (23:08 +0200)
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

index 292c108bc34538a9399ded9b7672df58fdd1df0e..b268f36f26eab7063bf4622c2da7ef3453e518c7 100644 (file)
@@ -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;