Skip to content

Scale remote screen to window (X11) - #1672

Draft
telychko wants to merge 1 commit into
TigerVNC:masterfrom
telychko:scale-remote-screen-to-window
Draft

Scale remote screen to window (X11)#1672
telychko wants to merge 1 commit into
TigerVNC:masterfrom
telychko:scale-remote-screen-to-window

Conversation

@telychko

Copy link
Copy Markdown

WIP: there is possible conflicts with server side resize
X11 implementation only

WIP: there is possible conflicts with server side resize
X11 implementation only
@CendioOssman

Copy link
Copy Markdown
Member

Glad to see someone having a look at this. :)

FYI, one big technical hurdle is how to deal with partial updates and non-integer scaling. I.e. when the input is fractional pixels. The brute force approach is to re-render everything on each update, but that will be a big performance hit.

@samhed samhed added the enhancement New feature or request label Sep 12, 2023
@samhed samhed linked an issue Sep 12, 2023 that may be closed by this pull request
@telychko

Copy link
Copy Markdown
Author

Glad to see someone having a look at this. :)

FYI, one big technical hurdle is how to deal with partial updates and non-integer scaling. I.e. when the input is fractional pixels. The brute force approach is to re-render everything on each update, but that will be a big performance hit.

Thank you. My tests show no problem with partial updating and fractional scaling. All that handled by underlying drawing system. At least it working good under GNU Linux/X11

The real struggle for me could be do the same for Windows and Mac

@spinningD20

spinningD20 commented Mar 12, 2024

Copy link
Copy Markdown

I'm so glad I check every year for a good linux vnc client with auto scaling. I just happened to search this repo (my fav vnc client on all desktop platforms) today for scaling and found this PR.

I just wanted to say thanks to @telychko for this! I pulled this down and am using this successfully... FINALLY I have auto-scaling vnc client in linux without realvnc! I have always loved tigervnc as a client and was baffled when this functionality wasn't in the linux side.

Not sure what is specifically holding this PR up from being merged into master, but at least from a decently up-to-date arch install using X11, this is working perfectly.

Thanks again @telychko ! Now it's just tigervnc on my system.

edited for slip between tightvnc and tigervnc on my brain :D

@telychko

Copy link
Copy Markdown
Author

@spinningD20 Be careful when server side resize is ON. At the moment, server side resize and client scaling are mutually exclusive.

To merge this PR, there should be added options for choosing between server side resize and client side scaling. Also, macos and windows platform should be supported.

Unfortunately, I have no time for that. I'm working full time, and I did this PR on weekends. I was inspired as the tigervnc is my favorite VNC client.

@spinningD20

Copy link
Copy Markdown

@telychko yep I did run into that, so I just turned off resizing in the config. Just thankful to be able to use this feature, regardless of if certain scenarios are taken care of automagically or not.

context, I have two different "server" side machines, one virtual that resizes, one that is 1440p of main user session with x11vnc, that I access with a 4k client machine in another building on the same network.

I'm familiar with moonlight/sunshine and was using that for the 1440p to scale up, but I use i3wm on all three machines, and there is no easy way to enter and exit, and not break the system key listening for switching workspaces through moonlight.

However, with tigervnc, I can full screen and pass system keys through, then when I need to switch, un-full screen the session, switch workspace on client, full screen the next one, continue.

Since I am doing dev work on both of these machines, I don't actually need the capabilities of moonlight - I just need scaling and a convenient/reliable way to toggle the listening/passthrough of system keys.

Thanks again! Maybe if that is all that's holding this feature up from going in, I can try to contribute. No promises but would love to give back to one of the many open source projects I rely so heavily upon!

@Neustradamus

Copy link
Copy Markdown

To follow this PR :)

@rudironsoni

Copy link
Copy Markdown
Contributor

Any tips on how I can contribute to make this feature available on macOS?
I can help, just need some guidance. (I can build everything, just need to know where to look at)

@telychko

Copy link
Copy Markdown
Author

Any tips on how I can contribute to make this feature available on macOS? I can help, just need some guidance. (I can build everything, just need to know where to look at)

I can make just wild guess, you need to know MacOS painting API. There is utilized low level painting API for each platform.

@jordyveys

Copy link
Copy Markdown

Hi, I'm struggeling to find the command line option to enable the auto-scaling.

@mjsir911

Copy link
Copy Markdown

0001-Scale-remote-screen-to-window-X11.patch

updated patch on master

@L-U-T-i

L-U-T-i commented Oct 22, 2025

Copy link
Copy Markdown

Commit c24b36e seem to be wrong (outdated?), it doesn't apply anymore.

0001-Scale-remote-screen-to-window-X11.patch

updated patch on master

doesn't seem to be completely OK either - it applies to the latest commit well, but is causing a build error later on:

[ 82%] Building CXX object vncviewer/CMakeFiles/vncviewer.dir/parameters.cxx.o
cd /builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/x86_64-redhat-linux-gnu/vncviewer && /usr/lib64/ccache/g++ -DBUILD_TIMESTAMP="\"2025-10-22 00:00\"" -DH264_LIBAV -DHAVE_CONFIG_H -DHAVE_GNUTLS -DHAVE_H264 -DHAVE_LIBSYSTEMD -DHAVE_NETTLE -DHAVE_PWQUALITY -DHAVE_SELINUX -DHAVE_XDAMAGE -DHAVE_XFIXES -DHAVE_XRANDR -DHAVE_XTEST -D_FORTIFY_SOURCE=2 -D__STDC_CONSTANT_MACROS -I/builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/x86_64-redhat-linux-gnu -I/builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/common -isystem /usr/include/pixman-1 -isystem /usr/include/ffmpeg -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fpic -std=c++11 -std=gnu++11 -Wall -Wextra -Wformat=2 -Wvla -Wzero-as-null-pointer-constant -Wsuggest-override -Wshadow -DNDEBUG -UNDEBUG -MD -MT vncviewer/CMakeFiles/vncviewer.dir/parameters.cxx.o -MF CMakeFiles/vncviewer.dir/parameters.cxx.o.d -o CMakeFiles/vncviewer.dir/parameters.cxx.o -c /builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/vncviewer/parameters.cxx
/builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/vncviewer/Viewport.cxx: In member function 'virtual void Viewport::sendPointerEvent(const core::Point&, uint16_t)':
/builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/vncviewer/Viewport.cxx:583:8: error: 'Point' is not a member of 'rfb'; did you mean 'core::Point'?
  583 |   rfb::Point scaled_pos;
      |        ^~~~~
In file included from /builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/common/rfb/Cursor.h:29,
                 from /builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/vncviewer/Viewport.cxx:34:
/builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/common/core/Rect.h:37:10: note: 'core::Point' declared here
   37 |   struct Point {
      |          ^~~~~
/builddir/build/BUILD/tigervnc-5a93f651def24f5b489517cf12f67df2516a4d7d/vncviewer/Viewport.cxx:584:3: error: 'scaled_pos' was not declared in this scope
  584 |   scaled_pos.x = pos.x * frameBuffer->scaleX();
      |   ^~~~~~~~~~
gmake[2]: *** [vncviewer/CMakeFiles/vncviewer.dir/build.make:317: vncviewer/CMakeFiles/vncviewer.dir/Viewport.cxx.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....

After changing rfb::Point scaled_pos; to core::Point scaled_pos; I got a successful build.

@aravindev

Copy link
Copy Markdown

core::Point

I also managed to successfully build the patch on master and it works great! ❤️
I had to change the CMAKELists file in vncviewer to fix some linking issues I got, Claude helped!

I had to install the following packages on Ubuntu 24.04:

sudo apt-get install libx11-dev libxext-dev libxdamage-dev libxfixes-dev libxrandr-dev libxtst-dev libjpeg-dev libpixman-1-dev libpam0g-dev libfltk1.3-dev libavcodec-dev libswscale-dev libwayland-dev libxkbcommon-dev libgnutls28-dev nettle-dev libsystemd-dev libpwquality-dev libpipewire-0.3-dev libglib2.0-dev uuid-dev gettext libpng-dev libxcursor-dev libxft-dev libfontconfig1-dev libexpat1-dev libfreetype6-dev libbz2-dev libxinerama-dev

In vncviewer/CMakeLists.txt line 59:

target_link_libraries(vncviewer ${FLTK_LIBRARIES} ${Intl_LIBRARIES} brotlidec brotlicommon p11-kit idn2)

With this, I managed to cmake it using:

mkdir build && cd build
cmake -G "Unix Makefiles"  -DBUILD_STATIC=0 -DCMAKE_INSTALL_PREFIX=/usr/local ..
make vncviewer

After this, I could install vncviewer using

cd vncviewer (inside build directory)
sudo make install

I did not bother to fix issues building the other packages, but probably have to do with missing libraries.
In the future, it would be nice to have dockerfiles which help reproduce the developers system requirements, I guess.

It would be great to see this being merged to master
This is a feasible workaround for an issue that I had reported here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scale remote screen to window

10 participants