fix sync displays info && select monitor menu

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-02-17 13:32:17 +08:00
parent 5b58e957f6
commit 302499d1e0
14 changed files with 234 additions and 108 deletions

View File

@@ -142,6 +142,20 @@ impl FlutterHandler {
}
*stream_lock = None;
}
fn make_displays_msg(displays: &Vec<DisplayInfo>) -> String {
let mut msg_vec = Vec::new();
for ref d in displays.iter() {
let mut h: HashMap<&str, i32> = Default::default();
h.insert("x", d.x);
h.insert("y", d.y);
h.insert("width", d.width);
h.insert("height", d.height);
h.insert("cursor_embedded", if d.cursor_embedded { 1 } else { 0 });
msg_vec.push(h);
}
serde_json::ser::to_string(&msg_vec).unwrap_or("".to_owned())
}
}
impl InvokeUiSession for FlutterHandler {
@@ -316,17 +330,7 @@ impl InvokeUiSession for FlutterHandler {
}
fn set_peer_info(&self, pi: &PeerInfo) {
let mut displays = Vec::new();
for ref d in pi.displays.iter() {
let mut h: HashMap<&str, i32> = Default::default();
h.insert("x", d.x);
h.insert("y", d.y);
h.insert("width", d.width);
h.insert("height", d.height);
h.insert("cursor_embedded", if d.cursor_embedded { 1 } else { 0 });
displays.push(h);
}
let displays = serde_json::ser::to_string(&displays).unwrap_or("".to_owned());
let displays = Self::make_displays_msg(&pi.displays);
let mut features: HashMap<&str, i32> = Default::default();
for ref f in pi.features.iter() {
features.insert("privacy_mode", if f.privacy_mode { 1 } else { 0 });
@@ -351,6 +355,13 @@ impl InvokeUiSession for FlutterHandler {
);
}
fn set_displays(&self, displays: &Vec<DisplayInfo>) {
self.push_event(
"sync_peer_info",
vec![("displays", &Self::make_displays_msg(displays))],
);
}
fn on_connected(&self, _conn_type: ConnType) {}
fn msgbox(&self, msgtype: &str, title: &str, text: &str, link: &str, retry: bool) {