--- old/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java 2015-10-05 14:03:12.000000000 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java 2015-10-05 14:03:12.000000000 +0300 @@ -41,6 +41,7 @@ private static final PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XDecoratedPeer"); private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XDecoratedPeer"); private static final PlatformLogger iconLog = PlatformLogger.getLogger("sun.awt.X11.icon.XDecoratedPeer"); + private static final int MAX_INSET_ATTEMPT = 100; // Set to true when we get the first ConfigureNotify after being // reparented - indicates that WM has adopted the top-level. @@ -266,7 +267,7 @@ return null; } - if (wm_set_insets != null) { + if (!isNull(wm_set_insets)) { return wm_set_insets; } @@ -345,7 +346,12 @@ // Check if we have insets provided by the WM Insets correctWM = getWMSetInsets(null); - if (correctWM != null) { + int maxAttempts = MAX_INSET_ATTEMPT; + while (maxAttempts--> 0 && isNull(correctWM)) { + Thread.yield(); + correctWM = getWMSetInsets(null); + } + if (!isNull(correctWM)) { if (insLog.isLoggable(PlatformLogger.Level.FINER)) { insLog.finer("wm-provided insets {0}", correctWM); } @@ -370,8 +376,10 @@ } } - if (correctWM != null) { + if (!isNull(correctWM)) { handleCorrectInsets(correctWM); + } else { + insets_corrected = false; } } } finally {