summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-11-12 22:40:42 -0700
committerIrene Knapp <ireneista@irenes.space>2026-11-12 22:40:42 -0700
commite521722f5fd339ef72ee51af88f3941b71b1d9cf (patch)
tree300734c3a95ad6c73908e8f203a1d70b53379be0 /src/main.rs
parent9f61e842d01f910349458466c3749d92561f5cde (diff)
okay, all the color stuff is well-organized now HEAD main
since color is one of those "the data is the point" types, rather than one that encapsulates remote state, both the xcb and xft stuff is handled by a single type, Color.

Force-Push: yes
Change-Id: I192c40b13dd9040897cbf043d5dd84d5a73f607b
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/main.rs b/src/main.rs
index f70a22d..9decfbd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,8 +3,6 @@ use crate::x::*;
 
 use std::sync::Arc;
 
-use x11::xrender::XRenderColor;
-use x11::xft::XftColor;
 use xcb::{ Xid };
 use xcb::x::{
   ClientMessageData,
@@ -24,9 +22,8 @@ mod x;
 struct DockConfiguration {
   thickness: u16,
   side: Side,
-  background_pixel: u32,
-  foreground_pixel: u32,
-  foreground_render_color: XRenderColor,
+  background: Color,
+  foreground: Color,
   use_rounded_inside_corners: bool,
   use_rounded_outside_corners: bool,
 }
@@ -47,19 +44,15 @@ fn main() -> xcb::Result<()> {
   let display = Arc::new(Display::new()?);
 
   // #d4ffcc
-  let background_pixel = display.allocate_color(54484, 65535, 52428)?;
+  let background = display.allocate_color(54484, 65535, 52428)?;
 
   // #5c01be
-  let foreground_pixel = display.allocate_color(23644, 257, 48830)?;
-  let foreground_render_color = XRenderColor {
-    red: 23644, green: 257, blue: 48830, alpha: 65535,
-  };
+  let foreground = display.allocate_color(23644, 257, 48830)?;
 
   let dock = Dock::new(Arc::clone(&display), DockConfiguration {
     thickness: 34,
     side: Side::Bottom,
-    background_pixel,
-    foreground_pixel, foreground_render_color,
+    background, foreground,
     use_rounded_inside_corners: false,
     use_rounded_outside_corners: true,
   })?;
@@ -110,7 +103,7 @@ impl Dock {
       class: WindowClass::InputOutput,
       visual: screen.root_visual(),
       value_list: &[
-        Cw::BackPixel(configuration.background_pixel),
+        Cw::BackPixel(configuration.background.as_pixel()),
         Cw::EventMask(EventMask::EXPOSURE | EventMask::BUTTON_PRESS),
       ],
     })?;
@@ -275,7 +268,7 @@ impl Dock {
     let cookie = self.send_request_checked(&ChangeGc {
       gc: context.graphic_context_id(),
       value_list: &[
-        Gc::Foreground(self.configuration.background_pixel),
+        Gc::Foreground(self.configuration.background.as_pixel()),
       ],
     });
     self.check_request(cookie)?;
@@ -312,13 +305,10 @@ impl Dock {
 
   fn draw_text(&self) -> xcb::Result<()> {
     let context = FontGraphicContext::new(self.window())?;
-
-    let xft_color = XftColor {
-      pixel: self.configuration.foreground_pixel as u64,
-      color: self.configuration.foreground_render_color,
-    };
+    let color = &self.configuration.foreground;
     let text = "playful cool fic tech nonfic";
-    self.font.draw(&context, &xft_color, 12, 25, text)?;
+
+    self.font.draw(&context, color, 12, 25, text)?;
 
     Ok(())
   }