Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux/HiDPI scaling when gnome set to autodetect #1150

Closed
benwaffle opened this issue Feb 18, 2015 · 4 comments · Fixed by #2980
Closed

Linux/HiDPI scaling when gnome set to autodetect #1150

benwaffle opened this issue Feb 18, 2015 · 4 comments · Fixed by #2980

Comments

@benwaffle
Copy link

When org.gnome.desktop.interface scaling-factor is 0, GNOME automatically detects that I have a hidpi screen but atom does not. It's a minor issue since i can easily change scaling-factor to 2

@benwaffle benwaffle changed the title Linux HiDPI when gnome set to autodetect Linux/HiDPI scaling when gnome set to autodetect Feb 18, 2015
@mtwebster
Copy link

Applications really should not rely on this setting for detecting the current scale factor. This is a user preference setting for gnome-shell. Other desktops can and will use a different schema altogether to store this preference. The correct place to query the current scale factor is from the X server itself, via some toolkit's api, or using the X11 api directly to read the server xsettings. This will also prevent you from ending up in normal-dpi mode when 'autodetect' is enabled for that gsettings key (0).

@kpeeters
Copy link

kpeeters commented Feb 7, 2017

Slightly off-topic but I can't find the info anywhere else: can anyone comment on how to "query the current scale factor from the X server itself, via some toolkit's api, or using the X11 api directly to read the server xsettings", as mentioned by mtwebster, preferably using gtk?

@mtwebster
Copy link

This probably works in most cases: https://developer.gnome.org/gdk3/stable/GdkScreen.html#gdk-screen-get-monitor-scale-factor

In python you could do something like:

from gi.repository import Gdk
factor = Gdk.Screen.get_default().get_monitor_scale_factor(0)

Note the deprecation warning - in Gtk 3.22 it's highly recommended to go through the GdkMonitor api instead... old monitor reporting from GdkScreen/GdkDisplay is unreliable (and more or less unmaintained - this is what deprecated means to them.)

Something else to note, the 0 isn't technically appropriate - you should be sure you're using a valid monitor index, but under X server, all monitors will have the same scale factor, and I'm pretty certain there's always a monitor 0.

@kpeeters
Copy link

kpeeters commented Feb 7, 2017

That works, but it turns out I actually wanted not just the scale factor, but also the (independent) text scale factor. Any idea how to get the equivalent of org.gnome.desktop.interface.text-scaling-factor ?

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

Successfully merging a pull request may close this issue.

4 participants