chvol

Simple interface to set PulseAudio's volume, with graphical feedback! 🔊

Commit
8a5f15b6734ac4dd7119b082d94caa638c2343c4
Parent
e6e26723d50652951304f9494e342fa443456f30
Author
Pablo <pablo-pie@riseup.net>
Date

Improved the X11 platform layer

Made it so that we only repaint the window when we get an Expose event from X11

This is made to avoid stuttering issues with background videos when chvol was called

Diffstats

1 files changed, 11 insertions, 7 deletions

Status Name Changes Insertions Deletions
Modified src/main.c 2 files changed 11 7
diff --git a/src/main.c b/src/main.c
@@ -255,16 +255,20 @@ void x11_launch_window(uint8_t percent, uint32_t timeout_ms)
   };
 
   // ==========================================================================
-  struct timespec start, now;
-  clock_gettime(CLOCK_MONOTONIC, &start);
-  long deadline_ns = start.tv_sec * 1000000000LL + start.tv_nsec
+  struct timespec now;
+  clock_gettime(CLOCK_MONOTONIC, &now);
+  long deadline_ns = now.tv_sec * 1000000000LL + now.tv_nsec
                    + (long)timeout_ms * 1000000LL;
 
   draw_progress_bar(&canvas, percent);
-  for(long now_ns = 0;
-      now_ns <= deadline_ns;
-      clock_gettime(CLOCK_MONOTONIC, &now),
-      now_ns = now.tv_sec * 1000000000LL + now.tv_nsec) {
+
+  XEvent e;
+  for (long now_ns = 0;
+       now_ns <= deadline_ns;
+       clock_gettime(CLOCK_MONOTONIC, &now),
+       now_ns = now.tv_sec * 1000000000LL + now.tv_nsec) {
+    if (!XCheckMaskEvent(d, ExposureMask, &e)) continue;
+
     XPutImage(d, win, DefaultGC(d, screen),
               img, 0, 0, 0, 0, WIN_WIDTH, WIN_HEIGHT);
     XFlush(d);