C has good C interop
Browse files
+19 −7 src/bar/bar.rs
| @@ -76,7 +76,6 @@ impl Bar { | ||
| 76 | 76 | .background(config.scheme_normal.background), |
| 77 | 77 | )?; |
| 78 | 78 | |
| 79 | - // Set cursor using xlib after window creation | |
| 80 | 79 | unsafe { |
| 81 | 80 | x11::xlib::XDefineCursor(display, window as u64, cursor as u64); |
| 82 | 81 | } |
| @@ -266,7 +265,12 @@ impl Bar { | ||
| 266 | 265 | let underline_x = x_position + (underline_padding / 2) as i16; |
| 267 | 266 | |
| 268 | 267 | unsafe { |
| 269 | - let gc = x11::xlib::XCreateGC(display, self.surface.pixmap(), 0, std::ptr::null_mut()); | |
| 268 | + let gc = x11::xlib::XCreateGC( | |
| 269 | + display, | |
| 270 | + self.surface.pixmap(), | |
| 271 | + 0, | |
| 272 | + std::ptr::null_mut(), | |
| 273 | + ); | |
| 270 | 274 | x11::xlib::XSetForeground(display, gc, scheme.underline as u64); |
| 271 | 275 | x11::xlib::XFillRectangle( |
| 272 | 276 | display, |
| @@ -327,9 +331,13 @@ impl Bar { | ||
| 327 | 331 | let top_padding = 4; |
| 328 | 332 | let text_y = top_padding + font.ascent(); |
| 329 | 333 | |
| 330 | - self.surface | |
| 331 | - .font_draw() | |
| 332 | - .draw_text(font, block.color(), x_position, text_y, &text); | |
| 334 | + self.surface.font_draw().draw_text( | |
| 335 | + font, | |
| 336 | + block.color(), | |
| 337 | + x_position, | |
| 338 | + text_y, | |
| 339 | + &text, | |
| 340 | + ); | |
| 333 | 341 | |
| 334 | 342 | if self.block_underlines[i] { |
| 335 | 343 | let font_height = font.height(); |
| @@ -342,8 +350,12 @@ impl Bar { | ||
| 342 | 350 | let underline_x = x_position - (underline_padding / 2) as i16; |
| 343 | 351 | |
| 344 | 352 | unsafe { |
| 345 | - let gc = | |
| 346 | - x11::xlib::XCreateGC(display, self.surface.pixmap(), 0, std::ptr::null_mut()); | |
| 353 | + let gc = x11::xlib::XCreateGC( | |
| 354 | + display, | |
| 355 | + self.surface.pixmap(), | |
| 356 | + 0, | |
| 357 | + std::ptr::null_mut(), | |
| 358 | + ); | |
| 347 | 359 | x11::xlib::XSetForeground(display, gc, block.color() as u64); |
| 348 | 360 | x11::xlib::XFillRectangle( |
| 349 | 361 | display, |
+15 −7 src/tab_bar.rs
| @@ -64,7 +64,6 @@ impl TabBar { | ||
| 64 | 64 | .background(scheme_normal.background), |
| 65 | 65 | )?; |
| 66 | 66 | |
| 67 | - // Set cursor using xlib after window creation | |
| 68 | 67 | unsafe { |
| 69 | 68 | x11::xlib::XDefineCursor(display, window as u64, cursor as u64); |
| 70 | 69 | } |
| @@ -116,7 +115,8 @@ impl TabBar { | ||
| 116 | 115 | connection.flush()?; |
| 117 | 116 | |
| 118 | 117 | unsafe { |
| 119 | - let gc = x11::xlib::XCreateGC(self.display, self.surface.pixmap(), 0, std::ptr::null_mut()); | |
| 118 | + let gc = | |
| 119 | + x11::xlib::XCreateGC(self.display, self.surface.pixmap(), 0, std::ptr::null_mut()); | |
| 120 | 120 | x11::xlib::XSetForeground(self.display, gc, self.scheme_normal.background as u64); |
| 121 | 121 | x11::xlib::XFillRectangle( |
| 122 | 122 | self.display, |
| @@ -158,17 +158,25 @@ impl TabBar { | ||
| 158 | 158 | let top_padding = 6; |
| 159 | 159 | let text_y = top_padding + font.ascent(); |
| 160 | 160 | |
| 161 | - self.surface | |
| 162 | - .font_draw() | |
| 163 | - .draw_text(font, scheme.foreground, text_x, text_y, &display_title); | |
| 161 | + self.surface.font_draw().draw_text( | |
| 162 | + font, | |
| 163 | + scheme.foreground, | |
| 164 | + text_x, | |
| 165 | + text_y, | |
| 166 | + &display_title, | |
| 167 | + ); | |
| 164 | 168 | |
| 165 | 169 | if is_focused { |
| 166 | 170 | let underline_height = 3; |
| 167 | 171 | let underline_y = self.height as i16 - underline_height; |
| 168 | 172 | |
| 169 | 173 | unsafe { |
| 170 | - let gc = | |
| 171 | - x11::xlib::XCreateGC(self.display, self.surface.pixmap(), 0, std::ptr::null_mut()); | |
| 174 | + let gc = x11::xlib::XCreateGC( | |
| 175 | + self.display, | |
| 176 | + self.surface.pixmap(), | |
| 177 | + 0, | |
| 178 | + std::ptr::null_mut(), | |
| 179 | + ); | |
| 172 | 180 | x11::xlib::XSetForeground(self.display, gc, scheme.underline as u64); |
| 173 | 181 | x11::xlib::XFillRectangle( |
| 174 | 182 | self.display, |