aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 04162b5..a32cec0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,20 +1,32 @@
1use std::thread; 1use std::thread;
2use std::time::{Duration, Instant}; 2use std::time::{Duration, Instant};
3 3
4struct Configuration { 4use serde::{Deserialize, Serialize};
5
6#[derive(Serialize, Deserialize)]
7struct IndicatorConfig {
5 max_size: u16, // display pixels 8 max_size: u16, // display pixels
6 duration: u16, // milliseconds 9 duration: u16, // milliseconds
7 thickness: u32, // display pixels 10 thickness: u32, // display pixels
8 no_of_circles: u16, 11 no_of_circles: u16,
12 color: u32,
13}
14
15// sane defaults
16impl std::default::Default for IndicatorConfig {
17 fn default() -> IndicatorConfig {
18 IndicatorConfig {
19 max_size: 200u16,
20 duration: 500u16,
21 thickness: 1,
22 no_of_circles: 5,
23 color: 0xFFFFFF,
24 }
25 }
9} 26}
10 27
11fn main() { 28fn main() {
12 let config = Configuration { 29 let config: IndicatorConfig = confy::load("xcursorlocate").unwrap();
13 max_size: 200u16,
14 duration: 500u16,
15 thickness: 1,
16 no_of_circles: 5,
17 };
18 30
19 let padding = 10; // (???) largest circle gets clipped 31 let padding = 10; // (???) largest circle gets clipped
20 let win_width = config.max_size + padding; 32 let win_width = config.max_size + padding;
@@ -83,7 +95,7 @@ fn main() {
83 gfx_ctx, 95 gfx_ctx,
84 win, 96 win,
85 &[ 97 &[
86 (xcb::GC_FOREGROUND, screen.white_pixel()), // TODO: support different colors here 98 (xcb::GC_FOREGROUND, config.color),
87 (xcb::GC_GRAPHICS_EXPOSURES, 0), 99 (xcb::GC_GRAPHICS_EXPOSURES, 0),
88 (xcb::GC_LINE_WIDTH, config.thickness), 100 (xcb::GC_LINE_WIDTH, config.thickness),
89 ], 101 ],