mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Merge remote-tracking branch 'rd/master' into feat/x11/clipboard-file/init
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
This commit is contained in:
@@ -1330,10 +1330,8 @@ impl Connection {
|
||||
return Config::get_option(enable_prefix_option).is_empty();
|
||||
}
|
||||
|
||||
async fn handle_login_request_without_validation(&mut self, lr: &LoginRequest) {
|
||||
self.lr = lr.clone();
|
||||
fn update_codec_on_login(&self, lr: &LoginRequest) {
|
||||
if let Some(o) = lr.option.as_ref() {
|
||||
self.options_in_login = Some(o.clone());
|
||||
if let Some(q) = o.supported_decoding.clone().take() {
|
||||
scrap::codec::Encoder::update(
|
||||
self.inner.id(),
|
||||
@@ -1351,6 +1349,16 @@ impl Connection {
|
||||
scrap::codec::EncodingUpdate::NewOnlyVP9,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_login_request_without_validation(&mut self, lr: &LoginRequest) {
|
||||
self.lr = lr.clone();
|
||||
if let Some(o) = lr.option.as_ref() {
|
||||
self.options_in_login = Some(o.clone());
|
||||
}
|
||||
if lr.union.is_none() {
|
||||
self.update_codec_on_login(&lr);
|
||||
}
|
||||
self.video_ack_required = lr.video_ack_required;
|
||||
}
|
||||
|
||||
@@ -2039,12 +2047,18 @@ impl Connection {
|
||||
|
||||
#[cfg(windows)]
|
||||
async fn handle_elevation_request(&mut self, para: portable_client::StartPara) {
|
||||
let mut err = "No need to elevate".to_string();
|
||||
if !crate::platform::is_installed() && !portable_client::running() {
|
||||
err = portable_client::start_portable_service(para)
|
||||
.err()
|
||||
.map_or("".to_string(), |e| e.to_string());
|
||||
let mut err;
|
||||
if !self.keyboard {
|
||||
err = "No permission".to_string();
|
||||
} else {
|
||||
err = "No need to elevate".to_string();
|
||||
if !crate::platform::is_installed() && !portable_client::running() {
|
||||
err = portable_client::start_portable_service(para)
|
||||
.err()
|
||||
.map_or("".to_string(), |e| e.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
let mut misc = Misc::new();
|
||||
misc.set_elevation_response(err);
|
||||
let mut msg = Message::new();
|
||||
@@ -2361,6 +2375,7 @@ impl Connection {
|
||||
if self.portable.is_installed
|
||||
|| self.file_transfer.is_some()
|
||||
|| self.port_forward_socket.is_some()
|
||||
|| !self.keyboard
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2371,8 +2386,8 @@ impl Connection {
|
||||
));
|
||||
if self.authorized {
|
||||
let p = &mut self.portable;
|
||||
if running != p.last_running {
|
||||
p.last_running = running;
|
||||
if Some(running) != p.last_running {
|
||||
p.last_running = Some(running);
|
||||
let mut misc = Misc::new();
|
||||
misc.set_portable_service_running(running);
|
||||
let mut msg = Message::new();
|
||||
@@ -2507,7 +2522,11 @@ async fn start_ipc(
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
log::debug!("Start cm");
|
||||
res = crate::platform::run_as_user(args.clone(), user.clone());
|
||||
res = crate::platform::run_as_user(
|
||||
args.clone(),
|
||||
user.clone(),
|
||||
None::<(&str, &str)>,
|
||||
);
|
||||
}
|
||||
if res.is_ok() {
|
||||
break;
|
||||
@@ -2652,7 +2671,7 @@ pub enum FileAuditType {
|
||||
pub struct PortableState {
|
||||
pub last_uac: bool,
|
||||
pub last_foreground_window_elevated: bool,
|
||||
pub last_running: bool,
|
||||
pub last_running: Option<bool>,
|
||||
pub is_installed: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ use super::*;
|
||||
use hbb_common::{allow_err, platform::linux::DISTRO};
|
||||
use scrap::{is_cursor_embedded, set_map_err, Capturer, Display, Frame, TraitCapturer};
|
||||
use std::io;
|
||||
use std::process::{Command, Output};
|
||||
|
||||
use crate::client::{
|
||||
SCRAP_OTHER_VERSION_OR_X11_REQUIRED, SCRAP_UBUNTU_HIGHER_REQUIRED, SCRAP_X11_REQUIRED,
|
||||
@@ -115,6 +116,22 @@ pub(super) fn is_inited() -> Option<Message> {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_max_desktop_resolution() -> Option<String> {
|
||||
// works with Xwayland
|
||||
let output: Output = Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg("xrandr | awk '/current/ { print $8,$9,$10 }'")
|
||||
.output()
|
||||
.ok()?;
|
||||
|
||||
if output.status.success() {
|
||||
let result = String::from_utf8_lossy(&output.stdout);
|
||||
Some(result.trim().to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn check_init() -> ResultType<()> {
|
||||
if !scrap::is_x11() {
|
||||
let mut minx = 0;
|
||||
@@ -151,10 +168,20 @@ pub(super) async fn check_init() -> ResultType<()> {
|
||||
num_cpus::get(),
|
||||
);
|
||||
|
||||
minx = origin.0;
|
||||
maxx = origin.0 + width as i32;
|
||||
miny = origin.1;
|
||||
maxy = origin.1 + height as i32;
|
||||
let (max_width, max_height) = match get_max_desktop_resolution() {
|
||||
Some(result) if !result.is_empty() => {
|
||||
let resolution: Vec<&str> = result.split(" ").collect();
|
||||
let w: i32 = resolution[0].parse().unwrap_or(origin.0 + width as i32);
|
||||
let h: i32 = resolution[2].trim_end_matches(",").parse().unwrap_or(origin.1 + height as i32);
|
||||
(w, h)
|
||||
}
|
||||
_ => (origin.0 + width as i32, origin.1 + height as i32)
|
||||
};
|
||||
|
||||
minx = 0;
|
||||
maxx = max_width;
|
||||
miny = 0;
|
||||
maxy = max_height;
|
||||
|
||||
let capturer = Box::into_raw(Box::new(
|
||||
Capturer::new(display, true).with_context(|| "Failed to create capturer")?,
|
||||
|
||||
Reference in New Issue
Block a user