Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program icon scaling using DPI #1804

Conversation

amartya4256
Copy link
Contributor

@amartya4256 amartya4256 commented Feb 4, 2025

This PR contributes to proper scaling of Program icon. Since, these icons are retrieved by OS.SHGetFileInfo which is System DPI-Aware, it returns the icon with zoom level of the primary monitor at application startup. Hence, for initialNativeZoom of the Image object to be created for the icon, the zoom retrieved from the DPI is considered.

contributes to #62 and #127
fixes #1759

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Test Results

   494 files  ±0     494 suites  ±0   10m 10s ⏱️ -35s
 4 333 tests ±0   4 319 ✅ ±0   14 💤 ±0  0 ❌ ±0 
16 574 runs  ±0  16 465 ✅ ±0  109 💤 ±0  0 ❌ ±0 

Results for commit d7120e1. ± Comparison against base commit 81ac825.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have discussed, this seem to be the "right" short-term solution. I want to point out that we plan to work on replacing the call to SHGetFileInfo in order to get rid of the returned icons being scaled according to initial primary monitor zoom.

Can you please adapt the commit message to state that this will actually fix
#1759 (as the usage of display causing the reported issue is completely removed)?

@amartya4256 amartya4256 force-pushed the amartya4256/program_icon_scaling_using_dpi branch from 6297c78 to 869fa19 Compare February 4, 2025 17:02
@amartya4256
Copy link
Contributor Author

Can you please adapt the commit message to state that this will actually fix #1759 (as the usage of display causing the reported issue is completely removed)?

Adapted both in the PR description and the commit message

@amartya4256 amartya4256 force-pushed the amartya4256/program_icon_scaling_using_dpi branch from 869fa19 to 5ad58b9 Compare February 4, 2025 17:11
@HeikoKlare HeikoKlare force-pushed the amartya4256/program_icon_scaling_using_dpi branch from 5ad58b9 to a1ac77d Compare February 5, 2025 07:34
@@ -427,6 +427,13 @@ public ImageData getImageData (int zoom) {
return imageData;
}

private int getSystemWideDPI() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..AtStartup ? This value doesn't change. Thats why we need to use it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so but SystemWideDPI is, I reckon implicable for System DPI-aware value. At least that's what I found by definition here: https://learn.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows#system-dpi-awareness

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that the value we use here is equivalent to the DPI value when using "system DPI awareness", but we need to be aware that the we use here is the same throughout application lifecycle even when not using system DPI awareness, isn't it? I usually execute my runtime application directly with PerMonitorV2 and still this value is static.

Maybe we should not refer to any such predefined name but could instead also put the DPIUtil.mapDpiToZoom() call inside this method an make the method do some getPrimaryMonitorZoomAtStartup() and keep the documentation that SHGetFileInfo returns the icon scaled according to primary monitor zoom at startup? Then at least the given information is consistent and can be easily validated by anyone trying to understand the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. On it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you agree with this, @akoch-yatta?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure. I think, that should give the right expectation, what the method returns

@amartya4256 amartya4256 force-pushed the amartya4256/program_icon_scaling_using_dpi branch from a1ac77d to 2756354 Compare February 5, 2025 09:42
@HeikoKlare HeikoKlare force-pushed the amartya4256/program_icon_scaling_using_dpi branch from 2756354 to d684b15 Compare February 5, 2025 12:09
This commit contributes to proper scaling of Program icons. Since these
icons are retrieved by OS.SHGetFileInfo which is System DPI-Aware, it
returns the icon with zoom level of the primary monitor at application
startup. Hence, for initialNativeZoom of the Image object to be created
for the icon, the zoom retrieved from the DPI is considered.

Contributes to
eclipse-platform#62 and
eclipse-platform#127

Fixes eclipse-platform#1759
@HeikoKlare HeikoKlare force-pushed the amartya4256/program_icon_scaling_using_dpi branch from d684b15 to d7120e1 Compare February 5, 2025 12:40
@HeikoKlare HeikoKlare merged commit e2ae17b into eclipse-platform:master Feb 5, 2025
14 checks passed
@HeikoKlare HeikoKlare deleted the amartya4256/program_icon_scaling_using_dpi branch February 5, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants