Per-application window scaling in Xorg for high dpi display

31

13

I am running Gnome Shell with a 4k monitor and there are a few applications that I use that don't scale at all with the high resolution.

Here is an example of LMMS, an application that hasn't yet been ported Qt 5, so it doesn't have high dpi scaling capabilities:

Screenshot
(Click images to enlarge)

Is there any way to scale a specific X window without changing the display resolution?

My current solution is to half the dimensions of my display resolution, but this degrades the resolution of every other application that supports proper dpi scaling:

Screenshot

MetaDark

Posted 2015-08-04T21:22:19.090

Reputation: 773

Answers

21

I finally managed to find a solution that scales old applications without any noticeable visual or performance degradation.

Thanks to kaueraal, you can now scale old applications using run_scaled. You can obtain the script from either his GitHub page or through AUR run_scaled-git if you are running Arch Linux.

Here is an example of two applications running side by side:

  • Firefox with HiDPI support on the left
  • LMMS running with run_scaled on the right

enter image description here

I discovered this script through the Arch Linux Wiki.

MetaDark

Posted 2015-08-04T21:22:19.090

Reputation: 773

On Ubuntu you need to install xpra

– Pablo A – 2019-05-21T23:54:51.450

This program is consuming CPU really heavily. – L29Ah – 2019-05-29T20:38:01.047

This script is somewhat poorly documented, but many errors seems to caused by simply missing dependencies. On ubuntu you might need at least (not exhaustively) these: apt install xvfb python2.7-cups python2.7-gtkglext1 python-opencv xpra python-pyinotify python2.7-dev; pip2 install setuptools; pip2 install PyOpenGL_accelerate. It also has opengl and non-opengl mode, one of these might work even in case the other doesn't. – Cray – 2020-01-01T20:55:05.733

6

Without seeing the exact problem that you are running into I would suggest using

GDK_SCALE=x

or

GDK_DPI_SCALE=x

Before starting each application. You will likely have to manually change .desktop files or run from your shell prefixing the commands with GDK_SCALE=x

GDK_SCALE only allow interger values however GDK_DPI_SCALE=x allow for decimal values like i.e.GDK_DPI_SCALE=0.66

For other SDK based applications there are likely similar settings for respective kits. However since your problem is with gnome desktop I will provide this solution.

I haven't tried with a 4k monitor, but running GDK_DPI_SCALE=1.66 gnome-calculator will demo the solution.

Source: https://developer.gnome.org/gtk3/stable/gtk-x11.html

Maeve Kennedy

Posted 2015-08-04T21:22:19.090

Reputation: 139

1Thanks for the answer, but this does not work for the Xlib applications. – Ho1 – 2015-08-16T08:40:44.083

3Thank you for the answer, but this isn't really what I am looking for. I only encounter scaling issues with applications that don't use GTK3. I was hoping to find a solution that could be applied to any X application. – MetaDark – 2015-08-17T04:26:31.717

https://wiki.archlinux.org/index.php/HiDPI has info that might be helpful for both GTK and non-GTK apps. I'd make an answer for it, but I don't want to transcribe the info over to an answer post. – Emmaly Wilson – 2017-01-02T03:55:51.067

2

I have an application that spawns many windows, and I cannot at the moment use xpra as is required by the accepted run_scaled solution. I also can't tolerate gnome-tweak-tool's 2x scaling. Too huge. Need 1.5x.

I have discovered that the tigerVNC java client supports client-side display scaling of 150%.

So I start a vncserver with 2/3rds size and a minimal windows manager:

vncserver -geometry 2520x1380 -xstartup ~/.vnc/xstartup-mwm

I then connect with TigerVNC's v1.7 java client (1.8.0 consistently crashes for me):

java -jar VncViewer-1.7.0.jar -ScalingFactor=150

Other than the commandline, you can hit F8 to get the VNC Viewer Options. Screen->Scaling Factor->150%. This scales the resolution from 2/3rds of 4k to 4k.

enter image description here

Archaic MWM in VNC with 150% scaling on the left. Fancy Gnome desktop (native) on the right, no scaling. You'll notice the tiny icons. Gnome is otherwise adjusted for 4k with 1.5x Font Scaling in gnome-tweak-tool, but the icons don't scale. This is just an example application -- the icons and scaling in the application that is pushing me this way are far worse.

Unfortunately this is an entire 1.5x scaled desktop with a separate window manager. It creates a nice walled-off area for my multiwindow app, but it's annoying to have a second window manager. Nonetheless VNC is something I'm familiar with from longtime use, and this does kick over to the laptop pretty easily, so perhaps this is usable.

stevesliva

Posted 2015-08-04T21:22:19.090

Reputation: 123

1

Vncdesk gives you a solution based on a local VNC client-server (see here)

It is not a complete solution for me because it gives some problems if the app need a window manager.

Sergio Llorente

Posted 2015-08-04T21:22:19.090

Reputation: 11