Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent session resize when on screen keyboard is opened #1667

Open
10tecs opened this issue Jul 28, 2022 · 3 comments
Open

Prevent session resize when on screen keyboard is opened #1667

10tecs opened this issue Jul 28, 2022 · 3 comments

Comments

@10tecs
Copy link

10tecs commented Jul 28, 2022

Is your feature request related to a problem? Please describe.
Using touch device, I toggle on screen keyboard: toggleVirtualKeyboard(). When it shows and hides, the noVNC _canvas resizes to fit the available viewport.

Describe the solution you'd like
I would like to have the on screen keyboard overlay the _canvas content so that it does not resize.

Describe alternatives you've considered
I've read through rfb.js and display.js which I assume contain some variable (min height/resize/isOverlay keyboard) but trial and error not lucky. Also tried remote/local/none scaling but I believe it is due to the canvas element resizing so viewport is not relevant.

Additional context
I think it's well explained and maybe even too simple a problem to ask, sorry I am beginner only. If any information requested I will provide. Thank you for your time.

@samhed
Copy link
Member

samhed commented Aug 1, 2022

I agree, this would be nice.

This was not a conscious decision, this is how the onscreen keyboard works on Android. It's difficult to make things work differently if you simultaneously want automatic resize.

I saw that you wrote on the mailing list; my answer there:

I'm guessing you're using an Android device? On iOS and iPadOS, the
keyboard works more as an "overlay", like you want.

Unfortunately, on Android the keyboard works differently, and the
browser creates a resize-event. It's difficult to determine if that
resize was triggered by opening the keyboard or by something else.

For your specific case, the easiest solution might be to disable remote
resize and set the session size manually on the remote instead.

@samhed
Copy link
Member

samhed commented Aug 1, 2022

Perhaps it's possible to find a nice way to pause the resizeObserver in showVirtualKeyboard() and then resume it in hideVirtualKeyboard().

@samhed
Copy link
Member

samhed commented Aug 1, 2022

This patch seems to work quite OK, do you mind giving it a try?

diff --git a/app/ui.js b/app/ui.js
index 95f938d..a2ceed3 100644
--- a/app/ui.js
+++ b/app/ui.js
@@ -1410,6 +1410,8 @@ const UI = {
     showVirtualKeyboard() {
         if (!isTouchDevice) return;

+        // Temporarily disable remote resize
+        UI.rfb.resizeSession = false;
+
         const input = document.getElementById('noVNC_keyboardinput');

         if (document.activeElement == input) return;
@@ -1433,6 +1435,11 @@ const UI = {
         if (document.activeElement != input) return;

         input.blur();
+
+        // Restore resize setting
+        window.setTimeout(function () {
+            UI.applyResizeMode()
+            UI.updateViewClip()
+        }, 50);
     },

     toggleVirtualKeyboard() {

With that patch alone, there are problems when the onscreen keyboard is closed by means other than the GUI button, but perhaps that can be fixed too.

@CendioOssman CendioOssman changed the title Prevent _canvas resizing when toggleVirtualKeyboard() is invoked on touch device Prevent session resize when on screen keyboard is opened Aug 18, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants