From 9f61e842d01f910349458466c3749d92561f5cde Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Thu, 12 Nov 2026 21:38:14 -0700 Subject: move XftDraw pointers into a new wrapper FontGraphicContext impl Drop :) Force-Push: yes Change-Id: I2a2a488819c9f03205aade5dd5d119c02dd8a3c2 --- src/main.rs | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'src/main.rs') 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(()) } -- cgit 1.4.1