summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-11-12 21:38:14 -0700
committerIrene Knapp <ireneista@irenes.space>2026-11-12 21:38:14 -0700
commit9f61e842d01f910349458466c3749d92561f5cde (patch)
tree595153f4d77646dfe2f6841292a084b78a844d39 /src/main.rs
parent7138ace1c1f97f85509278e50b72eb62ed0fd315 (diff)
move XftDraw pointers into a new wrapper FontGraphicContext
impl Drop :)

Force-Push: yes
Change-Id: I2a2a488819c9f03205aade5dd5d119c02dd8a3c2
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
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(())
   }