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

High DPI support on Linux #615

Closed
zcbenz opened this Issue Aug 28, 2014 · 18 comments

Comments

Projects
None yet
8 participants
@zcbenz
Copy link
Member

zcbenz commented Aug 28, 2014

Chromium already had some basic support for high DPI on Linux, we should enable it in atom-shell.

@zcbenz

This comment has been minimized.

Copy link
Member Author

zcbenz commented Sep 8, 2014

Steps to implement this:

  1. Enable enable_hidpi flag in libchromiumcontent
  2. Ship and load high DPI resources under Linux
  3. Read system's high DPI settings and set atom-shell's DPI by --force-device-scale-factor=2

Problems:

  1. Menus are completely unusable under high DPI
  2. Different DE seems to have different ways of setting high DPI
@geminorum

This comment has been minimized.

Copy link

geminorum commented Oct 1, 2014

In Windows, having high DPI for lower quality and bigger font and icon size in general. and since Chrome 36 upgrade, I'm using chrome with --force-device-scale-factor=1 to reset pixels to the actual size of a pixel in the browser. but how can I set this for atom-shell's?

@Nek-

This comment has been minimized.

Copy link

Nek- commented Mar 12, 2015

capture du 2015-03-12 18 10 52
Looks like it doesnt work at all...

Dell XPS 2014 / Ubuntu 14.04 (well configured for hidpi of course)

@madd512

This comment has been minimized.

Copy link

madd512 commented Mar 22, 2015

Same as above. This fixes it, but I wish it didn't:

body {
  zoom: 2;
}
atom-text-editor {
  zoom: 0.5;
  font-size: 200%;
}
@niedzielski

This comment has been minimized.

Copy link
Contributor

niedzielski commented Apr 6, 2015

I'm not sure what the recommended configuration is but @devtristan's snippet seems to work well.

@madd512

This comment has been minimized.

Copy link

madd512 commented Apr 6, 2015

Updated to handle overlays properly (jshint etc):

body {
  zoom: 2;
}
atom-text-editor {
  zoom: 0.5;
  font-size: 200%;
}
atom-overlay>* {
  zoom: 2;
}
@benley

This comment has been minimized.

Copy link

benley commented Apr 6, 2015

For what it's worth, if you do something like gsettings set org.gnome.desktop.interface scaling-factor 2 it does have an effect on Atom. Unfortunately it appears that scaling-factor key is an int32 value in gsettings, so you can only get increments of 100%, and if your environment already has Xft.dpi set to an appropriate value for your display (via .Xresources or .fonts.conf or perhaps automatically by the X server), then some of Atom's UI elements will end up scaled twice. The menus in particular are affected by this, and end up being gigantic with their contents overrunning the edges of the panels.

I think Chromium is finally getting hidpi support straightened out on Linux as of version 43, so it may be worth taking another look at their implementation at some point.

@madd512

This comment has been minimized.

Copy link

madd512 commented Apr 6, 2015

Interesting, my distribution handles DPI somewhere else. Setting that just makes atom interface components inconsistently sized (0.5x-8x). I've been waiting for chromium HiDPI support for years, I can wait a bit longer.

@niedzielski

This comment has been minimized.

Copy link
Contributor

niedzielski commented Apr 9, 2015

@benley neat. I see the same behavior on Xubuntu you described. I think I'll stick with @devtristan's solution for the time being. Thanks!

@cart

This comment has been minimized.

Copy link

cart commented Apr 10, 2015

Zooming the interface is the best approach I found (https://discuss.atom.io/t/how-to-set-the-font-for-the-settings-ui-and-the-command-browser/13498/4). I made this addon and it has been working pretty well for me https://atom.io/packages/hidpi.

@madd512

This comment has been minimized.

Copy link

madd512 commented Apr 10, 2015

👍

Nice addon.

If you don't need automatic switching, you can open the command palette and type "init script" then add this line to the bottom:

require('web-frame').setZoomFactor(2)

This works better than the zoom: 2 trick. Needs an atom restart to take effect, though.

@Mingling94

This comment has been minimized.

Copy link
Contributor

Mingling94 commented Jun 28, 2015

@zcbenz Sorry if this is rather ignorant, but I've been trying to find out how to perform the below steps to no avail:

Enable enable_hidpi flag in libchromiumcontent

Is this

  1. programmatically done (if so how)?
  2. Through adding a flag to the command (usually start) in the package.json that for most is electron ./ or electron app/ for my case?
  3. or through a chrome command line switch inserted programmatically

Ship and load high DPI resources under Linux

I'm having trouble understanding what this means.

Read system's high DPI settings and set atom-shell's DPI by --force-device-scale-factor=2

Same 3 options as the first quoted line.

@niedzielski

This comment has been minimized.

Copy link
Contributor

niedzielski commented Jun 28, 2015

FWIW, I've since switched to using the HiDPI package and it works well for me.

@Mingling94

This comment has been minimized.

Copy link
Contributor

Mingling94 commented Jun 28, 2015

@niedzielski Word, I'll give it a try. Though I'm confused, is it for the atom text editor or to be used in electron apps in general? I'm dealing with the latter

@niedzielski

This comment has been minimized.

Copy link
Contributor

niedzielski commented Jun 29, 2015

@Mingling94, sorry! I was thinking Atom. I do not know if the HiDPI package supports Electron apps but I would guess not.

@cart

This comment has been minimized.

Copy link

cart commented Jun 29, 2015

Electron does not support Atom packages. But im pretty sure you can still use require('web-frame').setZoomFactor(), which is what atom-hidpi uses. I haven't used electron so I do not know where you would put that code.

@Mingling94

This comment has been minimized.

Copy link
Contributor

Mingling94 commented Jun 29, 2015

@mcanders Right, so for an app that would be distributed to people, how would one do this automagically? I'm thinking that my laptop has a 3200x1800 and that I could do something like:

var electronScreen = require('screen');
var webFrame = require('web-frame');
var size = electronScreen.getPrimaryDisplay().workAreaSize;

function log2(number) {
    return Math.log(number) / Math.log(2);
}

webFrame.setZoomFactor(Math.floor(log2((size.width*size.height)/(800*600))));

x = zoom factor = floor( log_base_2( size / (800_600) ) )... or basically the lowest log_base_2 of how many 800_600 screens fit in the actual resolution.
So the app would be x1 on a 800x600 screen, x2 on a 1600x1200 screen... and for my high dpi screen size of 3200x1800, it would be x3? Yeah that works.

@cart

This comment has been minimized.

Copy link

cart commented Jun 29, 2015

That seems right. But if you are distributing this app, I would provide some configuration options. Resolution isn't a great indicator of DPI and there is no surefire way to get the correct dpi value on all platforms. But that seems like good default behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.