Skip to content

High DPI support on Linux #615

Closed

Description

@zcbenz

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

Activity

  1. zcbenz commented on Sep 8, 2014

    @zcbenz
    ContributorAuthor

    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
  2. geminorum commented on Oct 1, 2014

    @geminorum

    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?

  3. Nek- commented on Mar 12, 2015

    @Nek-

    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)

  4. summer4096 commented on Mar 22, 2015

    @summer4096

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

    body {
      zoom: 2;
    }
    atom-text-editor {
      zoom: 0.5;
      font-size: 200%;
    }
  5. niedzielski commented on Apr 6, 2015

    @niedzielski
    Contributor

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

  6. summer4096 commented on Apr 6, 2015

    @summer4096

    Updated to handle overlays properly (jshint etc):

    body {
      zoom: 2;
    }
    atom-text-editor {
      zoom: 0.5;
      font-size: 200%;
    }
    atom-overlay>* {
      zoom: 2;
    }
  7. benley commented on Apr 6, 2015

    @benley

    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.

  8. summer4096 commented on Apr 6, 2015

    @summer4096

    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.

  9. niedzielski commented on Apr 9, 2015

    @niedzielski
    Contributor

    @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!

  10. summer4096 commented on Apr 10, 2015

    @summer4096

    👍

    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.

  11. Mingling94 commented on Jun 28, 2015

    @Mingling94
    Contributor

    @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.

  12. niedzielski commented on Jun 28, 2015

    @niedzielski
    Contributor

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

  13. Mingling94 commented on Jun 28, 2015

    @Mingling94
    Contributor

    @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

  14. niedzielski commented on Jun 29, 2015

    @niedzielski
    Contributor

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

  15. cart commented on Jun 29, 2015

    @cart

    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.

  16. Mingling94 commented on Jun 29, 2015

    @Mingling94
    Contributor

    @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.

  17. cart commented on Jun 29, 2015

    @cart

    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.

  18. Zeioth commented on Sep 23, 2021

    @Zeioth

    Does this work? I don't seem to be able to scale stremio or franz (the two electron apps I use) with this.

  19. choucavalier commented on Feb 20, 2022

    @choucavalier

    i don't understand why this issue is closed as HiDPI support clearly does not work yet 😕

  20. Nek- commented on Feb 20, 2022

    @Nek-

    @tgy your issue is probably related to the implementation of the software you're using, because I can confirm that Visual Studio Code (which uses electron) is clearly supporting high dpi.

  21. choucavalier commented on Feb 20, 2022

    @choucavalier

    @Nek- thx! was actually trying to run signal-desktop under Wayland. HiDPI does not work well with Wayland but works with Xorg...

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions