diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 0bb979b7c..2ec552f26 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -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::*; diff --git a/src/ui.rs b/src/ui.rs index 729b62b91..a8e1450ff 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -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); diff --git a/src/ui/common.tis b/src/ui/common.tis index 2f6987337..2b14e1d79 100644 --- a/src/ui/common.tis +++ b/src/ui/common.tis @@ -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; diff --git a/src/ui/header.tis b/src/ui/header.tis index 4132eab46..b662934a9 100644 --- a/src/ui/header.tis +++ b/src/ui/header.tis @@ -15,10 +15,28 @@ var svg_insecure = ; var svg_secure_relay = ; -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
{title}
; + return
{title}
; } var screens = pi.displays.map(function(d, i) { return
diff --git a/src/ui/remote.rs b/src/ui/remote.rs index 61a692ff0..f18600fc9 100644 --- a/src/ui/remote.rs +++ b/src/ui/remote.rs @@ -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();