summaryrefslogtreecommitdiff
path: root/src/colours.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-06-06 21:39:23 +0100
committertcmal <me@aria.rip>2024-06-06 21:39:23 +0100
commit66e3423828892a72e5e525f2dc8d5ad91e634445 (patch)
tree5dfd94005edbde91adc7a18e5b9a81a5c87816ec /src/colours.rs
parent266d39668bcee886cc7fecdb0f2c7b0b3302b20e (diff)
track focus and draw borders
Diffstat (limited to 'src/colours.rs')
-rw-r--r--src/colours.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/colours.rs b/src/colours.rs
new file mode 100644
index 0000000..6f862c3
--- /dev/null
+++ b/src/colours.rs
@@ -0,0 +1,44 @@
+use crate::error::*;
+use xcb::{
+ x::{AllocColor, Colormap},
+ Connection,
+};
+
+pub struct Colours {
+ cmap: Colormap,
+ border_normal: u32,
+ border_focused: u32,
+}
+
+impl Colours {
+ pub fn new_with(conn: &Connection, cmap: Colormap) -> Result<Self> {
+ let (border_normal, border_focused) = (
+ conn.wait_for_reply(conn.send_request(&AllocColor {
+ cmap,
+ red: 0,
+ green: 0,
+ blue: 0,
+ }))?,
+ conn.wait_for_reply(conn.send_request(&AllocColor {
+ cmap,
+ red: u16::MAX,
+ green: 0,
+ blue: u16::MAX,
+ }))?,
+ );
+
+ Ok(Self {
+ cmap,
+ border_normal: border_normal.pixel(),
+ border_focused: border_focused.pixel(),
+ })
+ }
+
+ pub fn border_normal(&self) -> u32 {
+ self.border_normal
+ }
+
+ pub fn border_focused(&self) -> u32 {
+ self.border_focused
+ }
+}