src/solaris/classes/sun/awt/X11/XWindow.java

Print this page

        

@@ -279,16 +279,88 @@
 
     protected String[] getWMClass() {
         return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
     }
 
-    void setReparented(boolean newValue) {
-        reparented = newValue;
+    /**
+     * Current native parent of this window.
+     *
+     * Synchronization: state lock.
+     */
+    private long nativeParent = XConstants.None;
+
+    /**
+     * Get the current native parent window of this window as reported via
+     * the ReparentNotify.
+     */
+    public final long getNativeParent() {
+        synchronized (getStateLock()) {
+            return nativeParent;
+        }
+    }
+
+    /**
+     * Sets the current native parent of the window.
+     * Primarily intended to be called from the handleReparentNotifyEvent().
+     */
+    public void setNativeParent(long parent) {
+        synchronized (getStateLock()) {
+            nativeParent = parent;
+        }
+    }
+
+    @Override
+    public void handleReparentNotifyEvent(XEvent xev) {
+        super.handleReparentNotifyEvent(xev);
+
+        XReparentEvent  xe = xev.get_xreparent();
+
+        if (xe.get_window() != getWindow()) {
+            return;
+        }
+
+        setNativeParent(xe.get_parent());
+    }
+
+    /**
+     * Returns the root window of the current window.
+     */
+    public final long getRootWindow() {
+        if (getWindow() == XConstants.None) {
+            return XConstants.None;
+        }
+        XToolkit.awtLock();
+        try {
+            XlibUtil.getWindowGeometry(getWindow(), XlibWrapper.larg1);
+            return Native.getWindow(XlibWrapper.larg1);
+        } finally {
+            XToolkit.awtUnlock();
+        }
     }
 
-    boolean isReparented() {
-        return reparented;
+    /**
+     * Indicates whether the window is currently parented or not.
+     */
+    public final boolean isParented() {
+        long nativeParent = getNativeParent();
+        return nativeParent != XConstants.None &&
+            nativeParent != getRootWindow();
+    }
+
+    /**
+     * Indicates if this window has not yet been parented by the window
+     * manager.
+     *
+     * If the window is not expected to be parented at all (like if the WM is
+     * non-reparenting, or this is an OverrideRedirect window), this method
+     * returns false.
+     */
+    public boolean mayBeReparented() {
+        return 
+            XWM.isRunning() &&
+            !XWM.isNonReparentingWM() &&
+            !isParented();
     }
 
     static long getParentWindowID(Component target) {
 
         ComponentPeer peer = target.getParent().getPeer();

@@ -992,37 +1064,45 @@
     }
 
     public void doLayout(int x, int y, int width, int height) {}
 
     public void handleConfigureNotifyEvent(XEvent xev) {
-        Rectangle oldBounds = getBounds();
+        XConfigureEvent xe = xev.get_xconfigure();
 
+        if (xe.get_window() != getWindow()) {
+            return;
+        }
+
+        Rectangle oldBounds = getBounds();
         super.handleConfigureNotifyEvent(xev);
         insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}",
-                   new Object[] {xev.get_xconfigure(), isEventDisabled(xev)});
+                   new Object[] {xe, isEventDisabled(xev)});
         if (isEventDisabled(xev)) {
             return;
         }
 
-//  if ( Check if it's a resize, a move, or a stacking order change )
-//  {
+
         Rectangle bounds = getBounds();
         if (!bounds.getSize().equals(oldBounds.getSize())) {
             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
         }
         if (!bounds.getLocation().equals(oldBounds.getLocation())) {
             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
         }
-//  }
     }
 
     public void handleMapNotifyEvent(XEvent xev) {
         super.handleMapNotifyEvent(xev);
         log.log(Level.FINE, "Mapped {0}", new Object[] {this});
         if (isEventDisabled(xev)) {
             return;
         }
+
+        if (xev.get_xany().get_window() != getWindow()) {
+            return;
+        }
+
         ComponentEvent ce;
 
         ce = new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_SHOWN);
         postEventToEventQueue(ce);
     }

@@ -1030,10 +1110,14 @@
     public void handleUnmapNotifyEvent(XEvent xev) {
         super.handleUnmapNotifyEvent(xev);
         if (isEventDisabled(xev)) {
             return;
         }
+        if (xev.get_xany().get_window() != getWindow()) {
+            return;
+        }
+
         ComponentEvent ce;
 
         ce = new ComponentEvent(target, ComponentEvent.COMPONENT_HIDDEN);
         postEventToEventQueue(ce);
     }

@@ -1400,11 +1484,11 @@
             XToolkit.awtLock();
             try {
                 Object wpeer = XToolkit.targetToPeer(comp);
                 if (wpeer == null
                     || !(wpeer instanceof XDecoratedPeer)
-                    || ((XDecoratedPeer)wpeer).configure_seen)
+                    || !((XDecoratedPeer)wpeer).areBoundsAdjusting())
                 {
                     return toGlobal(0, 0);
                 }
 
                 // wpeer is an XDecoratedPeer not yet fully adopted by WM