sminez / penrose

A library for writing an X11 tiling window manager
https://sminez.github.io/penrose/
MIT License
1.23k stars 86 forks source link

penrose_ui: Setting background color of status bar to black (0x000000 or 0x000000ff) results in crash #283

Closed mejo13 closed 10 months ago

mejo13 commented 10 months ago

Penrose doesn't start but just crashes with this error message:

Error: Custom("Unable to allocate the requested color using Xft")

I figured that this patch fixes this for me.

diff --git a/src/lib.rs b/src/lib.rs
index c7e3a98..a05566c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -263,7 +263,7 @@ impl Color {

     /// Render this color as a #RRGGBB hew color string
     pub fn as_rgb_hex_string(&self) -> String {
-        format!("#{:x}", self.rgb_u32())
+        format!("#{:0>6x}", self.rgb_u32())
     }

     /// 0xRRGGBB representation of this Color (no alpha information)

But i'm unsure whether i fixed my own mistake or if this realy is a bug in penrose_ui?!

sminez commented 10 months ago

Hi @mejo13, thank you for raising this. It does indeed look like it is a bug with how I am generating those strings and the fix you have here is the right one. I've got the fix plus some quick tests around the behviour sorted out so I'll get that pushed now :+1: