oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

used draw before show and Xsync instead of Xflush for the overlay so that overlay is blocked until x server finishes processing all draw commands

Commit
0367894e78aadf393a76cef7ddb1d404f4cec85a
Parent
ff0f23e
Author
tonybtw <tonybtw@tonybtw.com>
Date
2025-12-13 07:20:15

Diff

diff --git a/src/bar/font.rs b/src/bar/font.rs
index 0295b4d..1292d8d 100644
--- a/src/bar/font.rs
+++ b/src/bar/font.rs
@@ -131,6 +131,13 @@ impl FontDraw {
             x11::xlib::XFlush(display);
         }
     }
+
+    pub fn sync(&self) {
+        unsafe {
+            let display = x11::xft::XftDrawDisplay(self.xft_draw);
+            x11::xlib::XSync(display, 0);
+        }
+    }
 }
 
 impl Drop for FontDraw {
diff --git a/src/overlay/error.rs b/src/overlay/error.rs
index d953d9c..1bc9688 100644
--- a/src/overlay/error.rs
+++ b/src/overlay/error.rs
@@ -73,8 +73,9 @@ impl ErrorOverlay {
         let y = monitor_y + ((screen_height - height) / 2) as i16;
 
         self.base.configure(connection, x, y, width, height)?;
-        self.base.show(connection)?;
+        self.base.is_visible = true;
         self.draw(connection, font)?;
+        self.base.show(connection)?;
         Ok(())
     }
 
@@ -141,6 +142,7 @@ impl Overlay for ErrorOverlay {
             y += line_height as i16;
         }
         connection.flush()?;
+        self.base.font_draw.sync();
         Ok(())
     }
 }
diff --git a/src/overlay/keybind.rs b/src/overlay/keybind.rs
index 8314413..7114db3 100644
--- a/src/overlay/keybind.rs
+++ b/src/overlay/keybind.rs
@@ -103,10 +103,11 @@ impl KeybindOverlay {
         self.last_shown_at = Some(Instant::now());
         self.max_key_width = max_key_width;
 
-        self.base.show(connection)?;
-
+        self.base.is_visible = true;
         self.draw(connection, font)?;
 
+        self.base.show(connection)?;
+
         Ok(())
     }
 
@@ -305,9 +306,8 @@ impl Overlay for KeybindOverlay {
             y += line_height as i16;
         }
 
-        self.base.font_draw.flush();
-
         connection.flush()?;
+        self.base.font_draw.sync();
 
         Ok(())
     }