Activate on startup (#70)

Frontends are now properly synced among each other and on startup the correct state is reflected.

Closes #75 
Closes #68
This commit is contained in:
Ferdinand Schober
2024-01-16 12:59:39 +01:00
committed by GitHub
parent 2e52660714
commit d90eb0cd0f
14 changed files with 294 additions and 224 deletions

View File

@@ -46,6 +46,20 @@ impl Display for Position {
}
}
impl TryFrom<&str> for Position {
type Error = ();
fn try_from(s: &str) -> Result<Self, Self::Error> {
match s {
"left" => Ok(Position::Left),
"right" => Ok(Position::Right),
"top" => Ok(Position::Top),
"bottom" => Ok(Position::Bottom),
_ => Err(()),
}
}
}
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
pub struct Client {
/// hostname of this client
@@ -112,6 +126,7 @@ impl ClientManager {
ips: HashSet<IpAddr>,
port: u16,
pos: Position,
active: bool,
) -> ClientHandle {
// get a new client_handle
let handle = self.free_id();
@@ -135,7 +150,7 @@ impl ClientManager {
// client was never seen, nor pinged
let client_state = ClientState {
client,
active: false,
active,
active_addr: None,
alive: false,
pressed_keys: HashSet::new(),