1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 18:51:04 +02:00

refactor: macros to reduce repeated code

This commit is contained in:
Jake Stanger 2022-12-11 22:45:52 +00:00
parent 9d5049dde0
commit 5e21cbcca6
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
18 changed files with 225 additions and 248 deletions

View file

@ -1,7 +1,7 @@
use crate::clients::wayland::{self, ToplevelChange};
use crate::config::CommonConfig;
use crate::modules::{Module, ModuleInfo, ModuleUpdateEvent, ModuleWidget, WidgetContext};
use crate::{await_sync, error, icon};
use crate::{await_sync, icon, read_lock, send_async};
use color_eyre::Result;
use glib::Continue;
use gtk::prelude::*;
@ -49,7 +49,8 @@ impl Module<gtk::Box> for FocusedModule {
) -> Result<()> {
let focused = await_sync(async {
let wl = wayland::get_client().await;
let toplevels = wl.toplevels.read().expect(error::ERR_READ_LOCK).clone();
// TODO: Avoid cloning
let toplevels = read_lock!(wl.toplevels).clone();
toplevels.into_iter().find(|(_, (top, _))| top.active)
});
@ -72,12 +73,10 @@ impl Module<gtk::Box> for FocusedModule {
};
if update {
tx.send(ModuleUpdateEvent::Update((
event.toplevel.title,
event.toplevel.app_id,
)))
.await
.expect(error::ERR_CHANNEL_SEND);
send_async!(
tx,
ModuleUpdateEvent::Update((event.toplevel.title, event.toplevel.app_id))
);
}
}
});