summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxVerevkin <maxxverrr@gmail.com>2023-01-24 00:56:39 +0200
committerMaxVerevkin <maxxverrr@gmail.com>2023-01-24 00:56:39 +0200
commitb04f6e8190c691261c8eb94466d95c34ec6164a7 (patch)
tree3c0988f45a65e74d368a0751030003449554124b
parent0467b9f964f7ee91c0d679feedaf62626f6fe065 (diff)
downloadi3bar-mango-b04f6e8190c691261c8eb94466d95c34ec6164a7.tar.gz
update dependencies
-rw-r--r--Cargo.lock241
-rw-r--r--Cargo.toml9
-rw-r--r--src/bar.rs22
-rw-r--r--src/cursor.rs2
-rw-r--r--src/main.rs2
-rw-r--r--src/protocol.rs8
-rw-r--r--src/state.rs456
7 files changed, 435 insertions, 305 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 039669f..c3235d8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -18,17 +18,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61"
[[package]]
-name = "atty"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-dependencies = [
- "hermit-abi",
- "libc",
- "winapi",
-]
-
-[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -72,6 +61,12 @@ dependencies = [
]
[[package]]
+name = "cc"
+version = "1.0.78"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
+
+[[package]]
name = "cfg-expr"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -118,18 +113,39 @@ dependencies = [
[[package]]
name = "env_logger"
-version = "0.9.3"
+version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7"
+checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
dependencies = [
- "atty",
"humantime",
+ "is-terminal",
"log",
"regex",
"termcolor",
]
[[package]]
+name = "errno"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
+dependencies = [
+ "errno-dragonfly",
+ "libc",
+ "winapi",
+]
+
+[[package]]
+name = "errno-dragonfly"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
+dependencies = [
+ "cc",
+ "libc",
+]
+
+[[package]]
name = "futures-channel"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -295,6 +311,12 @@ dependencies = [
]
[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+
+[[package]]
name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -302,9 +324,9 @@ checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]]
name = "hermit-abi"
-version = "0.1.19"
+version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
+checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
dependencies = [
"libc",
]
@@ -329,14 +351,45 @@ dependencies = [
"serde_json",
"thiserror",
"tokio",
- "toml",
+ "toml 0.6.0",
"wayrs-client",
- "wayrs-scanner",
"wayrs-shm-alloc",
"xcursor",
]
[[package]]
+name = "indexmap"
+version = "1.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
+dependencies = [
+ "autocfg",
+ "hashbrown",
+]
+
+[[package]]
+name = "io-lifetimes"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e"
+dependencies = [
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "is-terminal"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
+dependencies = [
+ "hermit-abi",
+ "io-lifetimes",
+ "rustix",
+ "windows-sys",
+]
+
+[[package]]
name = "itoa"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -349,6 +402,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
+name = "linux-raw-sys"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
+
+[[package]]
name = "log"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -401,9 +460,9 @@ dependencies = [
[[package]]
name = "nix"
-version = "0.26.1"
+version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694"
+checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
dependencies = [
"bitflags",
"cfg-if",
@@ -414,19 +473,28 @@ dependencies = [
[[package]]
name = "nom"
-version = "7.1.1"
+version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
+checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
+name = "nom8"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
name = "once_cell"
-version = "1.16.0"
+version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
+checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
[[package]]
name = "pango"
@@ -507,7 +575,7 @@ checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9"
dependencies = [
"once_cell",
"thiserror",
- "toml",
+ "toml 0.5.11",
]
[[package]]
@@ -536,18 +604,18 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.49"
+version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
+checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quick-xml"
-version = "0.26.0"
+version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd"
+checksum = "ffc053f057dd768a56f62cd7e434c42c831d296968997e9ac1f76ea7c2d14c41"
dependencies = [
"memchr",
]
@@ -583,9 +651,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.7.0"
+version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
+checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
dependencies = [
"aho-corasick",
"memchr",
@@ -599,6 +667,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
+name = "rustix"
+version = "0.36.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03"
+dependencies = [
+ "bitflags",
+ "errno",
+ "io-lifetimes",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys",
+]
+
+[[package]]
name = "ryu"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -636,6 +718,15 @@ dependencies = [
]
[[package]]
+name = "serde_spanned"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2c68e921cef53841b8925c2abadd27c9b891d9613bdc43d6b823062866df38e8"
+dependencies = [
+ "serde",
+]
+
+[[package]]
name = "shmemfdrs"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -704,15 +795,15 @@ dependencies = [
"cfg-expr",
"heck",
"pkg-config",
- "toml",
+ "toml 0.5.11",
"version-compare",
]
[[package]]
name = "termcolor"
-version = "1.1.3"
+version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
+checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
dependencies = [
"winapi-util",
]
@@ -739,9 +830,9 @@ dependencies = [
[[package]]
name = "tokio"
-version = "1.23.0"
+version = "1.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46"
+checksum = "597a12a59981d9e3c38d216785b0c37399f6e415e8d0712047620f189371b0bb"
dependencies = [
"autocfg",
"bytes",
@@ -768,14 +859,48 @@ dependencies = [
[[package]]
name = "toml"
-version = "0.5.10"
+version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
+checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
dependencies = [
"serde",
]
[[package]]
+name = "toml"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fb9d890e4dc9298b70f740f615f2e05b9db37dce531f6b24fb77ac993f9f217"
+dependencies = [
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+ "toml_edit",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "toml_edit"
+version = "0.18.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "729bfd096e40da9c001f778f5cdecbd2957929a24e10e5883d9392220a751581"
+dependencies = [
+ "indexmap",
+ "nom8",
+ "serde",
+ "serde_spanned",
+ "toml_datetime",
+]
+
+[[package]]
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -807,9 +932,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wayrs-client"
-version = "0.2.1"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36735e4fa01ade0a22aa5366c0245e49e955b7088379127d86b8bb14f2427eac"
+checksum = "2bbd13520ff20d66b6ac68db7f8b176f41d47577a76cf03c97dc72294978d432"
dependencies = [
"nix",
"thiserror",
@@ -819,9 +944,9 @@ dependencies = [
[[package]]
name = "wayrs-scanner"
-version = "0.2.0"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3957115661161e3f6efcadc6f09c894e3ed8536374baeffedc5e6c80a680b517"
+checksum = "0c931c2e42e89b78744eca04e7aef021759063d0dd7aa722ee97c0e205fde7ef"
dependencies = [
"convert_case",
"proc-macro2",
@@ -832,9 +957,9 @@ dependencies = [
[[package]]
name = "wayrs-shm-alloc"
-version = "0.2.0"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e3811c51fb48e8bd025ea8005f9a724e97ef955912eef050eedd257507c2c78"
+checksum = "eb9c74736663be1fc43219fab7cf694315667f4c7fb6958e1302d41dd684df64"
dependencies = [
"memmap2",
"shmemfdrs",
@@ -889,45 +1014,45 @@ dependencies = [
[[package]]
name = "windows_aarch64_gnullvm"
-version = "0.42.0"
+version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
+checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_msvc"
-version = "0.42.0"
+version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
+checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
[[package]]
name = "windows_i686_gnu"
-version = "0.42.0"
+version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
+checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
[[package]]
name = "windows_i686_msvc"
-version = "0.42.0"
+version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
+checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
[[package]]
name = "windows_x86_64_gnu"
-version = "0.42.0"
+version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed"
+checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
[[package]]
name = "windows_x86_64_gnullvm"
-version = "0.42.0"
+version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
+checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_msvc"
-version = "0.42.0"
+version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5"
+checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "xcursor"
diff --git a/Cargo.toml b/Cargo.toml
index 6c6aac9..f487ad2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,19 +5,18 @@ edition = "2021"
[dependencies]
log = "0.4"
-env_logger = "0.9"
+env_logger = "0.10"
anyhow = "1"
dirs-next = "2"
-toml = "0.5"
+toml = "0.6"
pangocairo = "0.16"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
memchr = "2"
thiserror = "1.0.38"
-wayrs-client = { version = "0.2.1", features = ["tokio"] }
-wayrs-scanner = "0.2"
-wayrs-shm-alloc = "0.2"
+wayrs-client = { version = "0.3", features = ["tokio"] }
+wayrs-shm-alloc = "0.3"
xcursor = "0.3.4"
diff --git a/src/bar.rs b/src/bar.rs
index cca3c30..5bfa020 100644
--- a/src/bar.rs
+++ b/src/bar.rs
@@ -65,7 +65,18 @@ impl Bar {
};
river_control.add_argument(conn, cmd.into());
river_control.add_argument(conn, CString::new((1u32 << tag).to_string()).unwrap());
- river_control.run_command(conn, seat);
+ river_control.run_command_with_cb(
+ conn,
+ seat,
+ |conn, state, _, event| match event {
+ zriver_command_callback_v1::Event::Success(msg) => {
+ info!("river_control: {msg:?}")
+ }
+ zriver_command_callback_v1::Event::Failure(msg) => {
+ state.set_error(conn, msg.to_string_lossy())
+ }
+ },
+ );
}
} else if let Some((name, instance)) = self.blocks_btns.click(x) {
if let Some(cmd) = &mut ss.status_cmd {
@@ -214,7 +225,7 @@ impl Bar {
height_f,
);
- self.surface.attach(conn, buffer, 0, 0);
+ self.surface.attach(conn, buffer.wl, 0, 0);
self.surface
.damage_buffer(conn, 0, 0, width * self.scale, height * self.scale);
self.surface.commit(conn);
@@ -222,7 +233,12 @@ impl Bar {
pub fn request_frame(&mut self, conn: &mut Connection<State>) {
if self.configured && self.frame_cb.is_none() {
- self.frame_cb = Some(self.surface.frame(conn));
+ self.frame_cb = Some(self.surface.frame_with_cb(conn, |conn, state, cb, _| {
+ if let Some(bar) = state.bars.iter_mut().find(|bar| bar.frame_cb == Some(cb)) {
+ bar.frame_cb = None;
+ bar.frame(conn, &mut state.shared_state);
+ }
+ }));
self.surface.commit(conn);
}
}
diff --git a/src/cursor.rs b/src/cursor.rs
index 57db8bb..3a827d0 100644
--- a/src/cursor.rs
+++ b/src/cursor.rs
@@ -92,7 +92,7 @@ impl Cursor {
assert_eq!(image.pixels_argb.len(), canvas.len(),);
canvas.copy_from_slice(&image.pixels_rgba);
- self.surface.attach(conn, buffer, 0, 0);
+ self.surface.attach(conn, buffer.wl, 0, 0);
self.surface
.damage_buffer(conn, 0, 0, image.width as i32, image.height as i32);
self.surface.set_buffer_scale(conn, scale as i32);
diff --git a/src/main.rs b/src/main.rs
index 73c2d6c..7ef0acb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -38,7 +38,7 @@ async fn main() -> anyhow::Result<()> {
tokio::select! {
recv_events = conn.async_recv_events() => {
recv_events?;
- conn.dispatch_events(&mut state)?;
+ conn.dispatch_events(&mut state);
conn.async_flush().await?;
}
reat_res = state.status_cmd_read() => {
diff --git a/src/protocol.rs b/src/protocol.rs
index ac8b2c1..a53a22a 100644
--- a/src/protocol.rs
+++ b/src/protocol.rs
@@ -2,7 +2,7 @@
use wayrs_client;
pub use wayrs_client::protocol::*;
-wayrs_scanner::generate!("protocols/xdg-shell.xml");
-wayrs_scanner::generate!("protocols/wlr-layer-shell-unstable-v1.xml");
-wayrs_scanner::generate!("protocols/river-status-unstable-v1.xml");
-wayrs_scanner::generate!("protocols/river-control-unstable-v1.xml");
+wayrs_client::scanner::generate!("protocols/xdg-shell.xml");
+wayrs_client::scanner::generate!("protocols/wlr-layer-shell-unstable-v1.xml");
+wayrs_client::scanner::generate!("protocols/river-status-unstable-v1.xml");
+wayrs_client::scanner::generate!("protocols/river-control-unstable-v1.xml");
diff --git a/src/state.rs b/src/state.rs
index dbe73fd..dfc2a2a 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -1,13 +1,12 @@
use crate::cursor::Cursor;
use crate::protocol::*;
-use std::convert::Infallible;
use std::future::pending;
use wayrs_client::connection::Connection;
use wayrs_client::global::{Global, GlobalExt, Globals, GlobalsExt};
-use wayrs_client::proxy::{Dispatch, Dispatcher, Proxy};
-use wayrs_shm_alloc::ShmAlloc;
+use wayrs_client::proxy::Proxy;
+use wayrs_shm_alloc::{ShmAlloc, ShmAllocState};
use crate::{
bar::Bar, config::Config, i3bar_protocol::Block, pointer_btn::PointerBtn,
@@ -21,13 +20,13 @@ pub struct State {
river_status_manager: Option<ZriverStatusManagerV1>,
river_control: Option<ZriverControlV1>,
- seats: Vec<Seat>,
- bars: Vec<Bar>,
+ pub seats: Vec<Seat>,
+ pub bars: Vec<Bar>,
pub shared_state: SharedState,
}
-struct Seat {
+pub struct Seat {
seat: WlSeat,
reg_name: u32,
pointer: Option<WlPointer>,
@@ -53,6 +52,7 @@ impl State {
.as_ref()
.and_then(|cmd| StatusCmd::new(cmd).map_err(|e| error = Err(e)).ok());
+ conn.set_callback_for(conn.registry(), wl_registry_cb);
let shm = globals.bind(conn, 1..=1).expect("could not bind wl_shm");
let mut this = Self {
@@ -138,17 +138,21 @@ impl State {
}
fn bind_output(&mut self, conn: &mut Connection<Self>, global: &Global) {
- let output = global.bind(conn, 2..=4).expect("could not bind wl_output");
+ let output = global
+ .bind_with_cb(conn, 2..=4, wl_output_cb)
+ .expect("could not bind wl_output");
+
let surface = self.wl_compositor.create_surface(conn);
use zwlr_layer_shell_v1::Layer;
use zwlr_layer_surface_v1::Anchor;
- let layer_surface = self.layer_shell.get_layer_surface(
+ let layer_surface = self.layer_shell.get_layer_surface_with_cb(
conn,
surface,
output,
Layer::Top,
wayrs_client::cstr!("i3bar-river").into(),
+ layer_surface_cb,
);
layer_surface.set_size(conn, 0, self.shared_state.config.height);
layer_surface.set_anchor(conn, Anchor::Top | Anchor::Left | Anchor::Right); // Top + Left + Right
@@ -159,7 +163,7 @@ impl State {
let river_output_status = self
.river_status_manager
.as_ref()
- .map(|s| s.get_river_output_status(conn, output));
+ .map(|s| s.get_river_output_status_with_cb(conn, output, river_output_status_cb));
self.bars.push(Bar {
output,
@@ -183,7 +187,7 @@ impl State {
}
fn bind_seat(&mut self, conn: &mut Connection<Self>, global: &Global) {
- let seat: WlSeat = global.bind(conn, 5..=8).unwrap();
+ let seat: WlSeat = global.bind_with_cb(conn, 5..=8, wl_seat_cb).unwrap();
let cursor = Cursor::new(conn, self.wl_compositor).unwrap();
self.seats.push(Seat {
seat,
@@ -224,277 +228,263 @@ impl State {
}
}
-impl Dispatcher for State {
- type Error = Infallible;
+impl ShmAllocState for State {
+ fn shm_alloc(&mut self) -> &mut ShmAlloc {
+ &mut self.shared_state.shm
+ }
}
-impl Dispatch<WlRegistry> for State {
- fn event(&mut self, conn: &mut Connection<Self>, _: WlRegistry, event: wl_registry::Event) {
- match event {
- wl_registry::Event::Global(global) if global.is::<WlOutput>() => {
- self.bind_output(conn, &global);
- }
- wl_registry::Event::Global(global) if global.is::<WlSeat>() => {
- self.bind_seat(conn, &global);
- }
- wl_registry::Event::GlobalRemove(name) => {
- if let Some(bar_index) =
- self.bars.iter().position(|bar| bar.output_reg_name == name)
- {
- self.drop_bar(conn, bar_index);
- } else if let Some(seat_index) =
- self.seats.iter().position(|seat| seat.reg_name == name)
- {
- self.drop_seat(conn, seat_index);
- }
+fn wl_registry_cb(
+ conn: &mut Connection<State>,
+ state: &mut State,
+ _: WlRegistry,
+ event: wl_registry::Event,
+) {
+ match event {
+ wl_registry::Event::Global(global) if global.is::<WlOutput>() => {
+ state.bind_output(conn, &global);
+ }
+ wl_registry::Event::Global(global) if global.is::<WlSeat>() => {
+ state.bind_seat(conn, &global);
+ }
+ wl_registry::Event::GlobalRemove(name) => {
+ if let Some(bar_index) = state
+ .bars
+ .iter()
+ .position(|bar| bar.output_reg_name == name)
+ {
+ state.drop_bar(conn, bar_index);
+ } else if let Some(seat_index) =
+ state.seats.iter().position(|seat| seat.reg_name == name)
+ {
+ state.drop_seat(conn, seat_index);
}
- _ => (),
}
+ _ => (),
}
}
-impl Dispatch<WlCallback> for State {
- fn event(&mut self, conn: &mut Connection<Self>, cb: WlCallback, event: wl_callback::Event) {
- let wl_callback::Event::Done(_) = event;
- if let Some(bar) = self.bars.iter_mut().find(|bar| bar.frame_cb == Some(cb)) {
- bar.frame_cb = None;
- bar.frame(conn, &mut self.shared_state);
+fn wl_output_cb(
+ conn: &mut Connection<State>,
+ state: &mut State,
+ output: WlOutput,
+ event: wl_output::Event,
+) {
+ if let wl_output::Event::Scale(scale) = event {
+ let bar = state
+ .bars
+ .iter_mut()
+ .find(|bar| bar.output == output)
+ .unwrap();
+ bar.scale = scale;
+ // If bar is not configured yet, it is because we were waiting for the "scale" event
+ // before commiting the surface. Otherwise, there is no need to do any redrawing (we'll
+ // do that after "configure" event).
+ if !bar.configured {
+ bar.surface.commit(conn);
}
}
}
-impl Dispatch<WlOutput> for State {
- fn event(&mut self, conn: &mut Connection<Self>, output: WlOutput, event: wl_output::Event) {
- if let wl_output::Event::Scale(scale) = event {
- let bar = self
+fn layer_surface_cb(
+ conn: &mut Connection<State>,
+ state: &mut State,
+ layer_surface: zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
+ event: zwlr_layer_surface_v1::Event,
+) {
+ match event {
+ zwlr_layer_surface_v1::Event::Configure(args) => {
+ let bar = state
.bars
.iter_mut()
- .find(|bar| bar.output == output)
+ .find(|bar| bar.layer_surface == layer_surface)
.unwrap();
- bar.scale = scale;
- // If bar is not configured yet, it is because we were waiting for the "scale" event
- // before commiting the surface. Otherwise, there is no need to do any redrawing (we'll
- // do that after "configure" event).
- if !bar.configured {
- bar.surface.commit(conn);
- }
- }
- }
-}
-
-impl Dispatch<zwlr_layer_surface_v1::ZwlrLayerSurfaceV1> for State {
- fn event(
- &mut self,
- conn: &mut Connection<Self>,
- layer_surface: zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
- event: zwlr_layer_surface_v1::Event,
- ) {
- match event {
- zwlr_layer_surface_v1::Event::Configure(args) => {
- let bar = self
- .bars
- .iter_mut()
- .find(|bar| bar.layer_surface == layer_surface)
- .unwrap();
- assert_ne!(args.width, 0);
- bar.width = args.width;
+ assert_ne!(args.width, 0);
+ bar.width = args.width;
+ bar.layer_surface.ack_configure(conn, args.serial);
+ if bar.configured {
+ bar.request_frame(conn);
+ } else {
bar.configured = true;
- bar.layer_surface.ack_configure(conn, args.serial);
- bar.frame(conn, &mut self.shared_state);
- }
- zwlr_layer_surface_v1::Event::Closed => {
- let bar_index = self
- .bars
- .iter()
- .position(|bar| bar.layer_surface == layer_surface)
- .unwrap();
- self.drop_bar(conn, bar_index);
+ bar.frame(conn, &mut state.shared_state);
}
}
+ zwlr_layer_surface_v1::Event::Closed => {
+ let bar_index = state
+ .bars
+ .iter()
+ .position(|bar| bar.layer_surface == layer_surface)
+ .unwrap();
+ state.drop_bar(conn, bar_index);
+ }
}
}
-impl Dispatch<WlBuffer> for State {
- fn event(&mut self, _: &mut Connection<Self>, buffer: WlBuffer, event: wl_buffer::Event) {
- let wl_buffer::Event::Release = event;
- self.shared_state.shm.free_buffer(buffer);
- }
-}
-
-impl Dispatch<WlSeat> for State {
- fn event(&mut self, conn: &mut Connection<Self>, seat: WlSeat, event: wl_seat::Event) {
- if let wl_seat::Event::Capabilities(capabilities) = event {
- let seat = self.seats.iter_mut().find(|s| s.seat == seat).unwrap();
- match &seat.pointer {
- Some(pointer) if !capabilities.contains(wl_seat::Capability::Pointer) => {
- if pointer.version() >= 3 {
- pointer.release(conn);
- }
- seat.pointer = None;
- }
- None if capabilities.contains(wl_seat::Capability::Pointer) => {
- let pointer = seat.seat.get_pointer(conn);
- seat.pointer = Some(pointer);
+fn wl_seat_cb(
+ conn: &mut Connection<State>,
+ state: &mut State,
+ seat: WlSeat,
+ event: wl_seat::Event,
+) {
+ if let wl_seat::Event::Capabilities(capabilities) = event {
+ let seat = state.seats.iter_mut().find(|s| s.seat == seat).unwrap();
+ match &seat.pointer {
+ Some(pointer) if !capabilities.contains(wl_seat::Capability::Pointer) => {
+ if pointer.version() >= 3 {
+ pointer.release(conn);
}
- _ => (),
+ seat.pointer = None;
}
+ None if capabilities.contains(wl_seat::Capability::Pointer) => {
+ seat.pointer = Some(seat.seat.get_pointer_with_cb(conn, wl_pointer_cb));
+ }
+ _ => (),
}
}
}
-impl Dispatch<WlPointer> for State {
- fn event(&mut self, conn: &mut Connection<Self>, pointer: WlPointer, event: wl_pointer::Event) {
- let seat = self
- .seats
- .iter_mut()
- .find(|s| s.pointer == Some(pointer))
- .unwrap();
+fn wl_pointer_cb(
+ conn: &mut Connection<State>,
+ state: &mut State,
+ pointer: WlPointer,
+ event: wl_pointer::Event,
+) {
+ let seat = state
+ .seats
+ .iter_mut()
+ .find(|s| s.pointer == Some(pointer))
+ .unwrap();
- use wl_pointer::Event;
- match event {
- Event::Frame => {
- let btn = seat.pending_button.take();
- let scroll = seat.scroll_frame.finalize();
- if let Some(surface) = seat.cur_surface {
- let bar = self
- .bars
- .iter_mut()
- .find(|bar| bar.surface == surface)
- .unwrap();
+ use wl_pointer::Event;
+ match event {
+ Event::Frame => {
+ let btn = seat.pending_button.take();
+ let scroll = seat.scroll_frame.finalize();
+ if let Some(surface) = seat.cur_surface {
+ let bar = state
+ .bars
+ .iter_mut()
+ .find(|bar| bar.surface == surface)
+ .unwrap();
- if let Some(btn) = btn {
- bar.click(conn, &mut self.shared_state, btn, seat.seat, seat.x, seat.y)
- .unwrap();
- }
+ if let Some(btn) = btn {
+ bar.click(
+ conn,
+ &mut state.shared_state,
+ btn,
+ seat.seat,
+ seat.x,
+ seat.y,
+ )
+ .unwrap();
+ }
- if scroll.is_finder && self.shared_state.config.invert_touchpad_scrolling {
- seat.pending_scroll -= scroll.absolute;
- } else {
- seat.pending_scroll += scroll.absolute;
- }
+ if scroll.is_finder && state.shared_state.config.invert_touchpad_scrolling {
+ seat.pending_scroll -= scroll.absolute;
+ } else {
+ seat.pending_scroll += scroll.absolute;
+ }
- if scroll.stop {
- seat.pending_scroll = 0.0;
- }
+ if scroll.stop {
+ seat.pending_scroll = 0.0;
+ }
- let btn = if seat.pending_scroll >= 15.0 {
- seat.pending_scroll = 0.0;
- Some(PointerBtn::WheelDown)
- } else if seat.pending_scroll <= -15.0 {
- seat.pending_scroll = 0.0;
- Some(PointerBtn::WheelUp)
- } else {
- None
- };
+ let btn = if seat.pending_scroll >= 15.0 {
+ seat.pending_scroll = 0.0;
+ Some(PointerBtn::WheelDown)
+ } else if seat.pending_scroll <= -15.0 {
+ seat.pending_scroll = 0.0;
+ Some(PointerBtn::WheelUp)
+ } else {
+ None
+ };
- if let Some(btn) = btn {
- bar.click(conn, &mut self.shared_state, btn, seat.seat, seat.x, seat.y)
- .unwrap();
- }
- }
- }
- Event::Enter(args) => {
- let bar = self
- .bars
- .iter()
- .find(|bar| bar.surface.id() == args.surface)
+ if let Some(btn) = btn {
+ bar.click(
+ conn,
+ &mut state.shared_state,
+ btn,
+ seat.seat,
+ seat.x,
+ seat.y,
+ )
.unwrap();
- seat.cur_surface = Some(bar.surface);
- seat.x = args.surface_x.as_f64();
- seat.y = args.surface_y.as_f64();
- seat.cursor.set(
- conn,
- args.serial,
- pointer,
- bar.scale as u32,
- &mut self.shared_state.shm,
- );
- }
- Event::Leave(_) => seat.cur_surface = None,
- Event::Motion(args) => {
- seat.x = args.surface_x.as_f64();
- seat.y = args.surface_y.as_f64();
- }
- Event::Button(args) => {
- if args.state == wl_pointer::ButtonState::Pressed {
- seat.pending_button = Some(args.button.into());
}
}
- Event::Axis(args) => {
- if args.axis == wl_pointer::Axis::VerticalScroll {
- seat.scroll_frame.absolute += args.value.as_f64();
- }
+ }
+ Event::Enter(args) => {
+ let bar = state
+ .bars
+ .iter()
+ .find(|bar| bar.surface.id() == args.surface)
+ .unwrap();
+ seat.cur_surface = Some(bar.surface);
+ seat.x = args.surface_x.as_f64();
+ seat.y = args.surface_y.as_f64();
+ seat.cursor.set(
+ conn,
+ args.serial,
+ pointer,
+ bar.scale as u32,
+ &mut state.shared_state.shm,
+ );
+ }
+ Event::Leave(_) => seat.cur_surface = None,
+ Event::Motion(args) => {
+ seat.x = args.surface_x.as_f64();
+ seat.y = args.surface_y.as_f64();
+ }
+ Event::Button(args) => {
+ if args.state == wl_pointer::ButtonState::Pressed {
+ seat.pending_button = Some(args.button.into());
}
- Event::AxisSource(source) => {
- seat.scroll_frame.is_finder = source == wl_pointer::AxisSource::Finger;
+ }
+ Event::Axis(args) => {
+ if args.axis == wl_pointer::Axis::VerticalScroll {
+ seat.scroll_frame.absolute += args.value.as_f64();
}
- Event::AxisStop(args) => {
- if args.axis == wl_pointer::Axis::VerticalScroll {
- seat.scroll_frame.stop = true;
- }
+ }
+ Event::AxisSource(source) => {
+ seat.scroll_frame.is_finder = source == wl_pointer::AxisSource::Finger;
+ }
+ Event::AxisStop(args) => {
+ if args.axis == wl_pointer::Axis::VerticalScroll {
+ seat.scroll_frame.stop = true;
}
- Event::AxisDiscrete(_) | Event::AxisValue120(_) => (),
}
+ Event::AxisDiscrete(_) | Event::AxisValue120(_) => (),
}
}
-impl Dispatch<ZriverOutputStatusV1> for State {
- fn event(
- &mut self,
- conn: &mut Connection<Self>,
- status: ZriverOutputStatusV1,
- event: zriver_output_status_v1::Event,
- ) {
- let bar = self
- .bars
- .iter_mut()
- .find(|b| b.river_output_status == Some(status))
- .unwrap();
+fn river_output_status_cb(
+ conn: &mut Connection<State>,
+ state: &mut State,
+ status: ZriverOutputStatusV1,
+ event: zriver_output_status_v1::Event,
+) {
+ let bar = state
+ .bars
+ .iter_mut()
+ .find(|b| b.river_output_status == Some(status))
+ .unwrap();
- use zriver_output_status_v1::Event;
- match event {
- Event::FocusedTags(tags) => bar.tags_info.focused = tags,
- Event::UrgentTags(tags) => bar.tags_info.urgent = tags,
- Event::LayoutName(name) => bar.set_layout_name(Some(name.into_string().unwrap())),
- Event::LayoutNameClear => bar.set_layout_name(None),
- Event::ViewTags(vt) => {
- bar.tags_info.active = vt
- .chunks_exact(4)
- .map(|bytes| u32::from_ne_bytes(bytes.try_into().unwrap()))
- .fold(0, |a, b| a | b);
- }
+ use zriver_output_status_v1::Event;
+ match event {
+ Event::FocusedTags(tags) => bar.tags_info.focused = tags,
+ Event::UrgentTags(tags) => bar.tags_info.urgent = tags,
+ Event::LayoutName(name) => bar.set_layout_name(Some(name.into_string().unwrap())),
+ Event::LayoutNameClear => bar.set_layout_name(None),
+ Event::ViewTags(vt) => {
+ bar.tags_info.active = vt
+ .chunks_exact(4)
+ .map(|bytes| u32::from_ne_bytes(bytes.try_into().unwrap()))
+ .fold(0, |a, b| a | b);
}
-
- bar.request_frame(conn);
}
-}
-impl Dispatch<ZriverCommandCallbackV1> for State {
- fn event(
- &mut self,
- conn: &mut Connection<Self>,
- _: ZriverCommandCallbackV1,
- event: zriver_command_callback_v1::Event,
- ) {
- use zriver_command_callback_v1::Event;
- match event {
- Event::Success(msg) => info!("river_control: {msg:?}"),
- Event::Failure(msg) => self.set_error(conn, msg.into_string().unwrap()),
- }
- }
+ bar.request_frame(conn);
}
-// Interfaces with no events
-impl Dispatch<WlCompositor> for State {}
-impl Dispatch<ZwlrLayerShellV1> for State {}
-impl Dispatch<ZriverStatusManagerV1> for State {}
-impl Dispatch<ZriverControlV1> for State {}
-impl Dispatch<WlShmPool> for State {}
-
-// Dont care
-impl Dispatch<WlShm> for State {}
-impl Dispatch<WlSurface> for State {}
-
#[derive(Debug)]
pub struct ComputedBlock {
pub block: Block,