You are not logged in.

#1 2021-03-20 18:21:22

Euda
Member
Registered: 2021-03-20
Posts: 4

Gnome: Issue with DPI scaling since i3wm install & config (X11)

Hello Arch-Community,

I have an issue with the user interface scaling under Gnome 3.38. I am using it only on the internal display of a Dell XPS 15 inch laptop with a 2160p 4K display. Nvidia dGPU with proprietary driver. Wayland is disabled, I'm on a standard xorg session.
Before installing the i3 window manager, the UI Scaling setting in gnome-settings worked as expected and applied to all the UI elements.
Today I installed i3. Since the standard configuration of i3 left all the fonts unscaled and tiny, I created a new file ".Xresources-i3wm" in my home directory with the following content:

Xft.dpi: 192
Xft.autohint: 0
Xft.lcdfilter:  lcddefault
Xft.hintstyle:  hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
Xcursor.size: 80

For i3wm to load this configuration on login, I modified the i3-config under ~/.config/i3/config, adding the following line:
exec_always --no-startup-id "xrdb -merge ~/.Xresources-i3wm"

That works and the window manager now launches with the correct *2 scaling on login.

After logging into a Gnome session again, SOME elements of the UI did not scale correctly anymore. Affected Shell elements are: The Gnome Top Bar font size, button font sizes, window title bar font sizes and app-icon font sizes in the Gnome App Launcher.
Also I've noticed that Java Swing GUI Applications with Gtk+ Look and Feel do not recognize that "Scale" under gnome-settings->Displays is already set to 200%. They now scale to double the size (400%) since "GDK_SCALE=2" is set as an environment variable.

I was able to workaround the issue by doubling the Fontsizes in the Gnome Shell Theme *.CSS file. That fixed the Top Bar and App Launcher fonts, but not the ones on windows's title bars. If I export $GDK_SCALE=1 and launch a Java App with Gtk+, I get the correct scaling but afterwards the $GDK_SCALE is automatically set to 2 again, for whatever reason.

Since this occured, I reset my dconf, switched Themes back and forth using gnome-tweaks, switched resolution back and forth, rebooted the system several times and played with "xrandr --dpi" setting. All of this didn't help, it looks like i3wm and me screwed up the DPI scaling within Gnome.
This is the output of "xrdb -query -all" for me, under Gnome right now:

Xft.dpi:    192
Xft.antialias:    1
Xft.hinting:    1
Xft.hintstyle:    hintslight
Xft.rgba:    rgb
Xcursor.size:    96
Xcursor.theme:    Adwaita


I hope somebody can help me out with this. Thanks in advance,

Euda

Last edited by Euda (2021-03-20 18:26:10)

Offline

#2 2021-03-22 03:55:07

ponyrider
Member
Registered: 2014-11-18
Posts: 112

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

Offline

#3 2021-03-22 07:33:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,544

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

If the X11 server didn't restart, the xrd loaded by i3 is still there and the bigger xft.dpi might interfere with whatever configuration you applied to gnome for the HiDPI situation.
Try to clean the rdb after exiting i3/before starting gnome.

Offline

#4 2021-03-25 18:54:53

Euda
Member
Registered: 2021-03-20
Posts: 4

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

Thanks for the replies!

As mentioned in the first post, I have already reset/reloaded any gnome-settings by resetting the dconf. Rebooting the system and directly starting a Gnome session leads to the same result of some of the Gnome UI elements not being drawn in the correct size. Here are two screenshots of the issue, note both the tiny top bar on the first image, plus the vignette effect of the system message popup, which looks like it's not being drawn in the correct size.

Right now, after a fresh reboot right into gnome and without an .Xresources file inside my home directory, 'xrdb -query -all' looks as follows:
Xft.dpi:    192
Xft.autohint:    0
Xft.lcdfilter:    lcddefault
Xft.hintstyle:    hintslight
Xft.hinting:    1
Xft.antialias:    1
Xft.rgba:    rgb
Xcursor.size:    96
Xcursor.theme:    Adwaita

Font scaling is set to 1.0. User Interface setting inside gnome-settings>>displays app is set to 200%. Switching resolutions both of these settings or the resolution back and forth do not help this.

https://i.imgur.com/P1WtDBV.jpg

https://i.imgur.com/GBqXN1C.jpg

Another output that might help to find a hint on what is the reason for this - 'printenv | grep GDK' shows:
GDK_DPI_SCALE=0.5
GDK_SCALE=2

If I change these env variables via 'export', it doesn't affect GTK3 applications that I run in the current session. Unfortunately the settings doesn't persist at my custom value and the standard values (0.5 & 2) are automatically loaded on a re-login.

Greets,
Euda

Last edited by Euda (2021-03-25 20:08:46)

Offline

#5 2021-03-25 22:00:42

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,544

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

Please post the output of "xrandr -q" and "xdpyinfo | grep resolution"

without an .Xresources file inside my home directory, 'xrdb -query -all' looks

What sets those values? The don't show up there randomly. It will be some session script. Does it run before or after gnome-session starts?

Unfortunately the settings doesn't persist at my custom value and the standard values (0.5 & 2) are automatically loaded on a re-login.

Where and how are those "standards"? Where do you export them? How precisely do you start gnome?

Last edited by seth (2021-03-25 22:01:02)

Offline

#6 2021-03-27 07:31:41

Euda
Member
Registered: 2021-03-20
Posts: 4

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

seth wrote:

Please post the output of "xrandr -q" and "xdpyinfo | grep resolution"

without an .Xresources file inside my home directory, 'xrdb -query -all' looks

What sets those values? The don't show up there randomly. It will be some session script. Does it run before or after gnome-session starts?

Unfortunately the settings doesn't persist at my custom value and the standard values (0.5 & 2) are automatically loaded on a re-login.

Where and how are those "standards"? Where do you export them? How precisely do you start gnome?

"xrandr -q" output:

Screen 0: minimum 320 x 200, current 3840 x 2160, maximum 16384 x 16384
eDP-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
   3840x2160     60.00*+  59.98    59.97  
   3200x1800     59.96    59.94  
   2880x1620     59.96    59.97  
   2560x1600     59.99    59.97  
   2560x1440     59.99    59.99    59.96    59.95  
   2048x1536     60.00  
   1920x1440     60.00  
   1856x1392     60.01  
   1792x1344     60.01  
   2048x1152     59.99    59.98    59.90    59.91  
   1920x1200     59.88    59.95  
   1920x1080     60.01    59.97    59.96    59.93  
   1600x1200     60.00  
   1680x1050     59.95    59.88  
   1400x1050     59.98  
   1600x900      59.99    59.94    59.95    59.82  
   1280x1024     60.02  
   1400x900      59.96    59.88  
   1280x960      60.00  
   1440x810      60.00    59.97  
   1368x768      59.88    59.85  
   1280x800      59.99    59.97    59.81    59.91  
   1280x720      60.00    59.99    59.86    59.74  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   1024x576      59.95    59.96    59.90    59.82  
   960x600       59.93    60.00  
   960x540       59.96    59.99    59.63    59.82  
   800x600       60.00    60.32    56.25  
   840x525       60.01    59.88  
   864x486       59.92    59.57  
   700x525       59.98  
   800x450       59.95    59.82  
   640x512       60.02  
   700x450       59.96    59.88  
   640x480       60.00    59.94  
   720x405       59.51    58.99  
   684x384       59.88    59.85  
   640x400       59.88    59.98  
   640x360       59.86    59.83    59.84    59.32  
   512x384       60.00  
   512x288       60.00    59.92  
   480x270       59.63    59.82  
   400x300       60.32    56.34  
   432x243       59.92    59.57  
   320x240       60.05  
   360x202       59.51    59.13  
   320x180       59.84    59.32  
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)

"xdpyinfo | grep resolution" output:

  resolution:    96x96 dots per inch

I launch Gnome via GDM. The login manager lets me choose between a Gnome or i3 session (graphically) before login. My /etc/X11/xinit/xinitrc.d contains two files:

[pascal@9570-arch xinitrc.d]$ cat 40-libcanberra-gtk-module.sh 
#!/bin/sh

case "${DESKTOP_SESSION-}" in
  gnome*) # Done by gnome-settings-daemon
  ;;
  *)
    # Extra check in case DESKTOP_SESSION is not set correctly
    if [ -z "${GNOME_DESKTOP_SESSION_ID-}" ]; then
      GTK_MODULES="${GTK_MODULES:+$GTK_MODULES:}canberra-gtk-module"
      export GTK_MODULES
    fi
  ;;
esac
[pascal@9570-arch xinitrc.d]$ cat 50-systemd-user.sh 
#!/bin/sh

systemctl --user import-environment DISPLAY XAUTHORITY

if command -v dbus-update-activation-environment >/dev/null 2>&1; then
    dbus-update-activation-environment DISPLAY XAUTHORITY
fi

Offline

#7 2021-03-27 07:49:25

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,544

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

The physical resolution is ~283 DPI, the logical is 96 DPI …
You probably want to "xrandr --dpi 283" to accomodate for that before everything else and you want to do that before you start i3.
https://wiki.archlinux.org/index.php/Xprofile suggests that GDM will read it (but idk for sure)

"GDK_SCALE=2" might be too big for that if it's applied on top of the DPI.

I guess your gnome session just writes that xrdb by default.

Offline

#8 2021-03-27 10:18:19

Euda
Member
Registered: 2021-03-20
Posts: 4

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

GDK_SCALE, GDK_DPI_SCALE and QT_AUTO_SCREEN_SCALE_FACTOR being set on login seem to be the root of the issue.
I just found a ~/.profile which had the following contents:

export GDK_SCALE=2
export GDK_DPI_SCALE=0.5
export QT_AUTO_SCREEN_SCALE_FACTOR=2

So I changed the values all to 1. Now the next issue, seen in the following screenshot:
gaWruSs.png

The gnome-shell.css files are all at their default values again. Now I'm using standard Adwaita theme as shipped with Gnome.
Also I've checked the dconf again for any non-default settings related to interface and scaling. All the settings are default now. Font scaling via gnome-tweaks is set to 1.00 too.

The Terminator application has the correct scaling, whereas for example Nautilus and gnome-settings do scale too small (seem to ignore the 200% scale set in gnome-settings). So my suspicion is that GDK_SCALE, GDK_DPI_SCALE, etc. should not be set at all on login for Gnome to scale correctly. To do that, I tried to delete the .profile file and "unset GDK_SCALE"/"unset GDK_DPI_SCALE"/"unset QT_AUTO_SCREEN_SCALE_FACTOR". When I did a re-login thereafter the variables were again set to their previous values and popped up in the "printenv" list. So as a workaround I created a ~/.profile again, now with "unset GDK_SCALE", etc.
That didn't work either. If I put for example "export GDK_SCALE=2" inside the .profile again, the scaling changes to be too large in Nautilus. And when I rename the .profile and unset such variable, nothing changes and the 200% scale of Nautilus persists. So there seems to be something else reading the values in .profile and copying them somewhere.

What resource withing gnome/gdm/X11 is responsible for setting env variables? How do I find out?

EDIT: A quick test proved that GDK_SCALE set to anything is indeed the problem. I did "unset GDK_SCALE" and killed nautilus using htop, all in a running session. Launching nautilus again resulted in the result that I want. So what I need to figure out now is just where GDK_SCALE is set during the login and then remove the corresponding line from the script file. @seth: Do you have a hint where could I be looking for that? Thanks for your help.

Last edited by Euda (2021-03-27 10:46:21)

Offline

#9 2021-03-27 12:15:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,544

Re: Gnome: Issue with DPI scaling since i3wm install & config (X11)

Please replace the oversized image w/ a thumbnail/link - the board has a 200x200 max rule.
I assume the gnome-session binary exports GDK_SCALE based on the gnome-settings value which you probably want to reduce to 100% since you've corrected the DPI?

(I don't use gnome at all, so I'm just guessing here. Also ensure to consult the link ponyrider posted in #2 for general HiDPI information)

Offline

Board footer

Powered by FluxBB