diff --git a/src/ui.rs b/src/ui.rs
index 6e867c53b..614763d47 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -31,13 +31,6 @@ struct UI(
struct UIHostHandler;
-fn get_msgbox() -> String {
- #[cfg(feature = "inline")]
- return inline::get_msgbox();
- #[cfg(not(feature = "inline"))]
- return "".to_owned();
-}
-
pub fn start(args: &mut [String]) {
// https://github.com/c-smile/sciter-sdk/blob/master/include/sciter-x-types.h
// https://github.com/rustdesk/rustdesk/issues/132#issuecomment-886069737
@@ -227,10 +220,6 @@ impl UI {
Config::set_remote_id(&id);
}
- fn get_msgbox(&mut self) -> String {
- get_msgbox()
- }
-
fn goto_install(&mut self) {
allow_err!(crate::run_me(vec!["--install"]));
}
@@ -670,7 +659,6 @@ impl sciter::EventHandler for UI {
fn store_fav(Value);
fn recent_sessions_updated();
fn get_icon();
- fn get_msgbox();
fn install_me(String);
fn is_installed();
fn set_socks(String, String, String);
diff --git a/src/ui/common.css b/src/ui/common.css
index df1ea1f44..587ccc957 100644
--- a/src/ui/common.css
+++ b/src/ui/common.css
@@ -214,24 +214,24 @@ header caption {
}
}
-div.msgbox {
+div.chatbox {
size: *;
}
-div.msgbox div.send svg {
+div.chatbox div.send svg {
size: 16px;
}
-div.msgbox div.send span:active {
+div.chatbox div.send span:active {
opacity: 0.5;
}
-div.msgbox div.send span {
+div.chatbox div.send span {
display: inline-block;
padding: 6px;
}
-div.msgbox .msgs {
+div.chatbox .msgs {
border: none;
size: *;
border-bottom: color(border) 1px solid;
@@ -241,25 +241,25 @@ div.msgbox .msgs {
padding: 1em;
}
-div.msgbox div.send {
+div.chatbox div.send {
flow: horizontal;
height: 30px;
padding: 5px;
}
-div.msgbox div.send input {
+div.chatbox div.send input {
height: 20px !important;
}
-div.msgbox div.name {
+div.chatbox div.name {
color: color(dark-green);
}
-div.msgbox div.right-side div {
+div.chatbox div.right-side div {
text-align: right;
}
-div.msgbox div.text {
+div.chatbox div.text {
margin-top: 0.5em;
}
@@ -328,3 +328,62 @@ menu li.line-through {
text-decoration-line: line-through;
color: red;
}
+
+div#msgbox .msgbox-icon svg {
+ size: 80px;
+ background: white;
+
+}
+div#msgbox .form {
+ border-spacing: 0.5em;
+}
+
+div#msgbox .caption {
+ @ELLIPSIS;
+ height: 2em;
+ line-height: 2em;
+ text-align: center;
+ color: white;
+ font-weight: bold;
+}
+
+div#msgbox .form .text {
+ @ELLIPSIS;
+}
+
+div#msgbox button.button {
+ margin-left: 1.6em;
+}
+
+div#msgbox div.password {
+ position: relative;
+}
+
+div#msgbox div.password svg {
+ position: absolute;
+ right: 0.25em;
+ top: 0.25em;
+ padding: 0.5em;
+ color: color(text);
+}
+
+div#msgbox div.set-password > div {
+ flow: horizontal;
+}
+
+div#msgbox div.set-password > div > span {
+ width: 30%;
+ line-height: 2em;
+}
+
+div#msgbox div.set-password div.password {
+ width: *;
+}
+
+div#msgbox div.set-password input {
+ font-size: 1em;
+}
+
+div#msgbox #error {
+ color: red;
+}
diff --git a/src/ui/common.tis b/src/ui/common.tis
index b4e0bf190..be9b99094 100644
--- a/src/ui/common.tis
+++ b/src/ui/common.tis
@@ -174,7 +174,7 @@ class ChatBox: Reactor.Component {
self.timer(1ms, function() {
scrollToBottom(me.msgs);
});
- return
+ return
{msgs}
@@ -211,81 +211,70 @@ class ChatBox: Reactor.Component {
/******************** start of msgbox ****************************************/
var remember_password = false;
-var msgbox_params;
-function getMsgboxParams() {
- return msgbox_params;
-}
-
-// tmp workaround https://sciter.com/forums/topic/menu-not-be-hidden-when-open-dialog-on-linux/
-function msgbox(type, title, text, callback=null, height=180, width=500, retry=0, contentStyle="") {
- if (is_linux) { // fix menu not hidden issue
- self.timer(1ms,
- function() {
- msgbox_(type, title, text, callback, height, width, retry, contentStyle);
- });
- } else {
- msgbox_(type, title, text, callback, height, width, retry, contentStyle);
+function bring_to_top(idx=-1) {
+ if (view.windowState == View.WINDOW_HIDDEN || view.windowState == View.WINDOW_MINIMIZED) {
+ if (is_linux) {
+ view.focus = self;
+ } else {
+ view.windowState = View.WINDOW_SHOWN;
+ }
+ if (idx >= 0) body.cur = idx;
+ } else {
+ view.windowTopmost = true;
+ view.windowTopmost = false;
+ }
+}
+function msgbox(type, title, content, callback=null, height=180, width=500, hasRetry=false, contentStyle="") {
+ if (!type) {
+ closeMsgbox();
+ return;
}
-}
-
-function msgbox_(type, title, text, callback, height, width, retry, contentStyle) {
- var has_msgbox = msgbox_params != null;
- if (!has_msgbox && !type) return;
var remember = false;
- try {
- remember = handler.get_remember();
- } catch(e) {}
- msgbox_params = {
- remember: remember, type: type, text: text, title: title,
- getParams: getMsgboxParams,
- callback: callback, translate: translate,
- retry: retry, contentStyle: contentStyle,
- };
- if (has_msgbox) return;
- var dialog = {
- client: true,
- parameters: msgbox_params,
- width: width + (is_xfce ? 50 : 0),
- height: height + (is_xfce ? 50 : 0),
- };
- var html = handler.get_msgbox();
- if (html) dialog.html = html;
- else dialog.url = self.url("msgbox.html");
- var res = view.dialog(dialog);
- msgbox_params = null;
- stdout.printf("msgbox return, type: %s, res: %s\n", type, res);
- if (type.indexOf("custom") >= 0) {
- //
- } else if (!res) {
- if (!is_port_forward) view.close();
- } else if (res == "!alive") {
- // do nothing
- } else if (res.type == "input-password") {
- handler.login(res.password, res.remember);
- if (!is_port_forward) msgbox("connecting", "Connecting...", "Logging in...");
- } else if (res.reconnect) {
- if (!is_port_forward) connecting();
- handler.reconnect();
+ try { remember = handler.get_remember(); } catch(e) {}
+ width += is_xfce ? 50 : 0;
+ height += is_xfce ? 50 : 0;
+
+ if (type == "input-password") {
+ callback = function (res) {
+ if (!res) {
+ view.close();
+ return;
+ }
+ handler.login(res.password, res.remember);
+ if (!is_port_forward) msgbox("connecting", "Connecting...", "Logging in...");
+ };
+ } else if (type.indexOf("custom") < 0 && !is_port_forward && !callback) {
+ callback = function() { view.close(); }
}
+ $(#msgbox).content();
}
function connecting() {
handler.msgbox("connecting", "Connecting...", "Connection in progress. Please wait.");
}
-handler.msgbox = function(type, title, text, retry=0) {
- self.timer(30ms, function() { msgbox(type, title, text, null, 180, 500, retry); });
+handler.msgbox = function(type, title, text, hasRetry=false) {
+ msgbox(type, title, text, null, 180, 500, hasRetry);
}
-var reconnectTimeout = 1;
+var reconnectTimeout = 1000;
+var activeTimer = function() {};
handler.msgbox_retry = function(type, title, text, hasRetry) {
- handler.msgbox(type, title, text, hasRetry ? reconnectTimeout : 0);
+ handler.msgbox(type, title, text, hasRetry);
if (hasRetry) {
+ self.timer(0, activeTimer);
+ activeTimer = self.timer(reconnectTimeout, retryConnect);
reconnectTimeout *= 2;
} else {
- reconnectTimeout = 1;
+ reconnectTimeout = 1000;
}
}
+
+function retryConnect(cancelTimer=false) {
+ if (!is_port_forward) connecting();
+ handler.reconnect();
+ if (cancelTimer) self.timer(0, activeTimer);
+}
/******************** end of msgbox ****************************************/
function Progress()
diff --git a/src/ui/index.html b/src/ui/index.html
index fc24b564a..88c172231 100644
--- a/src/ui/index.html
+++ b/src/ui/index.html
@@ -7,6 +7,7 @@
diff --git a/src/ui/index.tis b/src/ui/index.tis
index d9625eb43..b1b23475a 100644
--- a/src/ui/index.tis
+++ b/src/ui/index.tis
@@ -326,6 +326,7 @@ class App: Reactor.Component
+