WerWolv / ImHex

🔍 A Hex Editor for Reverse Engineers, Programmers and people who value their retinas when working at 3 AM.
https://imhex.werwolv.net
GNU General Public License v2.0
43.92k stars 1.92k forks source link

[Bug] Scaling on Windows not implemented properly multiple scales and 4k. #1906

Open KyleADOlson opened 1 week ago

KyleADOlson commented 1 week ago

Operating System

Windows 10/11

What's the issue you encountered?

The application is scaled either to 1px=1px or to the Windows system scaling factor rather than using the per-monitor scaling on Windows (multiplied by the user's set scaling factor, which shouldn't need to be set for accessibility). At this point I'm unsure if it is using the wrong scaling factor or none at all.

On my system, currently with 2 4k monitors and a 1080p laptop monitor the window defaults to being too small for accessibility on the 4k monitor but normal on the laptop screen.

While I can use find the scaling factor and expand it, this will break when a Window slides between monitors or when I am using my laptop undocked or with different monitors.

How can the issue be reproduced?

Run a new ImGui install on a Windows 11 Laptop with a 1080p screen and a 4k monitor in 4k resolution attached.

ImHex Version

1.35.4

ImHex Build Type

Installation type

msi

Additional context?

I don't know how much this is an ImGui problem or something implemented incorrectly in ImGui.

There's a correct pattern when working in modern Win32. A window needs to scale itself based on MonitorFromWindow/GetScaleFactorForMonitor. Whenever the window moves or a scale change event triggers, the window must rescale/redraw itself if the scale has changed.

https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorformonitor

While an application can "work around" the problem with manual scale changes, it's far from an ideal situation, and it's a problem that only gets worse year after year when apps don't handle it as 4k monitors become more reasonable.

As a said, this is in "Win32". I don't know what ImGui exposes of this code to make it more possible to perform the cross platform scaling. Many modern UI platforms automatically implement this feature on Windows.

The options for a fix, without knowing what ImGui offers, or what is reasonable, likely look like: 1) Turn on the right option in ImGui 2) Add lines of ImGui code that match the Win32 functions 3) Add Win32 native lines on the Windows build to find the scale for the monitor 4) Fix ImGui :)

I can take a look at the code when I get a chance and see what's going on. My boss has been looking for alternate UI frameworks and I wouldn't mind being able to have an opinion on ImGui.

WerWolv commented 1 week ago

Hey! Thanks for the report ImGui includes basically nothing in the regards of DPI scaling, you need to do it manually. That said, the latest nightly builds improve on this quite a lot and also the work I did on Fenestra will soon benefit ImHex as well. With that, the issue should hopefully be solved.

I sadly don't have any monitors like this and also nobody else has stepped up so far to improve on it so it's pretty hard to test and implement for me alone. I do hope that it will get better soon though