ThePhD / infoware

C++ Library for pulling system and hardware information, without hitting the command line.
Creative Commons Zero v1.0 Universal
410 stars 84 forks source link

Physical resolution / DPI of scaled high-DPI displays on Windows #66

Open ffiirree opened 1 year ago

ffiirree commented 1 year ago

The resolution currently detected are virtual ones after scaling and the DPI seems to be wrong, like:

# \\.\DISPLAY1
  Scale               : 100%
  Physical Reslution  : 2560 x 1440
  Logical Reslution   : 2560 x 1440
  Physical DPI        : 108.887
  Logical DPI         : 96
  Frequency           : 59
  BPP                 : 32
  Position            : 0, 0             # the primary display contains the origin (0,0) for compatibility
  Primary             : true
  Orientation         : Landscape

# \\.\DISPLAY2
  Scale               : 150%
  Physical Reslution  : 1920 x 1080
  Logical Reslution   : 1280 x 720
  Physical DPI        : 92.607
  Logical DPI         : 144
  Frequency           : 50
  BPP                 : 32
  Position            : -1920, -592
  Primary             : false
  Orientation         : Landscape

The infoware output:

    #1:
      Resolution  : 2560x1440
      DPI         : 96
      Colour depth: 32b
      Refresh rate: 59Hz
    #2:
      Resolution  : 1280x720
      DPI         : 96
      Colour depth: 32b
      Refresh rate: 50Hz

Resolution

I think it should provide the physical resolution and the scale factor instead of the (virtual) resolution, the virtual resolution will be affected by the PROCESS_DPI_AWARENESS .

The physical resolution can be got by EnumDisplaySettingsfunction with ENUM_CURRENT_SETTINGS just like the one used in available_display_configurations().

DPI

All the DPI retrieved by GetDeviceCaps(hdc, LOGPIXELSX) in infoware for multiple displays is the system (primay display virtual) DPI, not per display.

More information

more information required, such as scale factor, position , primary, orientation.