eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

Adapt GetSystemMetrics call to be DPI dependent

Open ShahzaibIbrahim opened this issue 1 year ago • 4 comments

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.

Combo List Table

HOW TO TEST

Compare the values returned for new and old method when sending the OS.SM_CXVSCROLL call to get system metrics and check the difference or you can do the manual testing (before and after the new call) for which screenshots are also attached.

EXPECTED BEHAVIOUR

None of the widgets should look out of order when changing the zoom level.

Contributes to #62 and #127:

ShahzaibIbrahim avatar May 03 '24 12:05 ShahzaibIbrahim

Test Results

   450 files  ±0     450 suites  ±0   7m 44s :stopwatch: -16s  4 127 tests ±0   4 119 :white_check_mark: ±0   8 :zzz: ±0  0 :x: ±0  16 319 runs  ±0  16 227 :white_check_mark: ±0  92 :zzz: ±0  0 :x: ±0 

Results for commit 95051036. ± Comparison against base commit a3cf373e.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar May 03 '24 12:05 github-actions[bot]

@ShahzaibIbrahim please also improve the commit message:

  • Remove the links from the first line (they are in the body anyway)
  • Add the text "Fixes" or "Contributes to" appropriately for the linked issues

fedejeanne avatar May 06 '24 10:05 fedejeanne

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?

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.

ShahzaibIbrahim avatar May 06 '24 15:05 ShahzaibIbrahim

  1. What would happen if one removes the if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN10_1607) in the new method and always calls OS.GetSystemMetricsForDpi(...)? Would the application crash in older Windows versions?

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.

ShahzaibIbrahim avatar May 13 '24 13:05 ShahzaibIbrahim

@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)

Zoom = 100 image

Zoom = 200 image

After

Zoom = 100 image

Zoom = 200 image

Maybe I'm testing it wrong?

fedejeanne avatar May 23 '24 14:05 fedejeanne

Maybe 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 -Dswt.autoScale.updateOnRuntime=true

ShahzaibIbrahim avatar May 23 '24 14:05 ShahzaibIbrahim

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 = 100 image

Zoom = 200 According to the initial description of the bug, this image should show a missing horizontal scrollbar, right?

image

After (Table size 100x100)

Zoom = 100 image

Zoom = 200 image

fedejeanne avatar May 24 '24 08:05 fedejeanne

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?

Please check the scroll with 50x50 size and you will see the difference visibly. I have also added this in How to test section.

ShahzaibIbrahim avatar Jun 10 '24 08:06 ShahzaibIbrahim

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?

If a scrollbar is shown or not could perhaps be a side effect in some scenarios, but the main reason for that change is that the correct value for scroolbar sizes are used when the size for the table is calculated. You'll see the effect in the following screenshot:

image

Both are started on 100% and moved to 200% (That is when the screenshots were made). The left one uses OS.GetSystemMetrics, the right one uses OS.GetSystemMetricsForDpi. You'll see the left table is smaller, because it still uses the scrollbar sizes for the primary monitor (=OS.GetSystemMetrics)

akoch-yatta avatar Jun 14 '24 13:06 akoch-yatta

This change caused severe regression in the compare editor, see https://github.com/eclipse-platform/eclipse.platform/issues/1489.

iloveeclipse avatar Aug 09 '24 13:08 iloveeclipse