Skip to content

Commit 7cc858e

Browse files
HeikoKlarefedejeanne
authored andcommitted
Correct Cairo autoscaling setting in DPIUtil and remove setter #2031
Cairo auto-scaling was enabled in DPIUtil for every OS in a recent commit. This corrects the setting to be only applied on Linux/GTK and thus also issues arising from it. In addition, it removes the unnecessary setter for the auto-scaling and disables the tests that previously required it as they are meaningless without productive use of disabled Cairo auto-scale on Linux anyway. Fixes #2031
1 parent 111b874 commit 7cc858e

File tree

2 files changed

+4
-8
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal
  • tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit

2 files changed

+4
-8
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/DPIUtil.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static enum AutoScaleMethod { AUTO, NEAREST, SMOOTH }
4747
private static AutoScaleMethod autoScaleMethod = AutoScaleMethod.NEAREST;
4848

4949
private static String autoScaleValue;
50-
private static boolean useCairoAutoScale = true;
50+
private static final boolean USE_CAIRO_AUTOSCALE = SWT.getPlatform().equals("gtk");
5151

5252
/**
5353
* System property that controls the autoScale functionality.
@@ -484,7 +484,7 @@ public static Rectangle scaleUp(Drawable drawable, Rectangle rect, int zoom) {
484484
* @return float scaling factor
485485
*/
486486
private static float getScalingFactor(int zoom) {
487-
if (useCairoAutoScale) {
487+
if (USE_CAIRO_AUTOSCALE) {
488488
return 1;
489489
}
490490
if (zoom <= 0) {
@@ -631,10 +631,6 @@ private static boolean sholdUseSmoothScaling() {
631631
};
632632
}
633633

634-
public static void setUseCairoAutoScale (boolean cairoAutoScale) {
635-
useCairoAutoScale = cairoAutoScale;
636-
}
637-
638634
public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) {
639635
return getZoomForAutoscaleProperty(nativeDeviceZoom, autoScaleValue);
640636
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/DPIUtilTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import static org.junit.Assert.assertArrayEquals;
1717
import static org.junit.Assert.assertEquals;
1818
import static org.junit.Assert.assertSame;
19+
import static org.junit.Assume.assumeFalse;
1920

2021
import org.eclipse.swt.graphics.Device;
2122
import org.eclipse.swt.graphics.Point;
@@ -37,14 +38,13 @@ public class DPIUtilTests {
3738

3839
@Before
3940
public void setup() {
41+
assumeFalse("Linux uses Cairo auto scaling, thus DPIUtil scaling is disabled", SwtTestUtil.isLinux);
4042
deviceZoom = DPIUtil.getDeviceZoom();
4143
DPIUtil.setDeviceZoom(200);
42-
DPIUtil.setUseCairoAutoScale(false);
4344
}
4445

4546
@After
4647
public void tearDown() {
47-
DPIUtil.setUseCairoAutoScale(true);
4848
DPIUtil.setDeviceZoom(deviceZoom);
4949
}
5050

0 commit comments

Comments
 (0)