chore: add debug flag + housekeeping
This commit is contained in:
parent
18d349c11f
commit
1ec5921248
@ -2,7 +2,7 @@ mod ipc;
|
||||
mod manager;
|
||||
mod socket;
|
||||
|
||||
use std::io::Read;
|
||||
use std::{env, io::Read};
|
||||
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use microxdg::Xdg;
|
||||
@ -31,7 +31,11 @@ fn main() -> Result<()> {
|
||||
tracing_subscriber::fmt()
|
||||
.with_max_level(tracing::Level::DEBUG)
|
||||
.init();
|
||||
let span = tracing::span!(tracing::Level::DEBUG, "main");
|
||||
let span = if env::var("NIRI_TAG_DEBUG").is_ok() {
|
||||
tracing::span!(tracing::Level::DEBUG, "main")
|
||||
} else {
|
||||
tracing::span!(tracing::Level::INFO, "main")
|
||||
};
|
||||
let _ = span.enter();
|
||||
// spawn socket consumer for niri event stream
|
||||
let (niri_tx, niri_rx) = smol::channel::unbounded();
|
||||
|
@ -158,7 +158,6 @@ impl NiriTag {
|
||||
Tag(tag) => {
|
||||
tracing::debug!("Changing tag {}", tag);
|
||||
let tag_visible = *self.tags.entry(tag).or_insert(true);
|
||||
tracing::debug!("Windows: {:?}", self.windows);
|
||||
let affected_windows: Vec<u64> = self
|
||||
.windows
|
||||
.iter()
|
||||
@ -239,7 +238,7 @@ impl NiriTag {
|
||||
})
|
||||
.detach();
|
||||
};
|
||||
let add_tag = async |tx: Sender<TagEvent>, windows: &HashMap<u64, u8>, t| {
|
||||
let add_tag_fire = async |tx: Sender<TagEvent>, windows: &HashMap<u64, u8>, t| {
|
||||
if windows
|
||||
.iter()
|
||||
.filter(|(_, tag)| **tag == t)
|
||||
@ -249,8 +248,7 @@ impl NiriTag {
|
||||
send_event(tx, TagEvent::TagOccupied(t)).await;
|
||||
}
|
||||
};
|
||||
let rm_tag = async |tx: Sender<TagEvent>, windows: &HashMap<u64, u8>, wid, old_tag| {
|
||||
tracing::debug!("removing tag {}", wid);
|
||||
let rm_tag_fire = async |tx: Sender<TagEvent>, windows: &HashMap<u64, u8>, wid, old_tag| {
|
||||
let same_tagged = windows
|
||||
.iter()
|
||||
.filter(|(w, tag)| **tag == old_tag && **w != wid)
|
||||
@ -293,7 +291,7 @@ impl NiriTag {
|
||||
self.windows.insert(wid, t);
|
||||
tracing::debug!("adding tag {} to {}", t, wid);
|
||||
let tx = self.ev_tx.clone();
|
||||
add_tag(tx, &self.windows, t).await;
|
||||
add_tag_fire(tx, &self.windows, t).await;
|
||||
Window(wid)
|
||||
}
|
||||
TagCmd::RemoveTagFromWin(_) => {
|
||||
@ -302,7 +300,7 @@ impl NiriTag {
|
||||
let old_tag = self.windows.insert(wid, 0).unwrap_or(0);
|
||||
tracing::debug!("resetting tag on {}", wid);
|
||||
let tx = self.ev_tx.clone();
|
||||
rm_tag(tx, &self.windows, wid, old_tag).await;
|
||||
rm_tag_fire(tx, &self.windows, wid, old_tag).await;
|
||||
Window(wid)
|
||||
}
|
||||
TagCmd::ToggleTagOnWin(t) => {
|
||||
@ -313,9 +311,9 @@ impl NiriTag {
|
||||
let toggle = if this_tag == t { 0 } else { t };
|
||||
let tx = self.ev_tx.clone();
|
||||
if toggle == 0 {
|
||||
rm_tag(tx, &self.windows, wid, this_tag).await;
|
||||
rm_tag_fire(tx, &self.windows, wid, this_tag).await;
|
||||
} else {
|
||||
add_tag(tx, &self.windows, t).await;
|
||||
add_tag_fire(tx, &self.windows, t).await;
|
||||
}
|
||||
tracing::debug!("toggling {} to tag {}", wid, toggle);
|
||||
self.windows.insert(wid, toggle);
|
||||
|
Loading…
Reference in New Issue
Block a user