mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 10:41:03 +02:00
feat: improved logging & error handling
This commit is contained in:
parent
3a83bd31ab
commit
ad77dc4e4c
2 changed files with 22 additions and 4 deletions
|
@ -427,6 +427,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
.name("popup-launcher")
|
||||
.build();
|
||||
|
||||
// we need some content to force the container to have a size
|
||||
let placeholder = Button::with_label("PLACEHOLDER");
|
||||
placeholder.set_width_request(MAX_WIDTH);
|
||||
container.add(&placeholder);
|
||||
|
@ -439,6 +440,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
match event {
|
||||
LauncherUpdate::AddItem(item) => {
|
||||
let app_id = item.app_id.clone();
|
||||
trace!("Adding item with id '{app_id}' to the popup: {item:?}");
|
||||
|
||||
let window_buttons = item
|
||||
.windows
|
||||
|
@ -468,6 +470,11 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
buttons.insert(app_id, window_buttons);
|
||||
}
|
||||
LauncherUpdate::AddWindow(app_id, win) => {
|
||||
debug!(
|
||||
"Adding new window to popup for '{app_id}': '{}' ({})",
|
||||
win.name, win.id
|
||||
);
|
||||
|
||||
if let Some(buttons) = buttons.get_mut(&app_id) {
|
||||
let button = Button::builder()
|
||||
.height_request(40)
|
||||
|
@ -490,11 +497,17 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
}
|
||||
}
|
||||
LauncherUpdate::RemoveWindow(app_id, win_id) => {
|
||||
debug!("Removing window from popup for '{app_id}': {win_id}");
|
||||
|
||||
if let Some(buttons) = buttons.get_mut(&app_id) {
|
||||
buttons.remove(&win_id);
|
||||
}
|
||||
}
|
||||
LauncherUpdate::Title(app_id, win_id, title) => {
|
||||
debug!(
|
||||
"Updating window title on popup for '{app_id}'/{win_id} to '{title}'"
|
||||
);
|
||||
|
||||
if let Some(buttons) = buttons.get_mut(&app_id) {
|
||||
if let Some(button) = buttons.get(&win_id) {
|
||||
button.set_label(&title);
|
||||
|
|
|
@ -2,6 +2,8 @@ use super::{Env, ToplevelHandler};
|
|||
use crate::wayland::toplevel::{ToplevelEvent, ToplevelInfo};
|
||||
use crate::wayland::toplevel_manager::listen_for_toplevels;
|
||||
use crate::wayland::ToplevelChange;
|
||||
use color_eyre::Report;
|
||||
use indexmap::IndexMap;
|
||||
use smithay_client_toolkit::environment::Environment;
|
||||
use smithay_client_toolkit::output::{with_output_info, OutputInfo};
|
||||
use smithay_client_toolkit::reexports::calloop;
|
||||
|
@ -10,7 +12,7 @@ use std::sync::{Arc, RwLock};
|
|||
use std::time::Duration;
|
||||
use tokio::sync::{broadcast, oneshot};
|
||||
use tokio::task::spawn_blocking;
|
||||
use tracing::trace;
|
||||
use tracing::{error, trace};
|
||||
use wayland_client::protocol::wl_seat::WlSeat;
|
||||
use wayland_protocols::wlr::unstable::foreign_toplevel::v1::client::{
|
||||
zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1,
|
||||
|
@ -88,9 +90,12 @@ impl WaylandClient {
|
|||
|
||||
loop {
|
||||
// TODO: Avoid need for duration here - can we force some event when sending requests?
|
||||
event_loop
|
||||
.dispatch(Duration::from_millis(50), &mut ())
|
||||
.expect("Failed to dispatch pending wayland events");
|
||||
if let Err(err) = event_loop.dispatch(Duration::from_millis(50), &mut ()) {
|
||||
error!(
|
||||
"{:?}",
|
||||
Report::new(err).wrap_err("Failed to dispatch pending wayland events")
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue