fix on cm (connectin not closed somehow) and refactor isEnterKey

This commit is contained in:
open-trade 2022-02-09 16:06:44 +08:00
parent d313fa92e1
commit 4945605009
9 changed files with 49 additions and 27 deletions

View File

@ -335,6 +335,7 @@ impl Connection {
let _ = crate::platform::block_input(false); let _ = crate::platform::block_input(false);
crate::platform::toggle_blank_screen(false); crate::platform::toggle_blank_screen(false);
log::info!("#{} connection loop exited", id);
} }
fn handle_input(receiver: std_mpsc::Receiver<MessageInput>, tx: Sender) { fn handle_input(receiver: std_mpsc::Receiver<MessageInput>, tx: Sender) {
@ -933,7 +934,10 @@ impl Connection {
} }
} }
Some(misc::Union::video_received(_)) => { Some(misc::Union::video_received(_)) => {
video_service::notify_video_frame_feched(self.inner.id, Some(Instant::now().into())); video_service::notify_video_frame_feched(
self.inner.id,
Some(Instant::now().into()),
);
} }
_ => {} _ => {}
}, },
@ -1039,6 +1043,7 @@ impl Connection {
crate::platform::lock_screen(); crate::platform::lock_screen();
super::video_service::switch_to_primary(); super::video_service::switch_to_primary();
} }
self.tx_to_cm.send(ipc::Data::Close).ok();
self.port_forward_socket.take(); self.port_forward_socket.take();
} }

View File

@ -18,6 +18,7 @@ div.left-panel {
div.chaticon svg { div.chaticon svg {
size: 24px; size: 24px;
margin: 4px; margin: 4px;
opacity: 0.66;
} }
div.chaticon { div.chaticon {
@ -25,10 +26,11 @@ div.chaticon {
right: 0; right: 0;
top: 0; top: 0;
size: 32px; size: 32px;
background-color: color(gray-bg);
} }
div.chaticon.active { div.chaticon:hover svg {
opacity: 0.5; opacity: 1;
} }
div.chaticon:active { div.chaticon:active {
@ -209,6 +211,7 @@ div.tab-arrows {
position: absolute; position: absolute;
right: 2px; right: 2px;
font-weight: bold; font-weight: bold;
background: white;
} }
div.tab-arrows span { div.tab-arrows span {
@ -216,4 +219,15 @@ div.tab-arrows span {
height: *; height: *;
margin: 0; margin: 0;
padding: 6px 2px; padding: 6px 2px;
line-height: 20px;
opacity: 0.66;
} }
div.tab-arrows span:hover {
opacity: 1;
}
div.tab-arrows span:active {
opacity: 1;
background-color: #ddd;
}

View File

@ -349,6 +349,10 @@ async fn start_ipc(cm: ConnectionManager) {
conn_id = id; conn_id = id;
cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, tx.clone()); cm.add_connection(id, is_file_transfer, port_forward, peer_id, name, authorized, keyboard, clipboard, audio, tx.clone());
} }
Data::Close => {
log::info!("cm ipc connection closed from connection request");
break;
}
_ => { _ => {
cm.handle_data(conn_id, data, &mut write_jobs, &mut stream).await; cm.handle_data(conn_id, data, &mut write_jobs, &mut stream).await;
} }

View File

@ -22,7 +22,6 @@ class Body: Reactor.Component
var callback = function(msg) { var callback = function(msg) {
me.sendMsg(msg); me.sendMsg(msg);
}; };
self.timer(1ms, adaptSize);
var right_style = show_chat ? "" : "display: none"; var right_style = show_chat ? "" : "display: none";
return <div .content> return <div .content>
<div .left-panel> <div .left-panel>
@ -153,8 +152,8 @@ class Header: Reactor.Component
{tabs} {tabs}
</div> </div>
<div .tab-arrows> <div .tab-arrows>
<span .left-arrow>&lt;</span> <span #left-arrow>&lt;</span>
<span .right-arrow>&gt;</span> <span #right-arrow>&gt;</span>
</div> </div>
</div>; </div>;
} }
@ -181,13 +180,13 @@ class Header: Reactor.Component
this.update_cur(idx); this.update_cur(idx);
} }
event click $(span.left-arrow) { event click $(span#left-arrow) {
var cur = body.cur; var cur = body.cur;
if (cur == 0) return; if (cur == 0) return;
this.update_cur(cur - 1); this.update_cur(cur - 1);
} }
event click $(span.right-arrow) { event click $(span#right-arrow) {
var cur = body.cur; var cur = body.cur;
if (cur == connections.length - 1) return; if (cur == connections.length - 1) return;
this.update_cur(cur + 1); this.update_cur(cur + 1);
@ -205,7 +204,7 @@ if (is_osx) {
event click $(div.chaticon) { event click $(div.chaticon) {
checkClickTime(function() { checkClickTime(function() {
show_chat = !show_chat; show_chat = !show_chat;
adaptSize(); adaptSizeForChat();
}); });
} }
@ -213,12 +212,10 @@ function checkClickTime(callback) {
callback(); callback();
} }
function adaptSize() { function adaptSizeForChat() {
$(div.right-panel).style.set { $(div.right-panel).style.set {
display: show_chat ? "block" : "none", display: show_chat ? "block" : "none",
}; };
var el = $(div.chaticon);
if (el) el.attributes.toggleClass("active", show_chat);
var (x, y, w, h) = view.box(#rectw, #border, #screen); var (x, y, w, h) = view.box(#rectw, #border, #screen);
if (show_chat && w < 600) { if (show_chat && w < 600) {
view.move(x - (600 - w), y, 600, h); view.move(x - (600 - w), y, 600, h);
@ -298,7 +295,11 @@ handler.newMessage = function(id, text) {
if (!conn) return; if (!conn) return;
conn.msgs.push({name: conn.name, text: text, time: getNowStr()}); conn.msgs.push({name: conn.name, text: text, time: getNowStr()});
bring_to_top(idx); bring_to_top(idx);
if (idx == body.cur) show_chat = true; if (idx == body.cur) {
var shouldAdapt = !show_chat;
show_chat = true;
if (shouldAdapt) adaptSizeForChat();
}
conn.unreaded += 1; conn.unreaded += 1;
update(); update();
} }

View File

@ -10,6 +10,11 @@ var is_file_transfer;
var is_xfce = false; var is_xfce = false;
try { is_xfce = handler.is_xfce(); } catch(e) {} try { is_xfce = handler.is_xfce(); } catch(e) {}
function isEnterKey(evt) {
return (evt.keyCode == Event.VK_ENTER ||
(is_osx && evt.keyCode == 0x4C) ||
(is_linux && evt.keyCode == 65421));
}
function translate(name) { function translate(name) {
try { try {
@ -195,10 +200,9 @@ class ChatBox: Reactor.Component {
event keydown $(input) (evt) { event keydown $(input) (evt) {
if (!evt.shortcutKey) { if (!evt.shortcutKey) {
if (evt.keyCode == Event.VK_ENTER || if (isEnterKey(evt)) {
(view.mediaVar("platform") == "OSX" && evt.keyCode == 0x4C)) { this.send();
this.send(); }
}
} }
} }

View File

@ -510,8 +510,7 @@ class FolderView : Reactor.Component {
} }
event keydown $(.select-dir) (evt, me) { event keydown $(.select-dir) (evt, me) {
if (evt.keyCode == Event.VK_ENTER || if (isEnterKey(evt)) {
(view.mediaVar("platform") == "OSX" && evt.keyCode == 0x4C)) {
this.goto(me.value, true); this.goto(me.value, true);
} }
} }

View File

@ -250,8 +250,7 @@ class Grid: Behavior {
idx += 1; idx += 1;
} }
} }
if (evt.keyCode == Event.VK_ENTER || if (isEnterKey(evt)) {
(view.mediaVar("platform") == "OSX" && evt.keyCode == 0x4C)) {
this.onRowDoubleClick(this.getCurrentRow()); this.onRowDoubleClick(this.getCurrentRow());
} }
return false; return false;

View File

@ -665,9 +665,7 @@ event keydown (evt) {
return; return;
} }
if (!evt.shortcutKey) { if (!evt.shortcutKey) {
if (evt.keyCode == Event.VK_ENTER || if (isEnterKey(evt)) {
(is_osx && evt.keyCode == 0x4C) ||
(is_linux && evt.keyCode == 65421)) {
var el = $(button#connect); var el = $(button#connect);
view.focus = el; view.focus = el;
el.sendEvent("click"); el.sendEvent("click");

View File

@ -174,9 +174,7 @@ class MsgboxComponent: Reactor.Component {
event keydown (evt) { event keydown (evt) {
if (!evt.shortcutKey) { if (!evt.shortcutKey) {
if (evt.keyCode == Event.VK_ENTER || if (isEnterKey(evt)) {
(is_osx && evt.keyCode == 0x4C) ||
(is_linux && evt.keyCode == 65421)) {
this.submit(); this.submit();
} }
if (evt.keyCode == Event.VK_ESCAPE) { if (evt.keyCode == Event.VK_ESCAPE) {