diff --git a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java index 9f207ee7a8b..5fc56ba05d1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/CoordinateSystemMapperTests.java @@ -210,6 +210,15 @@ void translateRectangleInPixelsInBothMonitorsBackAndForthShouldBeTheSame(Coordin assertEquals(rectInPxs, mapper.translateToDisplayCoordinates(rectInPts, monitors[0].getZoom())); } + @ParameterizedTest + @MethodSource("provideCoordinateSystemMappers") + void translateRectangleInPixelsForZeroSize(CoordinateSystemMapper mapper) { + setupMonitors(mapper); + Rectangle rectInPts = createExpectedRectangle(mapper, 0, 0, 0, 0, monitors[0]); + Rectangle rectInPxs = mapper.translateToDisplayCoordinates(rectInPts, monitors[0].getZoom()); + assertEquals(rectInPts, mapper.translateFromDisplayCoordinates(rectInPxs, monitors[0].getZoom())); + } + private Point createExpectedPoint(CoordinateSystemMapper mapper, int x, int y, Monitor monitor) { if (mapper instanceof SingleZoomCoordinateSystemMapper) { return new Point(x, y); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java index 2057c9305ed..0edae112b5f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MultiZoomCoordinateSystemMapper.java @@ -192,6 +192,9 @@ private Monitor getContainingMonitorForPoints(int x, int y) { } private Monitor getContainingMonitorForPoints(int x, int y, int width, int height) { + if (width <= 0 || height <= 0) { + return getContainingMonitorForPoints(x, y); + } Monitor[] monitors = monitorSupplier.get(); Monitor selectedMonitor = null; int highestIntersectionRatio = 0;