From d10173a018d0a6b50b0471108137016b8fa344b2 Mon Sep 17 00:00:00 2001
From: si458 <simonsmith5521@gmail.com>
Date: Sat, 8 Mar 2025 17:20:30 +0000
Subject: [PATCH] fix sharing-mobile view only having control #6764

Signed-off-by: si458 <simonsmith5521@gmail.com>
---
 views/sharing-mobile.handlebars | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/views/sharing-mobile.handlebars b/views/sharing-mobile.handlebars
index 9a4ee7fb..d60b8f3e 100644
--- a/views/sharing-mobile.handlebars
+++ b/views/sharing-mobile.handlebars
@@ -746,7 +746,7 @@
         var domainUrl = '{{{domainurl}}}';
         var authCookie = '{{{authCookie}}}';
         var authRelayCookie = '{{{authRelayCookie}}}';
-        var viewOnly = (parseInt('{{{viewOnly}}}') == 1);
+        var viewOnly = parseInt('{{{viewOnly}}}');
         var authCookieRenewTimer = null;
         var serverPublicNamePort = '{{{serverDnsName}}}:{{{serverPublicPort}}}';
         var debugmode = false;
@@ -864,7 +864,7 @@
                 gotKeyPressEvent = true;
                 Q('softKeyboard').value = '';
                 // Check what keys we are allows to send
-                if (viewOnly) return false;
+                if (viewOnly == 1) return false;
                 return desktop.m.handleKeys(e);
             }
             if (terminal && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 5) && (t !== 1)) {
@@ -892,7 +892,7 @@
                 gotKeyPressEvent = false;
                 Q('softKeyboard').value = '';
                 // Check what keys we are allows to send
-                if (viewOnly) return false;
+                if (viewOnly == 1) return false;
                 return desktop.m.handleKeyDown(e);
             }
             if (terminal && !xxdialogMode && (xxcurrentView == 10) && (currentDevicePanel == 5) && (t !== 1)) {
@@ -921,7 +921,7 @@
                 var inputStr = Q('softKeyboard').value;
                 Q('softKeyboard').value = '';
                 // Check what keys we are allows to send
-                if (viewOnly) return;
+                if (viewOnly == 1) return;
                 if ((gotKeyPressEvent == false) && (inputStr.length > 0) && desktop.m.SendKeyUnicode) {
                     // This is a mobile keyboard, we need to send that is in the input control.
                     var inputchar = inputStr[inputStr.length - 1].charCodeAt(0);
@@ -1081,6 +1081,7 @@
                     desktop = CreateAmtRedirect(CreateAmtRemoteDesktop('Desk'), authCookie);
                     desktop.debugmode = debugmode;
                     desktop.onStateChanged = onDesktopStateChange;
+                    desktop.m.stopInput = (viewOnly == 1);
                     desktop.m.bpp = (desktopsettings.encoding == 1 || desktopsettings.encoding == 3) ? 1 : 2;
                     desktop.m.useZRLE = (desktopsettings.encoding < 3);
                     desktop.m.showmouse = true;
@@ -1090,6 +1091,8 @@
                 } else if ((contype == null) || (contype == 1) || ((contype == 3))) {
                     // Setup the Mesh Agent remote desktop
                     desktop = CreateAgentRedirect(null, CreateAgentRemoteDesktop('Desk'), serverPublicNamePort, authCookie, null, domainUrl);
+                    desktop.m.stopInput = (viewOnly == 1);
+                    desktop.m.mouseCursorActive(true);
                     desktop.debugmode = debugmode;
                     desktop.m.debugmode = debugmode;
                     desktop.attemptWebRTC = attemptWebRTC;
@@ -1461,7 +1464,7 @@
             QV('deskarea4', !fullscreen);
             QV('termarea1', !fullscreen);
             QV('termarea4', !fullscreen);
-            var inputAllowed = !viewOnly;
+            var inputAllowed = (viewOnly == 0);
 
             // Show full screen buttons if needed
             QV('deskkeybutton1', fullscreen);