fix on linux

This commit is contained in:
rustdesk 2021-05-02 21:19:48 +08:00
parent 547b85adbf
commit 2adc774d8a
5 changed files with 46 additions and 5 deletions

View File

@ -17,6 +17,17 @@ pub mod linux;
use hbb_common::{message_proto::CursorData, ResultType};
const SERVICE_INTERVAL: u64 = 300;
pub fn is_xfce() -> bool {
#[cfg(target_os = "linux")]
{
return std::env::var_os("XDG_CURRENT_DESKTOP") == Some(std::ffi::OsString::from("XFCE"));
}
#[cfg(not(target_os = "linux"))]
{
return false;
}
}
#[cfg(test)]
mod tests {
use super::*;

View File

@ -495,10 +495,15 @@ impl UI {
let p = "xdg-open";
allow_err!(std::process::Command::new(p).arg(url).spawn());
}
fn is_xfce(&self) -> bool {
crate::platform::is_xfce()
}
}
impl sciter::EventHandler for UI {
sciter::dispatch_script_call! {
fn is_xfce();
fn get_id();
fn get_password();
fn update_password(String);

View File

@ -7,6 +7,8 @@ var is_osx = OS == "OSX";
var is_win = OS == "Windows";
var is_linux = OS == "Linux";
var is_file_transfer;
var is_xfce = false;
try { is_xfce = handler.is_xfce(); } catch(e) {}
function hashCode(str) {
var hash = 160 << 16 + 114 << 8 + 91;
@ -221,8 +223,8 @@ function msgbox(type, title, text, callback, height, width) {
var dialog = {
client: true,
parameters: msgbox_params,
width: width,
height: height,
width: width + (is_xfce ? 50 : 0),
height: height + (is_xfce ? 50 : 0),
};
var html = handler.get_msgbox();
if (html) dialog.html = html;

View File

@ -15,10 +15,28 @@ var svg_insecure = <svg viewBox="0 0 347.97 347.97"><path d="M317.469 61.615c-59
var svg_insecure_relay = <svg viewBox="0 0 347.97 347.97"><path d="M317.469 61.615c-59.442 0-104.976-16.082-143.489-51.539-38.504 35.457-84.04 51.539-143.479 51.539 0 92.337-20.177 224.612 143.479 278.324 163.661-53.717 143.489-185.992 143.489-278.324z" fill="none" stroke="red" stroke-width="14.827"/><g fill="red"><path d="M231.442 247.498l-7.754-10.205c-17.268 12.441-38.391 17.705-59.478 14.822-21.087-2.883-39.613-13.569-52.166-30.088-25.916-34.101-17.997-82.738 17.65-108.42 32.871-23.685 78.02-19.704 105.172 7.802l-32.052 7.987 3.082 12.369 48.722-12.142-11.712-46.998-12.822 3.196 4.496 18.039c-31.933-24.008-78.103-25.342-112.642-.458-31.361 22.596-44.3 60.436-35.754 94.723 2.77 11.115 7.801 21.862 15.192 31.588 30.19 39.727 88.538 47.705 130.066 17.785z"/></g></svg>;
var svg_secure_relay = <svg viewBox="0 0 347.97 347.97"><path d="M317.469 61.615c-59.442 0-104.976-16.082-143.489-51.539-38.504 35.457-84.04 51.539-143.479 51.539 0 92.337-20.177 224.612 143.479 278.324 163.661-53.717 143.489-185.992 143.489-278.324z" fill="#3f7d46" stroke="#3f7d46" stroke-width="14.827"/><g fill="red"><path d="M231.442 247.498l-7.754-10.205c-17.268 12.441-38.391 17.705-59.478 14.822-21.087-2.883-39.613-13.569-52.166-30.088-25.916-34.101-17.997-82.738 17.65-108.42 32.871-23.685 78.02-19.704 105.172 7.802l-32.052 7.987 3.082 12.369 48.722-12.142-11.712-46.998-12.822 3.196 4.496 18.039c-31.933-24.008-78.103-25.342-112.642-.458-31.361 22.596-44.3 60.436-35.754 94.723 2.77 11.115 7.801 21.862 15.192 31.588 30.19 39.727 88.538 47.705 130.066 17.785z" fill="#fff"/></g></svg>;
view << event statechange {
var cur_window_state = view.windowState;
function check_state_change() {
if (view.windowState != cur_window_state) {
stateChanged();
}
self.timer(30ms, check_state_change);
}
if (is_linux) {
check_state_change();
} else {
view << event statechange {
stateChanged();
}
}
function stateChanged() {
stdout.println('state changed from ' + cur_window_state + ' -> ' + view.windowState);
cur_window_state = view.windowState;
adjustBorder();
adaptDisplay();
view.focus = handler;
if (!is_linux) view.focus = handler; // this cause windows always topmost on linux
var fs = view.windowState == View.WINDOW_FULL_SCREEN;
var el = $(#fullscreen);
if (el) el.attributes.toggleClass("active", fs);
@ -56,7 +74,7 @@ class Header: Reactor.Component {
var title = handler.get_id();
if (pi.hostname) title += "(" + pi.username + "@" + pi.hostname + ")";
if ((pi.displays || []).length == 0) {
return <div .ellipsis style={is_osx || is_win ? "size:*;text-align:center;margin:*;" : ""}>{title}</div>;
return <div .ellipsis style="size:*;text-align:center;margin:*;">{title}</div>;
}
var screens = pi.displays.map(function(d, i) {
return <div #screen class={pi.current_display == i ? "current" : ""}>

View File

@ -139,6 +139,7 @@ impl sciter::EventHandler for Handler {
}
sciter::dispatch_script_call! {
fn is_xfce();
fn get_id();
fn get_default_pi();
fn get_option(String);
@ -279,6 +280,10 @@ impl Handler {
self.lc.read().unwrap().remember
}
fn is_xfce(&self) -> bool {
crate::platform::is_xfce()
}
fn save_size(&mut self, x: i32, y: i32, w: i32, h: i32) {
let size = (x, y, w, h);
let mut config = self.load_config();