Skip to content

Commit b8ac17e

Browse files
committed
Backport 41bf2ad159d274574285a0f55c4a0f582cd93648
1 parent 0c506cf commit b8ac17e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -892,18 +892,22 @@ private void resetScreenInsetsCache() {
892892

893893
@Override
894894
public Insets getScreenInsets(final GraphicsConfiguration gc) {
895-
final X11GraphicsDevice device = (X11GraphicsDevice) gc.getDevice();
896-
Insets insets = device.getInsets();
897-
if (insets == null) {
898-
synchronized (device) {
899-
insets = device.getInsets();
900-
if (insets == null) {
901-
insets = getScreenInsetsImpl(gc);
902-
device.setInsets(insets);
895+
final GraphicsDevice gd = gc.getDevice();
896+
if (gd instanceof X11GraphicsDevice x11Device) {
897+
Insets insets = x11Device.getInsets();
898+
if (insets == null) {
899+
synchronized (x11Device) {
900+
insets = x11Device.getInsets();
901+
if (insets == null) {
902+
insets = getScreenInsetsImpl(gc);
903+
x11Device.setInsets(insets);
904+
}
903905
}
904906
}
907+
return (Insets) insets.clone();
908+
} else {
909+
return super.getScreenInsets(gc);
905910
}
906-
return (Insets) insets.clone();
907911
}
908912

909913
/*

0 commit comments

Comments
 (0)