|
@@ -30,8 +30,9 @@ impl Title {
|
|
|
|
|
|
pub fn redraw(&mut self) {
|
|
|
self.context.draw_bg(self.last_pos, self.last_width);
|
|
|
- self.context.draw_text(&self.title, self.last_pos + MARGIN);
|
|
|
- self.last_width = self.context.measure_text(&self.title) + MARGIN;
|
|
|
+ let x = self.last_pos;
|
|
|
+ let w = self.last_width;
|
|
|
+ self.render(x, w);
|
|
|
self.conn.flush();
|
|
|
}
|
|
|
}
|
|
@@ -45,16 +46,20 @@ impl Widget for Title {
|
|
|
self.conn.watch(self.last_win, true);
|
|
|
}
|
|
|
|
|
|
- fn render(&mut self, x: u16) {
|
|
|
+ fn render(&mut self, x: u16, w: u16) {
|
|
|
self.last_pos = x;
|
|
|
- self.context.draw_text(&self.title, self.last_pos + MARGIN);
|
|
|
- self.last_width = self.context.measure_text(&self.title) + MARGIN;
|
|
|
+ self.last_width = w;
|
|
|
+ self.context.draw_text_with_clipping(&self.title, self.last_pos + MARGIN, w - MARGIN * 2);
|
|
|
}
|
|
|
|
|
|
fn width(&mut self) -> u16 {
|
|
|
0
|
|
|
}
|
|
|
|
|
|
+ fn fit_width(&self) -> bool {
|
|
|
+ true
|
|
|
+ }
|
|
|
+
|
|
|
fn handle_event(&mut self, event: &Message) -> bool {
|
|
|
match event {
|
|
|
&Message::XcbEvent(ref event) =>
|