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")
|
.name("popup-launcher")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
// we need some content to force the container to have a size
|
||||||
let placeholder = Button::with_label("PLACEHOLDER");
|
let placeholder = Button::with_label("PLACEHOLDER");
|
||||||
placeholder.set_width_request(MAX_WIDTH);
|
placeholder.set_width_request(MAX_WIDTH);
|
||||||
container.add(&placeholder);
|
container.add(&placeholder);
|
||||||
|
@ -439,6 +440,7 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
match event {
|
match event {
|
||||||
LauncherUpdate::AddItem(item) => {
|
LauncherUpdate::AddItem(item) => {
|
||||||
let app_id = item.app_id.clone();
|
let app_id = item.app_id.clone();
|
||||||
|
trace!("Adding item with id '{app_id}' to the popup: {item:?}");
|
||||||
|
|
||||||
let window_buttons = item
|
let window_buttons = item
|
||||||
.windows
|
.windows
|
||||||
|
@ -468,6 +470,11 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
buttons.insert(app_id, window_buttons);
|
buttons.insert(app_id, window_buttons);
|
||||||
}
|
}
|
||||||
LauncherUpdate::AddWindow(app_id, win) => {
|
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) {
|
if let Some(buttons) = buttons.get_mut(&app_id) {
|
||||||
let button = Button::builder()
|
let button = Button::builder()
|
||||||
.height_request(40)
|
.height_request(40)
|
||||||
|
@ -490,11 +497,17 @@ impl Module<gtk::Box> for LauncherModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LauncherUpdate::RemoveWindow(app_id, win_id) => {
|
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) {
|
if let Some(buttons) = buttons.get_mut(&app_id) {
|
||||||
buttons.remove(&win_id);
|
buttons.remove(&win_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LauncherUpdate::Title(app_id, win_id, title) => {
|
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(buttons) = buttons.get_mut(&app_id) {
|
||||||
if let Some(button) = buttons.get(&win_id) {
|
if let Some(button) = buttons.get(&win_id) {
|
||||||
button.set_label(&title);
|
button.set_label(&title);
|
||||||
|
|
|
@ -2,6 +2,8 @@ use super::{Env, ToplevelHandler};
|
||||||
use crate::wayland::toplevel::{ToplevelEvent, ToplevelInfo};
|
use crate::wayland::toplevel::{ToplevelEvent, ToplevelInfo};
|
||||||
use crate::wayland::toplevel_manager::listen_for_toplevels;
|
use crate::wayland::toplevel_manager::listen_for_toplevels;
|
||||||
use crate::wayland::ToplevelChange;
|
use crate::wayland::ToplevelChange;
|
||||||
|
use color_eyre::Report;
|
||||||
|
use indexmap::IndexMap;
|
||||||
use smithay_client_toolkit::environment::Environment;
|
use smithay_client_toolkit::environment::Environment;
|
||||||
use smithay_client_toolkit::output::{with_output_info, OutputInfo};
|
use smithay_client_toolkit::output::{with_output_info, OutputInfo};
|
||||||
use smithay_client_toolkit::reexports::calloop;
|
use smithay_client_toolkit::reexports::calloop;
|
||||||
|
@ -10,7 +12,7 @@ use std::sync::{Arc, RwLock};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::{broadcast, oneshot};
|
use tokio::sync::{broadcast, oneshot};
|
||||||
use tokio::task::spawn_blocking;
|
use tokio::task::spawn_blocking;
|
||||||
use tracing::trace;
|
use tracing::{error, trace};
|
||||||
use wayland_client::protocol::wl_seat::WlSeat;
|
use wayland_client::protocol::wl_seat::WlSeat;
|
||||||
use wayland_protocols::wlr::unstable::foreign_toplevel::v1::client::{
|
use wayland_protocols::wlr::unstable::foreign_toplevel::v1::client::{
|
||||||
zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1,
|
zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1,
|
||||||
|
@ -88,9 +90,12 @@ impl WaylandClient {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// TODO: Avoid need for duration here - can we force some event when sending requests?
|
// TODO: Avoid need for duration here - can we force some event when sending requests?
|
||||||
event_loop
|
if let Err(err) = event_loop.dispatch(Duration::from_millis(50), &mut ()) {
|
||||||
.dispatch(Duration::from_millis(50), &mut ())
|
error!(
|
||||||
.expect("Failed to dispatch pending wayland events");
|
"{:?}",
|
||||||
|
Report::new(err).wrap_err("Failed to dispatch pending wayland events")
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue