From 361ea7ce43f4e0d554e20b0d06f464d25a55d6c6 Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sat, 14 Sep 2024 14:29:38 +0200 Subject: [PATCH 1/5] zbus: move to non-deprecated attribute macros --- src/client/main.rs | 4 ++-- src/input-backend/dbus_server.rs | 6 +++--- src/server/main.rs | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/main.rs b/src/client/main.rs index 04b7471..0edda88 100644 --- a/src/client/main.rs +++ b/src/client/main.rs @@ -15,9 +15,9 @@ use gtk::{gio::ApplicationFlags, Application}; use gtk::{glib, prelude::*}; use std::env::args_os; use std::path::PathBuf; -use zbus::{blocking::Connection, dbus_proxy}; +use zbus::{blocking::Connection, proxy}; -#[dbus_proxy( +#[proxy( interface = "org.erikreider.swayosd", default_service = "org.erikreider.swayosd-server", default_path = "/org/erikreider/swayosd" diff --git a/src/input-backend/dbus_server.rs b/src/input-backend/dbus_server.rs index c2da3e3..13901d0 100644 --- a/src/input-backend/dbus_server.rs +++ b/src/input-backend/dbus_server.rs @@ -1,12 +1,12 @@ -use zbus::{dbus_interface, Connection, ConnectionBuilder, SignalContext}; +use zbus::{interface, Connection, ConnectionBuilder, SignalContext}; use crate::config::{DBUS_BACKEND_NAME, DBUS_PATH}; pub struct DbusServer; -#[dbus_interface(name = "org.erikreider.swayosd")] +#[interface(name = "org.erikreider.swayosd")] impl DbusServer { - #[dbus_interface(signal)] + #[zbus(signal)] pub async fn key_pressed( signal_ctxt: &SignalContext<'_>, key_code: u16, diff --git a/src/server/main.rs b/src/server/main.rs index d2f1a97..36acea2 100644 --- a/src/server/main.rs +++ b/src/server/main.rs @@ -35,13 +35,13 @@ use std::future::pending; use std::path::PathBuf; use std::str::FromStr; use utils::{get_system_css_path, user_style_path}; -use zbus::{dbus_interface, ConnectionBuilder}; +use zbus::{interface, ConnectionBuilder}; struct DbusServer { sender: Sender<(ArgTypes, String)>, } -#[dbus_interface(name = "org.erikreider.swayosd")] +#[interface(name = "org.erikreider.swayosd")] impl DbusServer { pub fn handle_action(&self, arg_type: String, data: String) -> bool { let arg_type = match ArgTypes::from_str(&arg_type) { From da62b8c847420a3800fdf90dc33b5c9b8dfb9dd7 Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sun, 15 Sep 2024 18:32:06 +0200 Subject: [PATCH 2/5] server: move from MainContext::channel to async_channel --- Cargo.lock | 234 ++++++++++---------------------------- Cargo.toml | 1 + src/server/application.rs | 30 ++--- src/server/main.rs | 8 +- 4 files changed, 80 insertions(+), 193 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5643acb..e5c2873 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "async-broadcast" @@ -45,14 +45,14 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7" +checksum = "30ca9a001c1e8ba5149f91a74362376cc6bc5b919d92d988668657bd570bdcec" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.1.1", - "futures-lite 2.3.0", + "fastrand", + "futures-lite", "slab", ] @@ -62,9 +62,9 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" dependencies = [ - "async-lock 3.4.0", + "async-lock", "blocking", - "futures-lite 2.3.0", + "futures-lite", ] [[package]] @@ -75,61 +75,32 @@ checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ "async-channel 2.3.1", "async-executor", - "async-io 2.3.4", - "async-lock 3.4.0", + "async-io", + "async-lock", "blocking", - "futures-lite 2.3.0", + "futures-lite", "once_cell", ] -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock 2.8.0", - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-lite 1.13.0", - "log", - "parking", - "polling 2.8.0", - "rustix 0.37.27", - "slab", - "socket2", - "waker-fn", -] - [[package]] name = "async-io" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" dependencies = [ - "async-lock 3.4.0", + "async-lock", "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.3.0", + "futures-lite", "parking", - "polling 3.7.3", - "rustix 0.38.35", + "polling", + "rustix", "slab", "tracing", "windows-sys 0.59.0", ] -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener 2.5.3", -] - [[package]] name = "async-lock" version = "3.4.0" @@ -143,22 +114,21 @@ dependencies = [ [[package]] name = "async-process" -version = "2.2.4" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a07789659a4d385b79b18b9127fc27e1a59e1e89117c78c5ea3b806f016374" +checksum = "63255f1dc2381611000436537bbedfe83183faa303a5a0edaf191edef06526bb" dependencies = [ "async-channel 2.3.1", - "async-io 2.3.4", - "async-lock 3.4.0", + "async-io", + "async-lock", "async-signal", "async-task", "blocking", "cfg-if", "event-listener 5.3.1", - "futures-lite 2.3.0", - "rustix 0.38.35", + "futures-lite", + "rustix", "tracing", - "windows-sys 0.59.0", ] [[package]] @@ -178,13 +148,13 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" dependencies = [ - "async-io 2.3.4", - "async-lock 3.4.0", + "async-io", + "async-lock", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.35", + "rustix", "signal-hook-registry", "slab", "windows-sys 0.59.0", @@ -192,19 +162,19 @@ dependencies = [ [[package]] name = "async-std" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +checksum = "c634475f29802fde2b8f0b505b1bd00dfe4df7d4a000f0b36f7671197d5c3615" dependencies = [ "async-channel 1.9.0", "async-global-executor", - "async-io 1.13.0", - "async-lock 2.8.0", + "async-io", + "async-lock", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite 1.13.0", + "futures-lite", "gloo-timers", "kv-log-macro", "log", @@ -224,9 +194,9 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", @@ -309,7 +279,7 @@ dependencies = [ "async-channel 2.3.1", "async-task", "futures-io", - "futures-lite 2.3.0", + "futures-lite", "piper", ] @@ -358,9 +328,9 @@ checksum = "d499b43edbf784dd81e16f0395f5b4350a35b477da8a074251087adefc11cb52" [[package]] name = "cc" -version = "1.1.15" +version = "1.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" dependencies = [ "shlex", ] @@ -408,9 +378,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -540,15 +510,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "fastrand" version = "2.1.1" @@ -571,7 +532,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.38.35", + "rustix", "windows-sys 0.48.0", ] @@ -607,28 +568,13 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite", - "waker-fn", -] - [[package]] name = "futures-lite" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.1.1", + "fastrand", "futures-core", "futures-io", "parking", @@ -839,9 +785,9 @@ dependencies = [ [[package]] name = "gloo-timers" -version = "0.2.6" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" dependencies = [ "futures-channel", "futures-core", @@ -1009,15 +955,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd4f5b4d1c00331c5245163aacfe5f20be75b564c7112d45893d4ae038119eb0" -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -1105,12 +1042,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1198,9 +1129,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" [[package]] name = "ordered-stream" @@ -1240,9 +1171,9 @@ dependencies = [ [[package]] name = "parking" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" [[package]] name = "pin-project-lite" @@ -1263,7 +1194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" dependencies = [ "atomic-waker", - "fastrand 2.1.1", + "fastrand", "futures-io", ] @@ -1273,22 +1204,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite", - "windows-sys 0.48.0", -] - [[package]] name = "polling" version = "3.7.3" @@ -1299,7 +1214,7 @@ dependencies = [ "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", - "rustix 0.38.35", + "rustix", "tracing", "windows-sys 0.59.0", ] @@ -1424,28 +1339,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.35" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", "libc", - "linux-raw-sys 0.4.14", + "linux-raw-sys", "windows-sys 0.52.0", ] @@ -1457,18 +1358,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1549,16 +1450,6 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "static_assertions" version = "1.1.0" @@ -1579,6 +1470,7 @@ name = "swayosd" version = "0.1.0" dependencies = [ "anyhow", + "async-channel 2.3.1", "async-std", "blight", "cascade", @@ -1648,9 +1540,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", - "fastrand 2.1.1", + "fastrand", "once_cell", - "rustix 0.38.35", + "rustix", "windows-sys 0.59.0", ] @@ -1780,9 +1672,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "value-bag" @@ -1802,12 +1694,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "waker-fn" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2098,8 +1984,8 @@ dependencies = [ "async-broadcast", "async-executor", "async-fs", - "async-io 2.3.4", - "async-lock 3.4.0", + "async-io", + "async-lock", "async-process", "async-recursion", "async-task", diff --git a/Cargo.toml b/Cargo.toml index ed932c7..3c5a381 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,3 +41,4 @@ nix = "0.26.2" blight = "0.7.0" anyhow = "1.0.75" thiserror = "1.0.49" +async-channel = "2.3.1" diff --git a/src/server/application.rs b/src/server/application.rs index 35491ca..6f074ad 100644 --- a/src/server/application.rs +++ b/src/server/application.rs @@ -3,9 +3,11 @@ use crate::config::{self, APPLICATION_NAME, DBUS_BACKEND_NAME}; use crate::global_utils::{handle_application_args, HandleLocalStatus}; use crate::osd_window::SwayosdWindow; use crate::utils::{self, *}; +use async_channel::Receiver; +use glib::MainContext; use gtk::gio::SignalSubscriptionId; use gtk::gio::{ApplicationFlags, BusNameWatcherFlags, BusType}; -use gtk::glib::{clone, MainContext, OptionArg, OptionFlags, Priority, Receiver}; +use gtk::glib::{clone, OptionArg, OptionFlags}; use gtk::prelude::*; use gtk::*; use pulsectl::controllers::{SinkController, SourceController}; @@ -107,19 +109,17 @@ impl SwayOSDApplication { })); // Listen to any Client actions - action_receiver.attach( - None, - clone!(@strong osd_app => @default-return Continue(false), move |(arg_type, data)| { + MainContext::default().spawn_local(clone!(@strong osd_app => async move { + while let Ok((arg_type, data)) = action_receiver.recv().await { Self::action_activated(&osd_app, arg_type, (!data.is_empty()).then_some(data)); - Continue(true) - }), - ); + } + Continue(false) + })); // Listen to the LibInput Backend and activate the Application action - let (sender, receiver) = MainContext::channel::<(u16, i32)>(Priority::default()); - receiver.attach( - None, - clone!(@strong osd_app => @default-return Continue(false), move |(key_code, state)| { + let (sender, receiver) = async_channel::bounded::<(u16, i32)>(1); + MainContext::default().spawn_local(clone!(@strong osd_app => async move { + while let Ok((key_code, state)) = receiver.recv().await { let (arg_type, data): (ArgTypes, Option) = match evdev_rs::enums::int_to_ev_key(key_code as u32) { Some(evdev_rs::enums::EV_KEY::KEY_CAPSLOCK) => { @@ -134,9 +134,9 @@ impl SwayOSDApplication { _ => return Continue(true), }; Self::action_activated(&osd_app, arg_type, data); - Continue(true) - }), - ); + } + Continue(false) + })); // Start watching for the LibInput Backend let signal_id: Arc>> = Arc::new(Mutex::new(None)); gio::bus_watch_name( @@ -164,7 +164,7 @@ impl SwayOSDApplication { let state = variant.try_child_get::(1); match (key_code, state) { (Ok(Some(key_code)), Ok(Some(state))) => { - if let Err(error) = sender.send((key_code, state)) { + if let Err(error) = sender.send_blocking((key_code, state)) { eprintln!("Channel Send error: {}", error); } }, diff --git a/src/server/main.rs b/src/server/main.rs index 36acea2..3fef393 100644 --- a/src/server/main.rs +++ b/src/server/main.rs @@ -20,8 +20,8 @@ extern crate cascade; use application::SwayOSDApplication; use argtypes::ArgTypes; +use async_channel::Sender; use config::{DBUS_PATH, DBUS_SERVER_NAME}; -use gtk::glib::{MainContext, Priority, Sender}; use gtk::prelude::*; use gtk::{ gdk::Screen, @@ -43,7 +43,7 @@ struct DbusServer { #[interface(name = "org.erikreider.swayosd")] impl DbusServer { - pub fn handle_action(&self, arg_type: String, data: String) -> bool { + pub async fn handle_action(&self, arg_type: String, data: String) -> bool { let arg_type = match ArgTypes::from_str(&arg_type) { Ok(arg_type) => arg_type, Err(other_type) => { @@ -51,7 +51,7 @@ impl DbusServer { return false; } }; - if let Err(error) = self.sender.send((arg_type, data)) { + if let Err(error) = self.sender.send((arg_type, data)).await { eprintln!("Channel Send error: {}", error); return false; } @@ -150,7 +150,7 @@ fn main() { println!("Loaded user defined CSS file"); } - let (sender, receiver) = MainContext::channel::<(ArgTypes, String)>(Priority::default()); + let (sender, receiver) = async_channel::bounded::<(ArgTypes, String)>(1); // Start the DBus Server async_std::task::spawn(DbusServer::new(sender)); // Start the GTK Application From 68ef5d0681728666de67ed72f2e365cb5f2f50ad Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sun, 22 Sep 2024 14:41:55 +0200 Subject: [PATCH 3/5] src/server: fix receiver being closed after ignored libinput event --- src/server/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/application.rs b/src/server/application.rs index 6f074ad..ff89e1a 100644 --- a/src/server/application.rs +++ b/src/server/application.rs @@ -131,7 +131,7 @@ impl SwayOSDApplication { Some(evdev_rs::enums::EV_KEY::KEY_SCROLLLOCK) => { (ArgTypes::ScrollLock, Some(state.to_string())) } - _ => return Continue(true), + _ => continue, }; Self::action_activated(&osd_app, arg_type, data); } From 0fc494952cef4339f231c6661e743ac8dcae0b0c Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sun, 22 Sep 2024 14:42:43 +0200 Subject: [PATCH 4/5] server: update gtk to 0.18.1 --- Cargo.lock | 276 ++++++++++++++++++++++---------------- Cargo.toml | 4 +- src/server/application.rs | 6 +- 3 files changed, 168 insertions(+), 118 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e5c2873..644dbfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + [[package]] name = "anyhow" version = "1.0.89" @@ -205,26 +214,25 @@ dependencies = [ [[package]] name = "atk" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba16453d10c712284061a05f6510f75abeb92b56ba88dfeb48c74775020cc22" +checksum = "b4af014b17dd80e8af9fa689b2d4a211ddba6eb583c1622f35d0cb543f6b17e4" dependencies = [ "atk-sys", - "bitflags 1.3.2", "glib", "libc", ] [[package]] name = "atk-sys" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf0a7ca572fbd5762fd8f8cd65a581e06767bc1234913fe1f43e370cff6e90" +checksum = "251e0b7d90e33e0ba930891a505a9a35ece37b2dd37a14f3ffc306c13b980009" dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] @@ -297,11 +305,11 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cairo-rs" -version = "0.17.10" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3603c4028a5e368d09b51c8b624b9a46edcd7c3778284077a6125af73c9f0a" +checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "cairo-sys-rs", "glib", "libc", @@ -311,13 +319,13 @@ dependencies = [ [[package]] name = "cairo-sys-rs" -version = "0.17.10" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "691d0c66b1fb4881be80a760cb8fe76ea97218312f9dfe2c9cc0f496ca279cb1" +checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51" dependencies = [ "glib-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] @@ -346,16 +354,20 @@ dependencies = [ ] [[package]] -name = "cfg-if" -version = "1.0.0" +name = "cfg-expr" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "345c78335be0624ed29012dc10c49102196c6882c12dde65d9f35b02da2aada8" +dependencies = [ + "smallvec", + "target-lexicon", +] [[package]] -name = "cfg_aliases" -version = "0.2.1" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "colored" @@ -401,6 +413,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "digest" version = "0.10.7" @@ -623,11 +646,10 @@ dependencies = [ [[package]] name = "gdk" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be1df5ea52cccd7e3a0897338b5564968274b52f5fd12601e0afa44f454c74d3" +checksum = "f5ba081bdef3b75ebcdbfc953699ed2d7417d6bd853347a42a37d76406a33646" dependencies = [ - "bitflags 1.3.2", "cairo-rs", "gdk-pixbuf", "gdk-sys", @@ -639,11 +661,10 @@ dependencies = [ [[package]] name = "gdk-pixbuf" -version = "0.17.10" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "695d6bc846438c5708b07007537b9274d883373dd30858ca881d7d71b5540717" +checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec" dependencies = [ - "bitflags 1.3.2", "gdk-pixbuf-sys", "gio", "glib", @@ -653,22 +674,22 @@ dependencies = [ [[package]] name = "gdk-pixbuf-sys" -version = "0.17.10" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9285ec3c113c66d7d0ab5676599176f1f42f4944ca1b581852215bf5694870cb" +checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7" dependencies = [ "gio-sys", "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gdk-sys" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2152de9d38bc67a17b3fe49dc0823af5bf874df59ea088c5f28f31cf103de703" +checksum = "31ff856cb3386dae1703a920f803abafcc580e9b5f711ca62ed1620c25b51ff2" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", @@ -678,7 +699,7 @@ dependencies = [ "libc", "pango-sys", "pkg-config", - "system-deps", + "system-deps 6.2.2", ] [[package]] @@ -704,11 +725,10 @@ dependencies = [ [[package]] name = "gio" -version = "0.17.10" +version = "0.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6973e92937cf98689b6a054a9e56c657ed4ff76de925e36fc331a15f0c5d30a" +checksum = "d4fc8f532f87b79cbc51a79748f16a6828fb784be93145a322fa14d06d354c73" dependencies = [ - "bitflags 1.3.2", "futures-channel", "futures-core", "futures-io", @@ -724,24 +744,24 @@ dependencies = [ [[package]] name = "gio-sys" -version = "0.17.10" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ccf87c30a12c469b6d958950f6a9c09f2be20b7773f7e70d20b867fdf2628c3" +checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2" dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", "winapi", ] [[package]] name = "glib" -version = "0.17.10" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fad45ba8d4d2cea612b432717e834f48031cd8853c8aaf43b2c79fec8d144b" +checksum = "233daaf6e83ae6a12a52055f568f9d7cf4671dabb78ff9560ab6da230ce00ee5" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "futures-channel", "futures-core", "futures-executor", @@ -760,27 +780,26 @@ dependencies = [ [[package]] name = "glib-macros" -version = "0.17.10" +version = "0.18.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca5c79337338391f1ab8058d6698125034ce8ef31b72a442437fa6c8580de26" +checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" dependencies = [ - "anyhow", "heck 0.4.1", - "proc-macro-crate 1.3.1", + "proc-macro-crate 2.0.2", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.77", ] [[package]] name = "glib-sys" -version = "0.17.10" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d80aa6ea7bba0baac79222204aa786a6293078c210abe69ef1336911d4bdc4f0" +checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898" dependencies = [ "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] @@ -797,23 +816,22 @@ dependencies = [ [[package]] name = "gobject-sys" -version = "0.17.10" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd34c3317740a6358ec04572c1bcfd3ac0b5b6529275fae255b237b314bb8062" +checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44" dependencies = [ "glib-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gtk" -version = "0.17.1" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c4222ab92b08d4d0bab90ddb6185b4e575ceeea8b8cdf00b938d7b6661d966" +checksum = "93c4f5e0e20b60e10631a5f06da7fe3dda744b05ad0ea71fee2f47adf865890c" dependencies = [ "atk", - "bitflags 1.3.2", "cairo-rs", "field-offset", "futures-channel", @@ -824,16 +842,15 @@ dependencies = [ "gtk-sys", "gtk3-macros", "libc", - "once_cell", "pango", "pkg-config", ] [[package]] name = "gtk-layer-shell" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "992f5fedb31835424a5280acd162bf348995f617d26969fde8d3dfd389b3ff5f" +checksum = "b48063be84aeb152d645c1da368053873c0ef62a5f381ca3f3175a99ee258a79" dependencies = [ "bitflags 2.6.0", "gdk", @@ -846,22 +863,22 @@ dependencies = [ [[package]] name = "gtk-layer-shell-sys" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5754bcfaadfc3529116af6ae93559b267d88647f965382153a4b8ea9372be75a" +checksum = "b9aa75cbb5bf5195d8be239b189f2a36cbea223777188c50f0bce124e291fe34" dependencies = [ "gdk-sys", "glib-sys", "gtk-sys", "libc", - "system-deps", + "system-deps 7.0.2", ] [[package]] name = "gtk-sys" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d8eb6a4b93e5a7e6980f7348d08c1cd93d31fae07cf97f20678c5ec41de3d7e" +checksum = "771437bf1de2c1c0b496c11505bdf748e26066bbe942dfc8f614c9460f6d7722" dependencies = [ "atk-sys", "cairo-sys-rs", @@ -872,21 +889,20 @@ dependencies = [ "gobject-sys", "libc", "pango-sys", - "system-deps", + "system-deps 6.2.2", ] [[package]] name = "gtk3-macros" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3efb84d682c9a39c10bd9f24f5a4b9c15cc8c7edc45c19cb2ca2c4fc38b2d95e" +checksum = "c6063efb63db582968fb7df72e1ae68aa6360dcfb0a75143f34fc7d616bad75e" dependencies = [ - "anyhow", "proc-macro-crate 1.3.1", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.77", ] [[package]] @@ -1096,13 +1112,12 @@ dependencies = [ [[package]] name = "nix" -version = "0.29.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ "bitflags 2.6.0", "cfg-if", - "cfg_aliases", "libc", "memoffset 0.9.1", ] @@ -1145,11 +1160,10 @@ dependencies = [ [[package]] name = "pango" -version = "0.17.10" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35be456fc620e61f62dff7ff70fbd54dcbaf0a4b920c0f16de1107c47d921d48" +checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4" dependencies = [ - "bitflags 1.3.2", "gio", "glib", "libc", @@ -1159,14 +1173,14 @@ dependencies = [ [[package]] name = "pango-sys" -version = "0.17.10" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3da69f9f3850b0d8990d462f8c709561975e95f689c1cdf0fecdebde78b35195" +checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5" dependencies = [ "glib-sys", "gobject-sys", "libc", - "system-deps", + "system-deps 6.2.2", ] [[package]] @@ -1240,11 +1254,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.2.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" dependencies = [ - "toml_edit 0.22.20", + "toml_datetime", + "toml_edit 0.20.2", ] [[package]] @@ -1328,6 +1343,35 @@ dependencies = [ "getrandom", ] +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + [[package]] name = "rustc_version" version = "0.4.1" @@ -1520,7 +1564,20 @@ version = "6.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" dependencies = [ - "cfg-expr", + "cfg-expr 0.15.8", + "heck 0.5.0", + "pkg-config", + "toml", + "version-compare", +] + +[[package]] +name = "system-deps" +version = "7.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "070a0a5e7da2d24be457809c4b3baa57a835fd2829ad8b86f9a049052fe71031" +dependencies = [ + "cfg-expr 0.16.0", "heck 0.5.0", "pkg-config", "toml", @@ -1568,21 +1625,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit 0.20.2", ] [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] @@ -1595,20 +1652,20 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", - "winnow 0.5.40", + "winnow", ] [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -1956,15 +2013,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winnow" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" -dependencies = [ - "memchr", -] - [[package]] name = "xdg-home" version = "1.3.0" @@ -1977,9 +2025,9 @@ dependencies = [ [[package]] name = "zbus" -version = "4.4.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" +checksum = "7b8e3d6ae3342792a6cc2340e4394334c7402f3d793b390d2c5494a4032b3030" dependencies = [ "async-broadcast", "async-executor", @@ -1991,13 +2039,14 @@ dependencies = [ "async-task", "async-trait", "blocking", + "derivative", "enumflags2", "event-listener 5.3.1", "futures-core", "futures-sink", "futures-util", "hex", - "nix 0.29.0", + "nix 0.27.1", "ordered-stream", "rand", "serde", @@ -2015,14 +2064,15 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "4.4.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" +checksum = "b7a3e850ff1e7217a3b7a07eba90d37fe9bb9e89a310f718afcde5885ca9b6d7" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.77", + "regex", + "syn 1.0.109", "zvariant_utils", ] @@ -2060,9 +2110,9 @@ dependencies = [ [[package]] name = "zvariant" -version = "4.2.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" +checksum = "4e09e8be97d44eeab994d752f341e67b3b0d80512a8b315a0671d47232ef1b65" dependencies = [ "endi", "enumflags2", @@ -2073,24 +2123,24 @@ dependencies = [ [[package]] name = "zvariant_derive" -version = "4.2.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" +checksum = "72a5857e2856435331636a9fbb415b09243df4521a267c5bedcd5289b4d5799e" dependencies = [ - "proc-macro-crate 3.2.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.77", + "syn 1.0.109", "zvariant_utils", ] [[package]] name = "zvariant_utils" -version = "2.1.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" +checksum = "00bedb16a193cc12451873fee2a1bc6550225acece0e36f333e68326c73c8172" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 1.0.109", ] diff --git a/Cargo.toml b/Cargo.toml index 3c5a381..6c4f67a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,8 @@ toml = "0.8" serde = "1" serde_derive = "1" # GUI Dependencies -gtk = "0.17.1" -gtk-layer-shell = "0.6.1" +gtk = "0.18.1" +gtk-layer-shell = "0.7.1" shrinkwraprs = "0.3.0" cascade = "1.0.1" pulse = { version = "2.26.0", package = "libpulse-binding" } diff --git a/src/server/application.rs b/src/server/application.rs index ff89e1a..fd07ed0 100644 --- a/src/server/application.rs +++ b/src/server/application.rs @@ -4,7 +4,7 @@ use crate::global_utils::{handle_application_args, HandleLocalStatus}; use crate::osd_window::SwayosdWindow; use crate::utils::{self, *}; use async_channel::Receiver; -use glib::MainContext; +use glib::{MainContext, ControlFlow::Continue, ControlFlow::Break}; use gtk::gio::SignalSubscriptionId; use gtk::gio::{ApplicationFlags, BusNameWatcherFlags, BusType}; use gtk::glib::{clone, OptionArg, OptionFlags}; @@ -113,7 +113,7 @@ impl SwayOSDApplication { while let Ok((arg_type, data)) = action_receiver.recv().await { Self::action_activated(&osd_app, arg_type, (!data.is_empty()).then_some(data)); } - Continue(false) + Break })); // Listen to the LibInput Backend and activate the Application action @@ -135,7 +135,7 @@ impl SwayOSDApplication { }; Self::action_activated(&osd_app, arg_type, data); } - Continue(false) + Break })); // Start watching for the LibInput Backend let signal_id: Arc>> = Arc::new(Mutex::new(None)); From 25faeab8555814bf34155b92c9ec943572c73eae Mon Sep 17 00:00:00 2001 From: Ferdinand Bachmann Date: Sun, 15 Sep 2024 18:46:21 +0200 Subject: [PATCH 5/5] server: update to gtk-layer-shell 0.8.1 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/server/application.rs | 2 +- src/server/osd_window.rs | 16 +++++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 644dbfe..baab9e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -848,9 +848,9 @@ dependencies = [ [[package]] name = "gtk-layer-shell" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b48063be84aeb152d645c1da368053873c0ef62a5f381ca3f3175a99ee258a79" +checksum = "adb41643070b55cdda5a4a10a338520cff4345395e342b754c02f341e4107383" dependencies = [ "bitflags 2.6.0", "gdk", diff --git a/Cargo.toml b/Cargo.toml index 6c4f67a..5fd9bbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ serde = "1" serde_derive = "1" # GUI Dependencies gtk = "0.18.1" -gtk-layer-shell = "0.7.1" +gtk-layer-shell = "0.8.1" shrinkwraprs = "0.3.0" cascade = "1.0.1" pulse = { version = "2.26.0", package = "libpulse-binding" } diff --git a/src/server/application.rs b/src/server/application.rs index fd07ed0..d150950 100644 --- a/src/server/application.rs +++ b/src/server/application.rs @@ -4,7 +4,7 @@ use crate::global_utils::{handle_application_args, HandleLocalStatus}; use crate::osd_window::SwayosdWindow; use crate::utils::{self, *}; use async_channel::Receiver; -use glib::{MainContext, ControlFlow::Continue, ControlFlow::Break}; +use glib::{ControlFlow::Break, ControlFlow::Continue, MainContext}; use gtk::gio::SignalSubscriptionId; use gtk::gio::{ApplicationFlags, BusNameWatcherFlags, BusType}; use gtk::glib::{clone, OptionArg, OptionFlags}; diff --git a/src/server/osd_window.rs b/src/server/osd_window.rs index e32bb52..091694f 100644 --- a/src/server/osd_window.rs +++ b/src/server/osd_window.rs @@ -17,6 +17,8 @@ use crate::{ }, }; +use gtk_layer_shell::LayerShell; + const ICON_SIZE: i32 = 32; /// A window that our application can open that contains the main project view. @@ -38,13 +40,13 @@ impl SwayosdWindow { .style_context() .add_class(>k::STYLE_CLASS_OSD.to_string()); - gtk_layer_shell::init_for_window(&window); - gtk_layer_shell::set_monitor(&window, monitor); - gtk_layer_shell::set_namespace(&window, "swayosd"); + window.init_layer_shell(); + window.set_monitor(monitor); + window.set_namespace("swayosd"); - gtk_layer_shell::set_exclusive_zone(&window, -1); - gtk_layer_shell::set_layer(&window, gtk_layer_shell::Layer::Overlay); - gtk_layer_shell::set_anchor(&window, gtk_layer_shell::Edge::Top, true); + window.set_exclusive_zone(-1); + window.set_layer(gtk_layer_shell::Layer::Overlay); + window.set_anchor(gtk_layer_shell::Edge::Top, true); // Set up the widgets window.set_width_request(250); @@ -60,7 +62,7 @@ impl SwayosdWindow { window.connect_map(clone!(@strong monitor => move |win| { let bottom = monitor.workarea().height() - win.allocated_height(); let margin = (bottom as f32 * get_top_margin()).round() as i32; - gtk_layer_shell::set_margin(win, gtk_layer_shell::Edge::Top, margin); + win.set_layer_shell_margin(gtk_layer_shell::Edge::Top, margin); })); Self {