summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
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(())
   }