From 334c94ceb32fe0714c4b816f85883472014548e9 Mon Sep 17 00:00:00 2001 From: open-trade Date: Wed, 22 Dec 2021 14:28:08 +0800 Subject: [PATCH] https://github.com/rustdesk/rustdesk/issues/210 --- src/ui/common.tis | 7 +++++++ src/ui/index.tis | 6 +++--- src/ui/remote.tis | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ui/common.tis b/src/ui/common.tis index 6af29ab02..679744439 100644 --- a/src/ui/common.tis +++ b/src/ui/common.tis @@ -311,3 +311,10 @@ function Progress() this.value = ""; } + +function isReasonableSize(r) { + var x = r[0]; + var y = r[1]; + return !(x < -3200 || x > 3200 || y < -3200 || y > 3200); +} + diff --git a/src/ui/index.tis b/src/ui/index.tis index 55fcf6f7c..5bffff322 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -708,10 +708,10 @@ function self.closing() { function self.ready() { var r = handler.get_size(); - if (r[2] == 0) { - centerize(800, 600); - } else { + if (isReasonableSize(r) && r[2] > 0) { view.move(r[0], r[1], r[2], r[3]); + } else { + centerize(800, 600); } if (!handler.get_remote_id()) { view.focus = $(#remote_id); diff --git a/src/ui/remote.tis b/src/ui/remote.tis index f78d8ec65..061fb5241 100644 --- a/src/ui/remote.tis +++ b/src/ui/remote.tis @@ -396,7 +396,7 @@ function self.ready() { var h = 640; if (is_file_transfer || is_port_forward) { var r = handler.get_size(); - if (r[0] > 0) { + if (isReasonableSize(r) && r[2] > 0) { view.move(r[0], r[1], r[2], r[3]); } else { centerize(w, h); @@ -418,7 +418,7 @@ handler.adaptSize = function() { var (fx, fy, fw, fh) = view.screenBox(#frame, #rectw); if (is_osx) workarea_offset = sy; var r = handler.get_size(); - if (r[2] > 0) { + if (isReasonableSize(r) && r[2] > 0) { if (r[2] >= fw && r[3] >= fh && !is_linux) { view.windowState = View.WINDOW_FULL_SCREEN; stdout.println("Initialize to full screen");