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

Allow smooth scaling for 100% monitors too #1809

Merged

Conversation

fedejeanne
Copy link
Contributor

@fedejeanne fedejeanne commented Feb 6, 2025

Smooth scaling is used if:

  • (in Windows) Monitor-specific scaling is active
  • (in Linux) if the zoom level of the monitor is not divisible by 100
  • (in Mac) never

In Linux, once the mode changes to smooth, it stays in smooth.

How to test

  • One 100% monitor and another in a "fractional" zoom e.g. 150%
  • Start the ControlExample with the following VM parameters:
-Dswt.autoScale.updateOnRuntime=true
  • (Linux) Drag the application back and forth between monitors

Expected result

In Windows

The autoScaleMethod should always be set to SMOOTH (in org.eclipse.swt.internal.DPIUtil.setDeviceZoom(int))

In Linux

  • If the application starts in the monitor with the "non fractional" zoom level (e.g. 100% or 200%) then the mode should be NEAREST
  • The autoScaleMethod should be set to SMOOTH when starting at/switching to a monitor with a "fractional" zoom level (e.g. 150%).
  • Once in SMOOTH mode, it should never switch back to NEAREST

In Mac

No changes: never SMOOTH.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

Test Results

   502 files  ±0     502 suites  ±0   11m 49s ⏱️ + 3m 54s
 4 334 tests ±0   4 320 ✅ ±0   14 💤 ±0  0 ❌ ±0 
16 575 runs  ±0  16 466 ✅ ±0  109 💤 ±0  0 ❌ ±0 

Results for commit 8dace1d. ± Comparison against base commit df1c412.

♻️ 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.

The change looks fine to me. If I am not mistaken, it only introduced one change in behavior, which might be considered. It is the following scenario:

  • Running on GTK
  • Starting with or changing to a deviceZoom that is not a multiple of 100 (like 150), which then enables "smooth" scaling
  • Changing to a deviceZoom of 100 (which previously kept "smooth" scaling and now switches back to "nearest" scaling)

On GTK, this is triggered by Display#dpiChanged(). What might be the result? Images are initially created for 150% scale and when then scaled down to 100% after changing deviceZoom to 100, this rescaling happens with "nearest" instead of "smooth", leading to bad results.

Maybe it makes more sense if we say that when auto-scaling was set to "smooth" once, it will stay at "smooth", no matter to what deviceZoom the value is changed?

@fedejeanne
Copy link
Contributor Author

@HeikoKlare so all in all you propose:

  • If it starts in a "non-fractional" monitor (100%, 200%, 400% etc) then use NEAREST
  • When switching to (or starting at) a "fractional" monitor, use SMOOTH
  • Once in SMOOTH, never go back to NEAREST

All of this shall be done for Windows and Linux (never for Mac) and only when using the "auto" scale mode.

Is that correct?

@fedejeanne
Copy link
Contributor Author

And of course, in Windows this only applies when activating the monitor-specific scaling

@HeikoKlare
Copy link
Contributor

Exactly 👍 Just that I would apply the logic to Linux only. On Windows I would use "nearest" unless monitor-specific scaling is enabled (then use "smooth" but also when deviceZoom is 100).

@fedejeanne
Copy link
Contributor Author

Done @HeikoKlare

@fedejeanne fedejeanne marked this pull request as ready for review February 7, 2025 10:39
@fedejeanne fedejeanne force-pushed the activate_smooth_on_100 branch 2 times, most recently from 3e5f932 to a0aebf9 Compare February 10, 2025 10:41
@fedejeanne
Copy link
Contributor Author

fedejeanne commented Feb 10, 2025

In a0aebf9 I made sure that the corner case of coming back to a 100% monitor in Linux remains unchanged by this PR i.e.

  • Starting with a 100% monitor: NEAREST
  • 100% --> 125% --> 100%: SMOOTH (corner case)
  • 100% --> 125% --> 200%: NEAREST

Do not change the logic for Linux: coming back to 100% monitor stays in
the current mode.

Co-authored-by: Heiko Klare <[email protected]>
@fedejeanne fedejeanne force-pushed the activate_smooth_on_100 branch from a0aebf9 to 8dace1d Compare February 11, 2025 15:26
@fedejeanne fedejeanne merged commit df0ae71 into eclipse-platform:master Feb 11, 2025
14 checks passed
@fedejeanne fedejeanne deleted the activate_smooth_on_100 branch February 11, 2025 15:43
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.

Unintended initial state (and switch) of the auto-scale mode
2 participants