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.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
screen.scaleFactor always returns 1 for 125% DPI #6571
I have a hidpi screen on my laptop and a normal main monitor that has some scaling applied through windows' display properties. In both cases the following code returns 1 even though I would expect something larger:
getPrimaryDisplay() probably didn't return the display you expected, it returns the display that the system considers primary, which may not be your laptop's screen. You should use APIs like getDisplayNearestPoint() to get the scale factor for current display.
I've tried to use the APIs to find the current screen and it still returns a scaleFactor of 1 despite the OS being set to scale to 125%. Also screen.getAllDisplays() returns just a single display regardless of whether I'm using my laptop screen or my external monitor (my laptop screen is disabled in that case so that is to be expected).
Is it possible that scaleFactor only supports integer values?
Just a heads up that I believe this is going to have a large impact
Because folks at 125% will finally get properly scaled content, everything will appear to be much larger for them. If those people are upset and don't like this, it can be worked around by passing two additional flags to the base::CommandLine class (you should be able to append via the command line): --high-dpi-support=1 --force-device-scale-factor=1
Reacted by zxc23, Tundra Shark, swiftbrad and nikolawan
Reacted by Tundra Shark, Augus, Damon Chen, Vishwas Shashidhar, VICTOR RAPHAEL BRAGA DE SALES MASCARENHAS, Clément Guillemain, Brett Connolly, Riccardo, GR, Orçun Tuna and 11 more
Reacted by Brian Clifton, haoyang wu, Gru, Tundra Shark, José Luís Silva, Kshamenk Nehuén Gil, Brett Connolly, Jacob Johansen, Matt McKegg, Ravi Rajpurohit and 2 more
Reacted by Xavier Le Tohic, Tundra Shark, Anton Nesterov, Brett Connolly, Ravi Rajpurohit and Umang G. Patel
Thanks @zxc23 for posting that solution. My application started scaling after I've npm installed electron (with global install there was no scaling). After adding those lines, the body of the application looks correct, but the top menu bar (on Windows) is scaled down. Any solution for this?
@HaulinOats There are hundreds of potential chromium CLI switches. We can't (and won't) document all of them especially as we can't guarantee there continued existence
Just a heads up that I believe this is going to have a large impact
Because folks at 125% will finally get properly scaled content, everything will appear to be much larger for them. If those people are upset and don't like this, it can be worked around by passing two additional flags to the base::CommandLine class (you should be able to append via the command line): --high-dpi-support=1 --force-device-scale-factor=1
Microsoft edge browser menu tab font seems very small . How it works for ?
Activity
zcbenz commentedon Jul 25, 2016
getPrimaryDisplay()probably didn't return the display you expected, it returns the display that the system considers primary, which may not be your laptop's screen. You should use APIs likegetDisplayNearestPoint()to get the scale factor for current display.Mossop commentedon Jul 25, 2016
I've tried to use the APIs to find the current screen and it still returns a scaleFactor of 1 despite the OS being set to scale to 125%. Also
screen.getAllDisplays()returns just a single display regardless of whether I'm using my laptop screen or my external monitor (my laptop screen is disabled in that case so that is to be expected).Is it possible that scaleFactor only supports integer values?
zcbenz commentedon Jul 26, 2016
Thanks for the information, after testing I found that
screen.scaleFactorreturns 1 when DPI is 125%, however DPI 150% can work.[-]screen.scaleFactor always returns 1[/-][+]screen.scaleFactor always returns 1 for 125% DPI[/+]virifi commentedon Jul 26, 2016
Chromium has this issue from two years ago, but it has been fixed a few days ago.
See https://bugs.chromium.org/p/chromium/issues/detail?id=410696
bsclifton commentedon Jan 20, 2017
Just a heads up that I believe this is going to have a large impact
Because folks at 125% will finally get properly scaled content, everything will appear to be much larger for them. If those people are upset and don't like this, it can be worked around by passing two additional flags to the base::CommandLine class (you should be able to append via the command line):
--high-dpi-support=1 --force-device-scale-factor=1zxc23 commentedon Sep 4, 2017
@bsclifton I've been looking everywhere for this information, and I finally found it here. Thank you very much for that.
I got my electron app to ignore the desktop display scaling with this in the main process:
sirgru commentedon Oct 20, 2017
Thanks @zxc23 for posting that solution. My application started scaling after I've npm installed electron (with global install there was no scaling). After adding those lines, the body of the application looks correct, but the top menu bar (on Windows) is scaled down. Any solution for this?
HaulinOats commentedon Jul 23, 2019
Should these flags be added to the official documentation as valid command line switches, since they work?
MarshallOfSound commentedon Jul 24, 2019
@HaulinOats There are hundreds of potential chromium CLI switches. We can't (and won't) document all of them especially as we can't guarantee there continued existence
HaulinOats commentedon Jul 24, 2019
Ah, I follow. Wasn't aware it was that complicated. I'm still learning. Appreciate the response.
gsbnlda commentedon Jun 25, 2023
How it will work for Microsoft edge browser? edge menu tab font seems very small.
gsbnlda commentedon Jun 25, 2023
Microsoft edge browser menu tab font seems very small . How it works for ?