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
Browse files
+7 −0 src/bar/font.rs
| @@ -131,6 +131,13 @@ impl FontDraw { | |||
| 131 | x11::xlib::XFlush(display); | 131 | x11::xlib::XFlush(display); |
| 132 | } | 132 | } |
| 133 | } | 133 | } |
| 134 | + | ||
| 135 | + pub fn sync(&self) { | ||
| 136 | + unsafe { | ||
| 137 | + let display = x11::xft::XftDrawDisplay(self.xft_draw); | ||
| 138 | + x11::xlib::XSync(display, 0); | ||
| 139 | + } | ||
| 140 | + } | ||
| 134 | } | 141 | } |
| 135 | 142 | ||
| 136 | impl Drop for FontDraw { | 143 | impl Drop for FontDraw { |
+3 −1 src/overlay/error.rs
| @@ -73,8 +73,9 @@ impl ErrorOverlay { | |||
| 73 | let y = monitor_y + ((screen_height - height) / 2) as i16; | 73 | let y = monitor_y + ((screen_height - height) / 2) as i16; |
| 74 | 74 | ||
| 75 | self.base.configure(connection, x, y, width, height)?; | 75 | self.base.configure(connection, x, y, width, height)?; |
| 76 | - self.base.show(connection)?; | 76 | + self.base.is_visible = true; |
| 77 | self.draw(connection, font)?; | 77 | self.draw(connection, font)?; |
| 78 | + self.base.show(connection)?; | ||
| 78 | Ok(()) | 79 | Ok(()) |
| 79 | } | 80 | } |
| 80 | 81 | ||
| @@ -141,6 +142,7 @@ impl Overlay for ErrorOverlay { | |||
| 141 | y += line_height as i16; | 142 | y += line_height as i16; |
| 142 | } | 143 | } |
| 143 | connection.flush()?; | 144 | connection.flush()?; |
| 145 | + self.base.font_draw.sync(); | ||
| 144 | Ok(()) | 146 | Ok(()) |
| 145 | } | 147 | } |
| 146 | } | 148 | } |
+4 −4 src/overlay/keybind.rs
| @@ -103,10 +103,11 @@ impl KeybindOverlay { | |||
| 103 | self.last_shown_at = Some(Instant::now()); | 103 | self.last_shown_at = Some(Instant::now()); |
| 104 | self.max_key_width = max_key_width; | 104 | self.max_key_width = max_key_width; |
| 105 | 105 | ||
| 106 | - self.base.show(connection)?; | 106 | + self.base.is_visible = true; |
| 107 | - | ||
| 108 | self.draw(connection, font)?; | 107 | self.draw(connection, font)?; |
| 109 | 108 | ||
| 109 | + self.base.show(connection)?; | ||
| 110 | + | ||
| 110 | Ok(()) | 111 | Ok(()) |
| 111 | } | 112 | } |
| 112 | 113 | ||
| @@ -305,9 +306,8 @@ impl Overlay for KeybindOverlay { | |||
| 305 | y += line_height as i16; | 306 | y += line_height as i16; |
| 306 | } | 307 | } |
| 307 | 308 | ||
| 308 | - self.base.font_draw.flush(); | ||
| 309 | - | ||
| 310 | connection.flush()?; | 309 | connection.flush()?; |
| 310 | + self.base.font_draw.sync(); | ||
| 311 | 311 | ||
| 312 | Ok(()) | 312 | Ok(()) |
| 313 | } | 313 | } |