eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
112 stars 134 forks source link

DPIUtil: Device Zoom only taken for one monitor #58

Open MarcelBoerner opened 2 years ago

MarcelBoerner commented 2 years ago

The device zoom in the DPIUtil is a static field which is only set once to the device zoom of the primary monitor. So using any method from DPIUtil delivers wrong values on multi monitor environments where the scaling differs between the primary and any other monitor. Moving a window from primary monitor with a scaling value of 125% to a secondary monitor with 250% results in bitmap scaling and blurry text. image The text should not get blurry.

akurtakov commented 2 years ago

Please always share details about your environment as implementations may differ. Windows, Linux, Mac?

sravanlakkimsetti commented 2 years ago

@niraj-modi based on the screen shot I believe this report is on Windows. Can you please take a look?

sravanlakkimsetti commented 2 years ago

Please always share details about your environment as implementations may differ. Windows, Linux, Mac?

You are right. There are 4 different implementations. Linux has two, Windows has one and mac has one.

Based on the icon in the screenshot, I believe this is Windows implementation.

Regarding two implementations on linux. KDE on Ubuntu 18 uses different implementation. gnome variants and kde on ubuntu 20 onwards use different implementation. This problem should not appear on the linux gnome and Mac.

MarcelBoerner commented 2 years ago

Sorry i would label it but the label is grayed out. And yes the problems are all on windows 10.

akurtakov commented 2 years ago

Sorry i would label it but the label is grayed out. And yes the problems are all on windows 10.

Thanks for letting me know, we will have to find a way to allow non-colaborators to do it.

lshanmug commented 2 years ago

The device zoom in the DPIUtil is a static field which is only set once to the device zoom of the primary monitor. So using any method from DPIUtil delivers wrong values on multi monitor environments where the scaling differs between the primary and any other monitor.

DPIUtil.getDeviceZoom() and other DPIUtil methods are not expected to be used by client code as they are not API. Though marked public they belong to the internal package (to be accessed internally by SWT code across packages).

Have you tried using Monitor.getZoom() https://www.eclipse.org/eclipse/news/4.8/platform_isv.php#monitor-getzoom ?

Moving a window from primary monitor with a scaling value of 125% to a secondary monitor with 250% results in bitmap scaling and blurry text.

Also, please note that SWT by default only supports zoom factors 100 and 200. Other zoom values are rounded off.

MarcelBoerner commented 2 years ago

DPIUtil.getDeviceZoom() and other DPIUtil methods are not expected to be used by client code as they are not API. Though marked public they belong to the internal package (to be accessed internally by SWT code across packages). Have you tried using Monitor.getZoom() https://www.eclipse.org/eclipse/news/4.8/platform_isv.php#monitor-getzoom ?

Hi yes, we know its not api but you use it indirectly when you for example call Display.getMonitor() (which is part of public api). And using then getZoom does not help, since you get in dpi aware mode (not the per monitor (v2) variant) then you get always the zoom of the primary monitor.

Also, please note that SWT by default only supports zoom factors 100 and 200. Other zoom values are rounded off.

If you have 175% for example you get everything scaled up to 200% which leads to blurry images and texts for example. Even when using not the default but the exact flag you get new errors. So 100% and 200% is not sufficient since the scaling can be freely set up to 500% in windows (depends on what kind of monitor with which resolution you use). If swt does not support scaling correctly it has a major disadvantage to other technologies. Most new Software is written with browser technologies. Since browsers support the scaling without any bigger problems.