rust-windowing / rust-windowing/winit

Incorrect DPI scaling on Windows

Open
#3,040 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

B - bug DS - win32
Dominant language
Rust
Stars
6.2k
Forks
1.3k
Avg merge
2d 19h
Merged PRs (30d)
9

Description

While testing DPI scaling with two monitors on Windows 11, one running at 4k (150% scaling) and the other at 2k (100% scaling) and both being 32", I noticed that the window size is 50% larger on the 4k one, which should be physically the same size.

And the conversion is also "lossy" because when moving the window between both monitors it's getting larger by one pixel

// new_dpi_x, new_scale_factor
144 1 1.5
PhysicalSize { width: 1208, height: 920 } PhysicalSize { width: 1812, height: 1380 }
96 1.5 1
PhysicalSize { width: 1201, height: 901 } PhysicalSize { width: 801, height: 601 }
144 1 1.5
PhysicalSize { width: 1210, height: 921 } PhysicalSize { width: 1815, height: 1382 }
96 1.5 1
PhysicalSize { width: 1203, height: 903 } PhysicalSize { width: 802, height: 602 }
144 1 1.5
PhysicalSize { width: 1211, height: 923 } PhysicalSize { width: 1817, height: 1385 }
96 1.5 1

It seems that both monitors are using 4k logical resolution, but I assume that's Windows 11?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue on Windows 11 with two monitors using the reported 4k/150% and 2k/100% configuration, then trace the DPI and scale-factor conversion path. Done means the window remains physically consistent when moved between monitors and repeated moves do not introduce cumulative pixel-size changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.