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

Fix Caret Rescaling for win32 #62 #1847

Merged

Conversation

amartya4256
Copy link
Contributor

@amartya4256 amartya4256 commented Feb 19, 2025

This PR fixes caret rescaling by making sure the the field height is updated for every caret and Caret::resize is called for those carets where applicable.

contributes to
#62 and #127

To reproduce

This is my configuration and how I reproduce the error in my current Eclipse IDE.

  • Activate Monitor-specific UI scaling either via the preferences (General > Appearance) or by using the flag -Dswt.autoScale.updateOnRuntime=true
  • 125% monitor on the left (primary)
  • 175% monitor on the right
  • Open editor, click somewhere -> caret appears
  • Move to the other monitor -> caret broken: it's in the wrong position and has the wrong size

In this video you can see how I moved from the monitor on the right to the one on the left and then back. The caret is broken after I move to the monitor on the left and stays broken when I come back to the monitor on the right.

Copy link
Contributor

github-actions bot commented Feb 19, 2025

Test Results

   502 files  ±0     502 suites  ±0   8m 54s ⏱️ -53s
 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 abd904b. ± Comparison against base commit b85d9d2.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

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

It works as expected and fixes the issue, I just have one question

Copy link
Contributor

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

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

@akurtakov requesting pmc approval to merge this one

@akurtakov
Copy link
Member

I would like to have one more win32 developer to test and verify before giving approval. @HannesWell @HeikoKlare or someone else would you please test/review.

@akurtakov
Copy link
Member

@eclipse-platform/eclipse-platform-project-leads If some of you can review please step in as we are pretty close to RC1.

@HannesWell
Copy link
Member

I would like to have one more win32 developer to test and verify before giving approval. @HannesWell @HeikoKlare or someone else would you please test/review.

I tried to test it, but I didn't find sufficient instructions to reproduce the issue. I tried out all examples in SWT that reference the Caret class but none of them hit the break-point at the location that is changed.

@fedejeanne
Copy link
Contributor

I added the information on how to reproduce the error.

@HannesWell
Copy link
Member

I added the information on how to reproduce the error.

I'm sorry but I'm still not able to reproduce it, not even to trigger the code in question.
I followed the instruction you provided and tried it with a Java-Editor (as in your video).
What seems strange is that the next within the Editor doesn't change its size although e.g. the shell titel changes it's size when moving from the 125% scaled monitor to the 175% scaled one or the other way round.

@HeikoKlare
Copy link
Contributor

@HannesWell The issue description seems to miss the information that it is related to monitor-specific scaling only. The code in question is only executed when that feature is enabled. To test in a runtime Eclipse, it's not sufficient to enable the preference (as it is stored in the configuration area which is usually cleared on every restart), so it's usually best so set the according VM argument -Dswt.autoScale.updateOnRuntime=true for testing).

The above mentioned also means that the change will only have an effect when the (experimental) monitor-specific scaling preference is enabled, which makes the change rather safe for being that late in the development cycle.

Copy link
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

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

@HannesWell The issue description seems to miss the information that it is related to monitor-specific scaling only. The code in question is only executed when that feature is enabled.

That was indeed the missing part. Now I was able to reproduce it and can confirm that this fixes the issue. Thanks for this.

The above mentioned also means that the change will only have an effect when the (experimental) monitor-specific scaling preference is enabled, which makes the change rather safe for being that late in the development cycle.

Agree. But I'd leave the final decision to the platform PLs. :)

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.

@amartya4256 I agree that this change is reasonable. However, part of the issue addressed here seems to also be that StyledText::updateAndRefreshCarets calls the update functionality on the same caret multiple times. Isn't that somehow unexpected and unintended as well? I.e., shouldn't StyledText::updateAndRefreshCarets probably first collect all carets to update (removing duplicated) and then update them instead of calling the update on the same caret multiple times?

But that could be done in a follow-up PR for cleanup. This PR seems to be fine as is to fix the underlying issue.

@fedejeanne
Copy link
Contributor

But that could be done in a follow-up PR for cleanup. This PR seems to be fine as is to fix the underlying issue.

@HeikoKlare approved?

@eclipse-platform/eclipse-platform-project-leads can this still be merged (now for RC2)? It's been approved by 2 (soon maybe even 3) committers and it's been deemed safe to merge.

@merks
Copy link
Contributor

merks commented Feb 21, 2025

@iloveeclipse

I think this should be merged but it would be nice if at least one project lead agrees.

@iloveeclipse
Copy link
Member

I personally would not merge non trivial SWT changes in RC2. This change is not a trivial one.

@HeikoKlare
Copy link
Contributor

I personally would not merge non trivial SWT changes in RC2. This change is not a trivial one.

I agree that non-trivial changes should not be merged for RC2, but I would like to emphasize that this change has basically no risk (and may thus be considered rather "trivial"). The adapted code is only used for monitor-specific scaling, which is an experimental feature on Windows that is not enabled by default. An experimental feature might not work perfectly fine anway (which is why it's flagged "experimental"), but improving it as far as possible for a release (such as with this change) improves the chance that people keep testing it and report back issues so that once delivering that feature as non-experimental and enabled-by-default, it will be in a better state.

@iloveeclipse
Copy link
Member

The adapted code is only used for monitor-specific scaling, which is an experimental feature on Windows that is not enabled by default.

I haven't reviewed the code in debugger but I trust your assessment. So no objections from my side then.

@HeikoKlare
Copy link
Contributor

Thank you!

FWIW, here is a screenshot showing the single call of that method (done by the DPI change handler only used for monitor-specific scaling on Windows):
image

So with no objections from platform PL side, I consider your comment as PMC+1, @merks?

This commit fixes caret rescaling by making sure the the field height is
updated for every caret and Caret::resize is called for those carets where applicable.

contributes to
eclipse-platform#62 and
eclipse-platform#127
@HeikoKlare HeikoKlare force-pushed the amartya4256/fix_caret_rescaling branch from 1727589 to abd904b Compare February 21, 2025 16:16
@merks
Copy link
Contributor

merks commented Feb 21, 2025

I too trust @HeikoKlare's assessments and give this a PMC +1 when he deems this ready to be merged.

@HeikoKlare HeikoKlare added the pmc_approved Issues with PMC approval label Feb 21, 2025
@HeikoKlare
Copy link
Contributor

Thank you all!

@HeikoKlare HeikoKlare merged commit 9f60279 into eclipse-platform:master Feb 21, 2025
18 of 19 checks passed
@HeikoKlare HeikoKlare deleted the amartya4256/fix_caret_rescaling branch February 21, 2025 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pmc_approved Issues with PMC approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Caret is scaled improperly while moving shell between monitors with different zoom
7 participants