morpheusthewhite / nordpy

A gui application to connect automatically to the recommended NordVPN server
GNU General Public License v3.0
105 stars 16 forks source link

Xorg screen dpi changes font size #40

Closed morpheusthewhite closed 4 years ago

morpheusthewhite commented 4 years ago

Font size under Wayland is the same with both single/multiple screens. (I was wrong earlier, the dpi is different between the two screens.)

Under Xorg, single screen: xorg_single screen

Xorg, two screens: xorg_two screens

Obviously the centering of the window (which uses self.winfo_screenwidth()) is a separate issue

Originally posted by @emulti in https://github.com/morpheusthewhite/nordpy/issues/38#issuecomment-612007105

morpheusthewhite commented 4 years ago

Is this the only application which causes this problem? I think it is a common problem among HiDPI setups

emulti commented 4 years ago

Yes, I have only seen this with nordpy.

Partial xrandr output:

Under Gnome/Xorg: Screen 0: minimum 8 x 8, current 3286 x 1200, maximum 32767 x 32767 LVDS1 connected primary 1366x768+0+432 (normal left inverted right x axis y axis) 295mm x 166mm HDMI1 connected 1920x1200+1366+0 (normal left inverted right x axis y axis) 520mm x 320mm

XFCE Screen 0: minimum 8 x 8, current 3286 x 1080, maximum 32767 x 32767 LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 295mm x 166mm HDMI1 connected 1920x1080+1366+0 (normal left inverted right x axis y axis) 520mm x 320mm

Gnome/Xorg: $ xdpyinfo |grep reso resolution: 285x185 dots per inch

Edit to previous comment: now xfce is showing the same overall resolution, and the 'tiny text' issue returned. XFCE $ xdpyinfo |grep reso resolution: 285x185 dots per inch

But if LVDS1 is configured as 'primary display' in Xrandr then it reports 96x96 DPI.

So it seems nordpy is being fooled by Xorg into thinking it is a HiDPI display.

morpheusthewhite commented 4 years ago

Just to be sure that this problem is linked only with the tkinter library, can you execute the following code (with python3) and look if the label size is small as in nordpy?

from tkinter import *
from tkinter.ttk import *

ro = Tk()
w = Label(ro, text="Hello world")
w.pack()
ro.mainloop()
emulti commented 4 years ago

With two monitors connected, Gnome/Wayland or Sway works fine. Gnome/Xorg, Xfce, and other X-based WM shows tiny text. xdpyinfo shows the screen as 96x96 dpi when running Wayland, but 285x 185 on Xorg. Can you work round it? This program is such an improvement on the 'official' nordvpn cli app! To prevent leaking DNS info however, it's important to not use systemd-resolved to manage /etc/resolv.conf. With the Nord official app, it's the other way round.

morpheusthewhite commented 4 years ago

With two monitors connected, Gnome/Wayland or Sway works fine. Gnome/Xorg, Xfce, and other X-based WM shows tiny text. xdpyinfo shows the screen as 96x96 dpi when running Wayland, but 285x 185 on Xorg. Can you work round it?

Unfortunately since I am not able reproduce your setup I cannot easily solve it, but since we know that it is related to tkinter + Xorg you can google it and find solutions from others. If you find a way to solve it, feel free to put into this issue how you did it

This program is such an improvement on the 'official' nordvpn cli app! To prevent leaking DNS info however, it's important to not use systemd-resolved to manage /etc/resolv.conf. With the Nord official app, it's the other way round.

So can you confirm me that everything works fine with connection / disconnection (many have experienced missing connection after the VPN starts, see https://github.com/morpheusthewhite/nordpy/issues/26)?

morpheusthewhite commented 4 years ago

Since we know that this problem is not related to nordpy I'll close this issue

emulti commented 4 years ago

Issue solved. I decided it was an issue with Xorg and checked the configuration. Specifically, it seems to be an issue with DRI2. I had disabled DRI3 some years ago due to problems with the Intel embedded graphics on my laptop, by adding a file /etc/X11/xorg.conf.d/20-intel.conf On removing that file and accepting the driver defaults/DRI3, xdpyinfo reports correct resolution again (96dpi) and your program works great!