gujjwal00 / avnc

VNC Client for Android
GNU General Public License v3.0
602 stars 57 forks source link

Feature request: resize the remote desktop if the server supports it #142

Closed sudomain closed 1 year ago

sudomain commented 1 year ago

I didn't know this existed until I tried the TigerVNC viewer client. Some servers (notably TigerVNC server) can be resized dynamically by the client. I think it would be great if AVNC supported this in preferences with a disclaimer that it needs to be supported by the server. This could work separately from the current zoom gestures: pinching would still zoom in/out on the client, while the initial connection and the onscreen keyboard appearing/disappearing can change the remote desktop size.

References: vncviewer man page from tigervnc: -RemoteResize Dynamically resize the remote desktop size as the size of the local client window changes. Note that this may not work with all VNC servers.

Screenshot_20230221-122744

xDoge26 commented 1 year ago

actually i dont like this . tiger vnc viewer doesnt preserve display resolution , which hurt the performance

babaric-dev commented 1 year ago

Best to make this setting optional (per server setting basis) if implemented. Maybe not everyone wants this feature.

sudomain commented 1 year ago

Sorry, I didn't mean to imply that it should be the default. As mentoned, if implemented it would require the server to support it as well. Since not every server supports resizing, the client option would have to be opt-in.

As for performance, I've only played with it a little. It seemed fine on my LAN with TigerVNC client (on a Raspberry Pi) connecting to the TigerVNC server running on my phone, and this was with the overhead of SSH port forwarding. Was it fast enough to stream a video? No, probably not, but it was fine for almost everything else.

xDoge26 commented 1 year ago

Also how would you resize dynamically if android always run in fullscreen 🤔

Rhys-T commented 1 year ago

This could also be useful for Termux users running graphical apps. I used the equivalent feature on another VNC client to make the TigerVNC server running under Termux follow the device's orientation (although I've since switched to using Termux:X11 instead of VNC).

Also how would you resize dynamically if android always run in fullscreen 🤔

The most likely way would probably be rotating the device between landscape and portrait. Opening/closing the keyboard could also do it, though it might make sense to include a separate option for whether or not that should be considered a resize. Also, it might not be fullscreen - some newer (or modified) versions of Android have support for split-screen mode, or even floating windows.

gujjwal00 commented 1 year ago
  1. If implemented, it will be an per-server optional feature. So don't worry about unintended regressions.
  2. An option to specify explicit size (like Width x Height in first screenshot) is not something I want to implement. If you want a fixed custom size, you can already do that directly on server.
  3. An option to dynamically resize to available window size can be implemented.

As for the handling keyboard, here is the what I am thinking:

Rhys-T commented 1 year ago

My reasoning behind making resize-on-keyboard-open an option was basically just 'Termux:X11 has an option for it'. Either way works for me.

sudomain commented 1 year ago

FWIW I also use Termux/VNC and I have a bad script saved to my desktop for switching orientations on my phone. It requires reconnecting AVNC after running:

#!/usr/bin/env sh
# Switches between portrait and landscape orientation (needed on my phone)
# After doing this, you'll probably need to reconnect your VNC client

xrandr | grep "current 1080 x 1920" >> /dev/null

if [ $? -eq 0 ]; then
    xrandr --fb 1920x1080
else
    xrandr --fb 1080x1920
fi

I've tried something similar with the keyboard but it didn't work well and still required reconnecting AVNC so it was pretty much a non-starter

gujjwal00 commented 1 year ago

Please test his APK: app-debug.zip It should resize remote screen to match with local window.

Note: UI to turn it off is not added yet.

Rhys-T commented 1 year ago

Sorry it took so long for me to get back to this.

So far, it seems to work fine. I've tried various combinations of rotating the device, split-screening AVNC with other apps, and putting it into a floating window, and the server (a TigerVNC server running under Termux on the same device) always seems to get updated to match it perfectly. The only thing that didn't trigger a resize was opening/closing the keyboard. That's fine if you decided against it, or just haven't implemented it yet. I just wanted to mention it in case that wasn't expected behavior.

sudomain commented 1 year ago

I'm also sorry about my slow feedback, it got lost in a slew of notifications until I saw the previous comment. I'm also running TigerVNC on Termux, and the experience with this apk has been great. I'm surprised how smooth the server and applications respond to the resizing. Resizing for keyboard/extra keys when in portrait would be nice, but the current behavior is amazing, thank you for your efforts.

gujjwal00 commented 1 year ago

No problem at all, thank you for testing! I will add a checkbox in advanced server options to control this.

Current patch ignores keyboard in all orientations. I will try to handle it in portrait mode, unless it becomes too complicated.

sudomain commented 1 year ago

Hmm I just had trouble getting my TigerVNC server to resize with this new apk. I restarted AVNC, but nothing. I restarted the server and then resizing started working again. Bc of this, its probably an issue with the server. It had been running continuously for a few days and I don't think I changed any config in that time. Something to keep in mind if other users of TigerVNC server report it.

gujjwal00 commented 1 year ago

Yes, there was a bug in the APK linked above. I didn't check the window size before trying to send it. Sometimes VNC connection would be initialized before local window is fully setup, so AVNC would try to set the remote size to 0x0. But 0x0 size is used internally by LibVNCClient as a flag signal that server doesn't support resize. So all future resize requests would be ignored by LibVNCClient. If you check logs in AVNC settings, you will likely see some messages about Sending dimensions 0x0 and Screen not yet received etc.

This has been fixed, and will be available next release (hopefully later today).

sudomain commented 1 year ago

Thanks again!

gujjwal00 commented 1 year ago

v2.2.2 is now available.