Skip to content

Deprecating Device#getDPI #2260

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShahzaibIbrahim
Copy link
Contributor

Having the scale factor being based on the screen DPI leads to unexpected result e.g. Image too big/small. Having a screen dpi independent factor leads to consistent results.

Copy link
Contributor

github-actions bot commented Jun 24, 2025

Test Results

   545 files  ±0     545 suites  ±0   26m 34s ⏱️ - 3m 26s
 4 405 tests ±0   4 387 ✅ ±0   18 💤 ±0  0 ❌ ±0 
16 741 runs  ±0  16 599 ✅ ±0  142 💤 ±0  0 ❌ ±0 

Results for commit a8605ae. ± Comparison against base commit 51fed8e.

♻️ This comment has been updated with latest results.

Point printerDPI = printer.getDPI();
int scaleFactor = printerDPI.x / screenDPI.x;
int scaleFactor = printerDPI.x / 100;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wasn't Display:getDPI always returning 96?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it depends on the display. Sometimes 144 or 96 or depending on the monitor. We then decided to use 100 as the base consistent value to calculate the scaleFactor like we did here: https://github.com/eclipse-platform/eclipse.platform.swt/pull/1802/files

Having the scale factor being based on the screen DPI leads to
unexpected result e.g. Image too big/small. Having a screen dpi
independent factor leads to consistent results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mark Device::getDPI() method as deprecated Replace Device::getDPI() usage in SWT Snippets/Test
2 participants