Lightroom: LrSystemInfo.displayInfo() returns wrong units of pixels on Windows

  • 1
  • Problem
  • Updated 3 weeks ago
  • (Edited)
When the user has set a Windows display scaling factor, LrSystemInfo.displayInfo() and .appWindowSize() incorrectly return width and height in units of physical pixels, rather than scaled pixels.  This makes it impossible for plugins to properly size large dialogs and controls.


Both Mac and Windows allow the user to set a scaling factor for a display, e.g. a scaling factor of 200% doubles the size of the user-interface elements.  On Mac, you can only set a scaling factor for Retina (high-resolution) displays via Settings > Displays. On Windows, you can set a global scaling factor via Settings > Display or a LR-specific scaling factor via Preferences > Interface > Font Size.

A number of LrView controls have width and height properties that are specified in units of scaled pixels. A "scaled pixel" is the number of physical pixels divided by the scaling factor.  

On Mac, LrSystemInfo.displayInfo() and .appWindowSize() return screen and window sizes in units of scaled pixels. This enables plugins to make a dialog as large as possible while still fitting on the screen; for example, the plugin can set the width and height of a scrolled_view() (in units of scaled pixels) to be somewhat less than the screen size (in units of scaled pixels).

But on Windows, LrSystemInfo.displayInfo() and .appWindowSize() return sizes in units of physical pixels, and there is no easy way for a plugin to get the current scaling factor to translate them to scaled pixels. This makes it very difficult for a plugin to make a large window that is guaranteed to fit on the screen.

The script below tries to create a scrolled_view() whose height is 1/2 of the screen height. On Mac, that works properly regardless of the current scaling factor, since both LrView and LrSystemInfo use the same units, scaled pixels. But on Windows, when the display scale factor is 200%, then the scrolled_view() is twice as large as it should be, overflowing the screen, because LrView uses scaled pixels and LrSystemInfo uses physical pixels.

local LrDialogs = import "LrDialogs"
local LrSystemInfo = import "LrSystemInfo"
local LrView = import "LrView"

local f = LrView.osFactory()
local display
for _, info in ipairs (LrSystemInfo.displayInfo ()) do 
    if info.hasAppMain then display = info end
local app = {LrSystemInfo.appWindowSize ()}
local width, height = 250, display.height / 2
local result = LrDialogs.presentModalDialog {title = "Scaling Bug", 
    contents = f:scrolled_view {width = width, height = height,
        f:static_text {title = 
            string.format ("Screen: %d x %d\nLightroom window: %d x %d\n" ..
                "Dialog window should be: %d x %d", 
                display.width, display.height, app [1], app [2], 
                width, height)}}}
Photo of John R. Ellis

John R. Ellis, Champion

  • 3236 Posts
  • 802 Reply Likes

Posted 3 weeks ago

  • 1
Photo of John R. Ellis

John R. Ellis, Champion

  • 3236 Posts
  • 802 Reply Likes
Updated the categories to include LR Classic.
Photo of Sunil Bhaskaran

Sunil Bhaskaran, Official Rep

  • 275 Posts
  • 86 Reply Likes
Thanks for letting us know.
We will look into this.

Photo of John R. Ellis

John R. Ellis, Champion

  • 3230 Posts
  • 801 Reply Likes