Skip to content

Commit da21f5c

Browse files
mkartashevjbrbot
authored andcommitted
JBR-9884 Wayland: logical screen size reported incorrectly when fractional scaling is OFF
The size is corrected only under -Dsun.awt.wl.correctLogicalSize=true. The location is unchanged.
1 parent ddad0b5 commit da21f5c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/java.desktop/unix/classes/sun/awt/wl/WLGraphicsEnvironment.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class WLGraphicsEnvironment extends SunGraphicsEnvironment implements HiD
5353
private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.wl.WLGraphicsEnvironment");
5454

5555
private static final boolean debugScaleEnabled;
56+
private static final boolean correctLogicalSize = Boolean.getBoolean("sun.awt.wl.correctLogicalSize");
5657
private final Dimension totalDisplayBounds = new Dimension();
5758

5859
private final List<WLGraphicsDevice> devices = new ArrayList<>(5);
@@ -136,6 +137,15 @@ private void notifyOutputConfigured(String name, String make, String model, int
136137
if (widthLogical <= 0) widthLogical = width;
137138
if (heightLogical <= 0) heightLogical = height;
138139

140+
if (correctLogicalSize && widthLogical == width && heightLogical == height && scale > 1) {
141+
// With fractional scale OFF, logical and physical sizes are reported as equal.
142+
// "Convert" the logical size to logical units to maintain Java promise of
143+
// always abstracting out the physical size.
144+
// Note that the monitor's location (offset) is left unchanged and is in physical units (pixels).
145+
widthLogical = (int) Math.ceil((double) width / scale);
146+
heightLogical = (int) Math.ceil((double) height / scale);
147+
}
148+
139149
// Physical size may be absent for virtual outputs.
140150
if (widthMm <= 0 || heightMm <= 0) {
141151
// Assume a 92 DPI display

0 commit comments

Comments
 (0)