refactor: use persistent TagState instead of ad hoc calculations

This commit is contained in:
atagen 2025-06-23 17:13:46 +10:00
parent 67e77c122f
commit 0b8a291b7d
2 changed files with 124 additions and 97 deletions

View file

@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};
use serde::{Deserialize, Serialize};
@ -13,7 +13,7 @@ pub enum TagCmd {
ExclusiveTag(u8),
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Debug)]
pub enum TagEvent {
TagEmpty(u8),
TagOccupied(u8),
@ -24,11 +24,24 @@ pub enum TagEvent {
TagFullState(HashMap<u8, TagState>),
}
#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Debug, Clone)]
pub struct TagState {
pub enabled: bool,
pub occupied: bool,
pub urgent: bool,
#[serde(skip_serializing)]
pub windows: HashSet<u64>,
}
impl Default for TagState {
fn default() -> Self {
Self {
enabled: true,
occupied: false,
urgent: false,
windows: HashSet::new(),
}
}
}
#[derive(Deserialize)]