mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-25 22:21:01 +03:00
feat: take screenshot (#11591)
* feat: take screenshot Signed-off-by: fufesou <linlong1266@gmail.com> * screenshot, vram temp switch capturer Signed-off-by: fufesou <linlong1266@gmail.com> * fix: misspelling Signed-off-by: fufesou <linlong1266@gmail.com> * screenshot, taking Signed-off-by: fufesou <linlong1266@gmail.com> * screenshot, rgba stride Signed-off-by: fufesou <linlong1266@gmail.com> * Bumps 1.4.0 Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -543,6 +543,25 @@ impl FlutterHandler {
|
||||
pub fn push_event<V>(&self, name: &str, event: &[(&str, V)], excludes: &[&SessionID])
|
||||
where
|
||||
V: Sized + Serialize + Clone,
|
||||
{
|
||||
self.push_event_(name, event, &[], excludes);
|
||||
}
|
||||
|
||||
pub fn push_event_to<V>(&self, name: &str, event: &[(&str, V)], include: &[&SessionID])
|
||||
where
|
||||
V: Sized + Serialize + Clone,
|
||||
{
|
||||
self.push_event_(name, event, include, &[]);
|
||||
}
|
||||
|
||||
pub fn push_event_<V>(
|
||||
&self,
|
||||
name: &str,
|
||||
event: &[(&str, V)],
|
||||
includes: &[&SessionID],
|
||||
excludes: &[&SessionID],
|
||||
) where
|
||||
V: Sized + Serialize + Clone,
|
||||
{
|
||||
let mut h: HashMap<&str, serde_json::Value> =
|
||||
event.iter().map(|(k, v)| (*k, json!(*v))).collect();
|
||||
@@ -550,11 +569,20 @@ impl FlutterHandler {
|
||||
h.insert("name", json!(name));
|
||||
let out = serde_json::ser::to_string(&h).unwrap_or("".to_owned());
|
||||
for (sid, session) in self.session_handlers.read().unwrap().iter() {
|
||||
if excludes.contains(&sid) {
|
||||
continue;
|
||||
let mut push = false;
|
||||
if includes.is_empty() {
|
||||
if !excludes.contains(&sid) {
|
||||
push = true;
|
||||
}
|
||||
} else {
|
||||
if includes.contains(&sid) {
|
||||
push = true;
|
||||
}
|
||||
}
|
||||
if let Some(stream) = &session.event_stream {
|
||||
stream.add(EventToUI::Event(out.clone()));
|
||||
if push {
|
||||
if let Some(stream) = &session.event_stream {
|
||||
stream.add(EventToUI::Event(out.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1067,6 +1095,16 @@ impl InvokeUiSession for FlutterHandler {
|
||||
&[],
|
||||
);
|
||||
}
|
||||
|
||||
fn handle_screenshot_resp(&self, sid: String, msg: String) {
|
||||
match SessionID::from_str(&sid) {
|
||||
Ok(sid) => self.push_event_to("screenshot", &[("msg", json!(msg))], &[&sid]),
|
||||
Err(e) => {
|
||||
// Unreachable!
|
||||
log::error!("Failed to parse sid \"{}\", {}", sid, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FlutterHandler {
|
||||
|
||||
Reference in New Issue
Block a user