Community
Participate
Working Groups
org.eclipse.swt.graphics.Device#getScreenDPI() Point getScreenDPI () { int dpi = 96; //default value if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) { long /*int*/ display = GDK.gdk_display_get_default(); long /*int*/ pMonitor = GDK.gdk_display_get_primary_monitor(display); if (pMonitor == 0) { pMonitor = GDK.gdk_display_get_monitor(display, 0); } int widthMM = GDK.gdk_monitor_get_width_mm(pMonitor); // returns 0 int scaleFactor = GDK.gdk_monitor_get_scale_factor(pMonitor); GdkRectangle monitorGeometry = new GdkRectangle (); GDK.gdk_monitor_get_geometry(pMonitor, monitorGeometry); dpi = Compatibility.round (254 * monitorGeometry.width * scaleFactor, widthMM * 10); // = 2147483647 } return new Point (dpi, dpi); } Monitors report that their size is 0 mm x 0 mm (some monitors do this, TigerVNC does not transmit the monitors physical size, resulting in 0 mm x 0 mm). This causes GDK.gdk_monitor_get_width_mm(pMonitor) to return 0, which leads to widthMM == 0. The method Compatibility.round requires the second parameter to be non-zero according to its Javadoc. 0 is passed in this situation. This leads to a floating point division by zero. After casting this value to an int, Integer.MAX_VALUE is returned as dpi value. Proposed fix: Check widthMM for zero (or even negative values?) and return the default DPI in this case. The TigerVNC project even said that using the physical size of a monitor is a problem itself and just the scale factor should be used: https://github.com/TigerVNC/tigervnc/issues/789
Thanks for the bug report, we'll take a look.
New Gerrit change created: https://git.eclipse.org/r/135480
Gerrit change https://git.eclipse.org/r/135480 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=5970d5d79cf7605de4826347008adda9cf67a2ef
(In reply to Eclipse Genie from comment #3) > Gerrit change https://git.eclipse.org/r/135480 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=5970d5d79cf7605de4826347008adda9cf67a2ef In master now.
Verified in I20190219-0600.