microsoft / microsoft/terminal

OpenConsole not DpiAware, causes GetSystemMetrics to indicate poor icon sizes

Open
#18,464 5 comments 0 reactions 1 assignee Claimed by @DHowett View on GitHub
Area-Server Issue-Bug Issue-Task Priority-3 Product-Conhost zInbox-Bug
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.21.3231.0

### Windows build number

10.0.22631

### Other Software

(I was using Yori but I don't think you need to)

### Steps to reproduce

1. Set the display DPI to 125%
2. Have a program that supports 20x20 and 40x40 icon sizes
3. Run the program, and ConHost/OpenConsole will load the 16x16 icon and scale it up rather than load the 20x20 size that is native for this DPI

### Expected Behavior

The optimal icon size for the DPI configuration.

### Actual Behavior

`ConExtractIconInBothSizesW` calls `GetSystemMetrics`, and the debugger indicated that `GetSystemMetrics` returns the wrong size. Looking at the OpenConsole manifest showed no indication of DPI awareness, which explains its behavior. `ConExtractIcons` seems to have quite sophisticated logic to probe for these icon sizes and use them if present before falling back to more common sizes, but this is effectively disabled if `GetSystemMetrics` won't return the exotic sizes. Patching the return values from `GetSystemMetrics` was sufficient for the rest of OpenConsole to load and use the 20x20 icon.

![Image](https://github.com/user-attachments/assets/1905a52b-33a9-4fb3-8eeb-524e7e85a464)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.