Skip to content

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

@ffiirree

Description

@ffiirree

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 EnumDisplaySettings function 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.

  • < Windows 8.1 : GetDeviceCaps(hdc, LOGPIXELSX), system DPI
  • >= Windows 8.1 : GetDpiForMonitor(,MDT_EFFECTIVE_DPI,,) with SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE), per monitor DPI, but may affect the UI of the process
  • >= Windows 10, version 1607 : GetDpiForMonitor(,MDT_EFFECTIVE_DPI,,) with SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) in a thread, per monitor DPI

More information

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions