-
Notifications
You must be signed in to change notification settings - Fork 118
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
Adapt GetSystemMetrics call to be DPI dependent #1209
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this PR changes (all?) calls to OS.GetSystemMetrics
for a call to a new intermediate method in Widget
: why not simply change OS.GetSystemMetrics
and put the new logic in there?
The request for changes is only because of the change in Table
.
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
Show resolved
Hide resolved
@ShahzaibIbrahim please also improve the commit message:
|
Not all calls, just the child of all widgets, also these are OS related calls, we can't really change the implementation of it. That's why created one intermediate call for all of them. |
e22a829
to
03dc8a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One call is still wrong (look at the parameter)
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing my findings. I took a deeper look and found some other stuff I would like your input on:
- I noticed there are still some calls inside the
widgets
and thewin32
package that are not using the new method, namely these 3 on top
The first one (in theOS
class) is probably OK because it asks for the value ofSM_IMMENABLED
which I assume is the same regardless of the current DPI settings (please confirm/rebut) - What would happen if one removes the
if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607)
in the new method and always callsOS.GetSystemMetricsForDpi(...)
? Would the application crash in older Windows versions?
NOTE: The request for changes is only because point nr 1.
I am not sure if the applications crashes in older version, and also can't test it but looking at the usage for dpi dependent OS calls, this check is always used which makes me think that it may have some affects on older windows versions. |
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
Outdated
Show resolved
Hide resolved
21fa04b
to
60b5ba8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addressing my change requests, @ShahzaibIbrahim . Would it be possible to rebase in origin/master
so I can checkout your PR and take a deeper look at it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look better now, I see that all the widgets go through the new method now ✔️
Since there has been some changes since the beginning of this PR, I would like to validate the behavior of the code myself. Some brief "How to test" and also "Expected (observable?) behavior" sections in the description of this PR would help.
Writing GetSystemMetrics method in Widget class so that the child controls can use it to get System Metrics to be DPI dependent Contributes to: eclipse-platform#62 & eclipse-platform#127
@ShahzaibIbrahim thank you for adding a How to test. I tested in Windows 10 and I see no difference before and after this PR. Before (Table, size 100x100)AfterMaybe I'm testing it wrong? |
No you have tested it correctly. I just forgot to mention that you need to add these vm arguments while running the example. -Dswt.autoScale=quarter |
I tested it again and I still see no difference between before and after this PR. Moreover, the status before this PR looks OK (I see both scroll bars when moving to the monitor with zoom = 200. Can you please confirm? Before (Table size 100x100)Zoom = 200 After (Table size 100x100) |
NOTE: these changes affect only Windows
What it does
Writing GetSystemMetrics method in Widget class so that the child controls can use it to get System Metrics to be DPI dependent. There are some visible affected areas (before and after zooming to 200 from 100) for which screenshots are attached.
The OS.getSystemMetrics call had a slight issue in some of the controls i.e. Combo, List and Table. The values returned for scroll i.e.
OS.SM_CXVSCROLL
were independent of DPI. So moving the shell from smaller zoom level to higher zoom level we can see the visible difference in the scroll bar which is not visible in the latter part.HOW TO TEST (Windows only!)
-Dswt.autoScale=quarter
-Dswt.autoScale.updateOnRuntime=true
EXPECTED BEHAVIOUR
None of the widgets should look out of order when changing the zoom level.
Contributes to #62 and #127: