mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-04-20 09:23:20 +03:00
update pos when entered from a different side
This commit is contained in:
@@ -204,7 +204,7 @@ pub enum FrontendEvent {
|
|||||||
/// incoming connected
|
/// incoming connected
|
||||||
IncomingConnected(String, SocketAddr, Position),
|
IncomingConnected(String, SocketAddr, Position),
|
||||||
/// incoming disconnected
|
/// incoming disconnected
|
||||||
IncomingDisconnected(String),
|
IncomingDisconnected(SocketAddr),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -234,11 +234,36 @@ impl Service {
|
|||||||
if self.incoming_conns.borrow_mut().insert(addr) {
|
if self.incoming_conns.borrow_mut().insert(addr) {
|
||||||
self.add_incoming(addr, pos, fingerprint.clone(), &capture);
|
self.add_incoming(addr, pos, fingerprint.clone(), &capture);
|
||||||
self.notify_frontend(FrontendEvent::IncomingConnected(fingerprint, addr, pos));
|
self.notify_frontend(FrontendEvent::IncomingConnected(fingerprint, addr, pos));
|
||||||
|
} else {
|
||||||
|
let handle = self
|
||||||
|
.incoming_conn_info
|
||||||
|
.borrow()
|
||||||
|
.iter()
|
||||||
|
.find(|(_, incoming)| incoming.addr == addr)
|
||||||
|
.map(|(k, _)| *k)
|
||||||
|
.expect("no such client");
|
||||||
|
let mut changed = false;
|
||||||
|
if let Some(incoming) = self.incoming_conn_info.borrow_mut().get_mut(&handle) {
|
||||||
|
if incoming.fingerprint != fingerprint {
|
||||||
|
incoming.fingerprint = fingerprint.clone();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if incoming.pos != pos {
|
||||||
|
incoming.pos = pos;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if changed {
|
||||||
|
self.remove_incoming(addr, &capture);
|
||||||
|
self.add_incoming(addr, pos, fingerprint.clone(), &capture);
|
||||||
|
self.notify_frontend(FrontendEvent::IncomingDisconnected(addr));
|
||||||
|
self.notify_frontend(FrontendEvent::IncomingConnected(fingerprint, addr, pos));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EmulationEvent::Disconnected { addr } => {
|
EmulationEvent::Disconnected { addr } => {
|
||||||
if let Some(fp) = self.remove_incoming(addr, &capture) {
|
if let Some(addr) = self.remove_incoming(addr, &capture) {
|
||||||
self.notify_frontend(FrontendEvent::IncomingDisconnected(fp));
|
self.notify_frontend(FrontendEvent::IncomingDisconnected(addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EmulationEvent::PortChanged(port) => match port {
|
EmulationEvent::PortChanged(port) => match port {
|
||||||
@@ -328,7 +353,7 @@ impl Service {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_incoming(&mut self, addr: SocketAddr, capture: &Capture) -> Option<String> {
|
fn remove_incoming(&mut self, addr: SocketAddr, capture: &Capture) -> Option<SocketAddr> {
|
||||||
let handle = self
|
let handle = self
|
||||||
.incoming_conn_info
|
.incoming_conn_info
|
||||||
.borrow()
|
.borrow()
|
||||||
@@ -340,7 +365,7 @@ impl Service {
|
|||||||
self.incoming_conn_info
|
self.incoming_conn_info
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.remove(&handle)
|
.remove(&handle)
|
||||||
.map(|incoming| incoming.fingerprint)
|
.map(|incoming| incoming.addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_incoming_pos(&self, handle: ClientHandle) -> Option<Position> {
|
pub(crate) fn get_incoming_pos(&self, handle: ClientHandle) -> Option<Position> {
|
||||||
|
|||||||
Reference in New Issue
Block a user