Преглед изворни кода

Don't draw empty text

For some reason this causes flickering, I didn't bother looking too
deeply into it, but it probably has something to do with the message
being broken
Thomas Dy пре 7 година
родитељ
комит
82d08509a2
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5 3
      src/ui/widget.rs

+ 5 - 3
src/ui/widget.rs

@@ -63,8 +63,10 @@ impl DrawContext {
     }
 
     pub fn draw_text(&self, name: &str, x: u16) {
-        let text = self.fonts.create_renderable_text(name);
-        let baseline = 20 - self.fonts.default_offset(20);
-        text.render(&self.conn, self.pen, self.picture, x, baseline as u16);
+        if !name.is_empty() {
+            let text = self.fonts.create_renderable_text(name);
+            let baseline = 20 - self.fonts.default_offset(20);
+            text.render(&self.conn, self.pen, self.picture, x, baseline as u16);
+        }
     }
 }