< prev index next >

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

Print this page

        

@@ -39,10 +39,11 @@
 abstract class XDecoratedPeer extends XWindowPeer {
     private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XDecoratedPeer");
     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.
     boolean configure_seen;
     boolean insets_corrected;

@@ -264,11 +265,11 @@
     private Insets getWMSetInsets(XAtom changedAtom) {
         if (isEmbedded()) {
             return null;
         }
 
-        if (wm_set_insets != null) {
+        if (!isNull(wm_set_insets)) {
             return wm_set_insets;
         }
 
         if (changedAtom == null) {
             wm_set_insets = XWM.getInsetsFromExtents(getWindow());

@@ -343,11 +344,16 @@
                 setReparented(true);
                 insets_corrected = false;
 
                 // 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);
                     }
                     // If these insets are equal to our current insets - no actions are necessary
                     Insets dimInsets = dimensions.getInsets();

@@ -368,12 +374,14 @@
                             insLog.finer("correctWM insets are not available, waiting for configureNotify");
                         }
                     }
                 }
 
-                if (correctWM != null) {
+                if (!isNull(correctWM)) {
                     handleCorrectInsets(correctWM);
+                } else {
+                    insets_corrected = false;
                 }
             }
         } finally {
             XToolkit.awtUnlock();
         }
< prev index next >