diff --git a/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java b/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java --- a/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java +++ b/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java @@ -25,17 +25,22 @@ package sun.awt.X11; -import java.awt.*; - +import java.awt.AWTKeyStroke; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Window; +import java.util.Iterator; import java.util.LinkedList; -import java.util.Iterator; - -import sun.util.logging.PlatformLogger; import sun.awt.EmbeddedFrame; import sun.awt.SunToolkit; - -import static sun.awt.X11.XConstants.*; +import sun.util.logging.PlatformLogger; +import static sun.awt.X11.XConstants.FocusIn; +import static sun.awt.X11.XConstants.FocusOut; +import static sun.awt.X11.XConstants.NoEventMask; +import static sun.awt.X11.XConstants.NotifyNormal; public class XEmbeddedFramePeer extends XFramePeer { @@ -44,6 +49,9 @@ LinkedList strokes; XEmbedClientHelper embedder; // Caution - can be null if XEmbed is not supported + + private boolean supportDrop = false; + public XEmbeddedFramePeer(EmbeddedFrame target) { // Don't specify PARENT_WINDOW param here. Instead we reparent // this embedded frame peer to the proper parent window after @@ -323,4 +331,64 @@ xev.dispose(); } } + + public void addDropTarget() { + supportDrop = true; + } + + public void removeDropTarget() { + supportDrop = false; + unregisterDropTarget(); + } + + private void registerDropTarget() { + XToolkit.awtLock(); + try { + long window = getWindow(); + System.out.println(">>> FIXED XEmbeddedFramePeer#registerDropTarget(): window=" + window); + if (window != 0) { + XDropTargetRegistry.getRegistry().registerDropSite(window); + } + } finally { + XToolkit.awtUnlock(); + } + } + + private void unregisterDropTarget() { + XToolkit.awtLock(); + try { + long window = getWindow(); + System.out.println(">>> FIXED XEmbeddedFramePeer#unregisterDropTarget(): window=" + window); + if (window != 0) { + XDropTargetRegistry.getRegistry().unregisterDropSite(window); + } + } finally { + XToolkit.awtUnlock(); + } + } + + public void handleWindowFocusInSync(long serial) { + if(supportDrop) { registerDropTarget(); } + super.handleWindowFocusInSync(serial); + } + + // NOTE: This method may be called by privileged threads. + // DO NOT INVOKE CLIENT CODE ON THIS THREAD! + public void handleWindowFocusIn(long serial) { + if(supportDrop) { registerDropTarget(); } + super.handleWindowFocusIn(serial); + } + + // NOTE: This method may be called by privileged threads. + // DO NOT INVOKE CLIENT CODE ON THIS THREAD! + public void handleWindowFocusOut(Window oppositeWindow, long serial) { + if(supportDrop) { unregisterDropTarget(); } + super.handleWindowFocusOut(oppositeWindow, serial); + } + + public void handleWindowFocusOutSync(Window oppositeWindow, long serial) { + if(supportDrop) { unregisterDropTarget(); } + super.handleWindowFocusOutSync(oppositeWindow, serial); + } + }