aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Cargo.lock149
-rw-r--r--Cargo.toml8
-rw-r--r--src/main.rs28
4 files changed, 176 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 088ba6b..f2e972d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,9 +2,5 @@
2# will have compiled files and executables 2# will have compiled files and executables
3/target/ 3/target/
4 4
5# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7Cargo.lock
8
9# These are backup files generated by rustfmt 5# These are backup files generated by rustfmt
10**/*.rs.bk 6**/*.rs.bk
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..38e044c
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,149 @@
1# This file is automatically @generated by Cargo.
2# It is not intended for manual editing.
3[[package]]
4name = "cfg-if"
5version = "0.1.10"
6source = "registry+https://github.com/rust-lang/crates.io-index"
7
8[[package]]
9name = "confy"
10version = "0.3.1"
11source = "registry+https://github.com/rust-lang/crates.io-index"
12dependencies = [
13 "directories 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
14 "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
15 "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
16]
17
18[[package]]
19name = "directories"
20version = "0.10.0"
21source = "registry+https://github.com/rust-lang/crates.io-index"
22dependencies = [
23 "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
24]
25
26[[package]]
27name = "libc"
28version = "0.2.65"
29source = "registry+https://github.com/rust-lang/crates.io-index"
30
31[[package]]
32name = "log"
33version = "0.4.8"
34source = "registry+https://github.com/rust-lang/crates.io-index"
35dependencies = [
36 "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
37]
38
39[[package]]
40name = "proc-macro2"
41version = "1.0.6"
42source = "registry+https://github.com/rust-lang/crates.io-index"
43dependencies = [
44 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
45]
46
47[[package]]
48name = "quote"
49version = "1.0.2"
50source = "registry+https://github.com/rust-lang/crates.io-index"
51dependencies = [
52 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
53]
54
55[[package]]
56name = "serde"
57version = "1.0.103"
58source = "registry+https://github.com/rust-lang/crates.io-index"
59dependencies = [
60 "serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
61]
62
63[[package]]
64name = "serde_derive"
65version = "1.0.103"
66source = "registry+https://github.com/rust-lang/crates.io-index"
67dependencies = [
68 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
69 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
70 "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
71]
72
73[[package]]
74name = "syn"
75version = "1.0.8"
76source = "registry+https://github.com/rust-lang/crates.io-index"
77dependencies = [
78 "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
79 "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
80 "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
81]
82
83[[package]]
84name = "toml"
85version = "0.4.10"
86source = "registry+https://github.com/rust-lang/crates.io-index"
87dependencies = [
88 "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
89]
90
91[[package]]
92name = "unicode-xid"
93version = "0.2.0"
94source = "registry+https://github.com/rust-lang/crates.io-index"
95
96[[package]]
97name = "winapi"
98version = "0.3.8"
99source = "registry+https://github.com/rust-lang/crates.io-index"
100dependencies = [
101 "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
102 "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
103]
104
105[[package]]
106name = "winapi-i686-pc-windows-gnu"
107version = "0.4.0"
108source = "registry+https://github.com/rust-lang/crates.io-index"
109
110[[package]]
111name = "winapi-x86_64-pc-windows-gnu"
112version = "0.4.0"
113source = "registry+https://github.com/rust-lang/crates.io-index"
114
115[[package]]
116name = "xcb"
117version = "0.9.0"
118source = "registry+https://github.com/rust-lang/crates.io-index"
119dependencies = [
120 "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
121 "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
122]
123
124[[package]]
125name = "xcursorlocate"
126version = "0.1.1"
127dependencies = [
128 "confy 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
129 "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
130 "xcb 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
131]
132
133[metadata]
134"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
135"checksum confy 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4b1400cd0dae7f27d2c7ced9492e1398d2e2df614570092a4936c73b416dedea"
136"checksum directories 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc2561db021b6f1321d0f16b67ed28ce843ef4610dfaa432e3ffa2e8a3050ebf"
137"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8"
138"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
139"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27"
140"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
141"checksum serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "1217f97ab8e8904b57dd22eb61cde455fa7446a9c1cf43966066da047c1f3702"
142"checksum serde_derive 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "a8c6faef9a2e64b0064f48570289b4bf8823b7581f1d6157c1b52152306651d0"
143"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92"
144"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
145"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
146"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
147"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
148"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
149"checksum xcb 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62056f63138b39116f82a540c983cc11f1c90cd70b3d492a70c25eaa50bd22a6"
diff --git a/Cargo.toml b/Cargo.toml
index 596db35..e4517b0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,11 +1,17 @@
1[package] 1[package]
2name = "xcursorlocate" 2name = "xcursorlocate"
3version = "0.1.0" 3version = "0.1.1"
4authors = ["Akshay <[email protected]>"] 4authors = ["Akshay <[email protected]>"]
5edition = "2018" 5edition = "2018"
6 6
7[dependencies]
8confy = "0.3.1"
7 9
8[dependencies.xcb] 10[dependencies.xcb]
9version = "0.9" 11version = "0.9"
10features = ["shape"] # NOTE: mapping and unmapping circular windows might be faster 12features = ["shape"] # NOTE: mapping and unmapping circular windows might be faster
11 13
14[dependencies.serde]
15version = "1.0.103"
16features = ["derive"]
17
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 ],