diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/src/main.rs b/src/main.rs index ddb58cd..f70a22d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,11 +4,7 @@ use crate::x::*; use std::sync::Arc; use x11::xrender::XRenderColor; -use x11::xft::{ - XftFontOpenName, - XftDrawCreate, XftDrawDestroy, - XftColor -}; +use x11::xft::XftColor; use xcb::{ Xid }; use xcb::x::{ ClientMessageData, @@ -315,27 +311,14 @@ impl Dock { fn draw_text(&self) -> xcb::Result<()> { - let xlib_display = self.connection().get_xlib_display(); - let x_visual = unsafe { - x11::xlib::XDefaultVisual(xlib_display, - self.display().screen_index()) - }; - - let xft_context = unsafe { - XftDrawCreate(xlib_display, - self.window().window_id().resource_id() as u64, - x_visual, - self.screen().default_colormap().resource_id() as u64) - }; + let context = FontGraphicContext::new(self.window())?; let xft_color = XftColor { pixel: self.configuration.foreground_pixel as u64, color: self.configuration.foreground_render_color, }; let text = "playful cool fic tech nonfic"; - self.font.draw(xft_context, &xft_color, 12, 25, text)?; - - unsafe { XftDrawDestroy(xft_context) }; + self.font.draw(&context, &xft_color, 12, 25, text)?; Ok(()) } |