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

Text in Dialog was cutoff due to invalid use of AdjustWindowRectEx #1707

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

Conversation

ShahzaibIbrahim
Copy link
Contributor

AdjustWindowRectEx does not take DPI into account. So using AdjustWindowRectExForDpi and passing the zoom level to retrieve correct coordinates and scaling accordingly.

How to Reproduce

  • Run the Runtime Workspace with the following VM Arguments on 200% monitor
-Dswt.autoScale=quarter
-Dswt.autoScale.updateOnRuntime=true
  • Add a class and create a conditional breakpoint
  • Double click on Breakpoint to remove it
  • Maximize the main IDE window
  • The dialog will appear with the text cutoff
    image

Note

Replacing AdjustWindowRectEx in Decoration fixes the issue for dialogs but replacing all the non-dpi calls for AdjustWindowRectEx even though there is no visible difference (but slight difference in returned coordinates) right now but having it DPI dependent makes it consistent.

@ShahzaibIbrahim ShahzaibIbrahim linked an issue Jan 6, 2025 that may be closed by this pull request
Copy link
Contributor

github-actions bot commented Jan 6, 2025

Test Results

   485 files  ±0     485 suites  ±0   11m 4s ⏱️ +14s
 4 272 tests ±0   4 261 ✅ ±0   10 💤 ±0  1 ❌ ±0 
16 377 runs  ±0  16 271 ✅ ±0  105 💤 ±0  1 ❌ ±0 

For more details on these failures, see this check.

Results for commit 35b3e3b. ± Comparison against base commit 950ca8a.

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

One first comment on the new usage of the Windows API method: The method has been introduced for Windows 10 1607 (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-adjustwindowrectexfordpi#requirements). This means:

  • We should guard its calls by a version check and use the old (non-DPI-aware) method if that method is not met (like, e.g., for getSystemMetrics(ForDpi), as done in Widget#getSystemMetrics()
  • We should load the native method dymically to avoid a linker error on platforms that do not provide that method. This is to avoid the issue that we had before that SWT actually required rather update-to-date Windows versions due to rather new methods being statically linked to. For example, take a look at how GetSystemMetricsForDpi is called in os.c.

@HeikoKlare HeikoKlare force-pushed the master-170 branch 2 times, most recently from e5a2838 to 17f652f Compare January 10, 2025 09:09
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.

Replacing usages of that method with the DPI-dependent version makes sense.

I have updated the PR by merging the commits and fixing copy-paste errors in the documentation.

Still I am non-deterministically getting wrongly scaled versions of dialogs, e.g., this one completely missing the checkbox to not show that message again:
image
I also have a question regarding the DPI parameter of the newly adapted method, which may be related to the issue.

AdjustWindowRectEx does not take DPI into account, leading to dialog
windows being cut off. This change adjusts usages of that method to
AdjustWindowRectExForDpi, passing the zoom level to retrieve correct
coordinates and scaling accordingly.
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.

Confirmation Dialog Text Cutoff
2 participants