summaryrefslogtreecommitdiff
path: root/src/event_loop.rs
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-08-16 08:21:37 +0200
committercashmere <cashmere@autistici.org>2026-08-16 08:21:37 +0200
commit4901b5d77d73db59f0c1545719ec6d1404aad979 (patch)
tree0b3233e82387ffe7a9cd5c0934971a665e0575a9 /src/event_loop.rs
parent91b84d1f1bfbc5de2eb140a48185a5252b1b592e (diff)
downloadi3bar-mango-4901b5d77d73db59f0c1545719ec6d1404aad979.tar.gz
Run detached and reload config liveHEADmain
Diffstat (limited to 'src/event_loop.rs')
-rw-r--r--src/event_loop.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/event_loop.rs b/src/event_loop.rs
index 89f6f81..28fc0dc 100644
--- a/src/event_loop.rs
+++ b/src/event_loop.rs
@@ -7,7 +7,7 @@ use wayrs_client::Connection;
use crate::state::State;
-type Callback = Box<dyn FnMut(EventLoopCtx) -> Result<Action>>;
+pub type Callback = Box<dyn FnMut(EventLoopCtx) -> Result<Action>>;
pub struct EventLoopCtx<'a> {
pub conn: &'a mut Connection<State>,
@@ -22,6 +22,7 @@ pub struct EventLoop {
pub enum Action {
Keep,
+ KeepAndRegister(RawFd, Callback),
Unregister,
}
@@ -80,6 +81,10 @@ impl EventLoop {
Action::Keep => {
self.cbs.insert(fd.fd, cb);
}
+ Action::KeepAndRegister(new_fd, new_cb) => {
+ self.cbs.insert(fd.fd, cb);
+ self.cbs.insert(new_fd, new_cb);
+ }
Action::Unregister => (),
}
}
@@ -88,6 +93,10 @@ impl EventLoop {
for mut cb in self.on_idle.drain(..) {
match cb(EventLoopCtx { conn, state })? {
Action::Keep => on_idle_scratch.push(cb),
+ Action::KeepAndRegister(fd, new_cb) => {
+ on_idle_scratch.push(cb);
+ self.cbs.insert(fd, new_cb);
+ }
Action::Unregister => (),
}
}