diff --git a/jdk/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java b/jdk/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java index 624be6bfc10..4491b7c9c05 100644 --- a/jdk/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java +++ b/jdk/src/macosx/classes/sun/lwawt/LWLightweightFramePeer.java @@ -94,10 +94,12 @@ public class LWLightweightFramePeer extends LWWindowPeer { @Override public void addDropTarget(DropTarget dt) { + getLwTarget().addDropTarget(dt); } @Override public void removeDropTarget(DropTarget dt) { + getLwTarget().removeDropTarget(dt); } @Override diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 768086220c3..b184ec0759f 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -688,6 +688,11 @@ public final class LWCToolkit extends LWToolkit { @Override public DragSourceContextPeer createDragSourceContextPeer( DragGestureEvent dge) throws InvalidDnDOperationException { + final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent()); + if (f != null) { + return f.createDragSourceContextPeer(dge); + } + return CDragSourceContextPeer.createDragSourceContextPeer(dge); } @@ -696,6 +701,11 @@ public final class LWCToolkit extends LWToolkit { public T createDragGestureRecognizer( Class abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) { + final LightweightFrame f = SunToolkit.getLightweightFrame(c); + if (f != null) { + return f.createDragGestureRecognizer(abstractRecognizerClass, ds, c, srcActions, dgl); + } + DragGestureRecognizer dgr = null; // Create a new mouse drag gesture recognizer if we have a class match: diff --git a/jdk/src/share/classes/sun/awt/LightweightFrame.java b/jdk/src/share/classes/sun/awt/LightweightFrame.java index 85d05924a0e..e1131905500 100644 --- a/jdk/src/share/classes/sun/awt/LightweightFrame.java +++ b/jdk/src/share/classes/sun/awt/LightweightFrame.java @@ -25,6 +25,7 @@ package sun.awt; +import java.awt.Component; import java.awt.Container; import java.awt.Frame; import java.awt.Graphics; @@ -33,6 +34,13 @@ import java.awt.MenuBar; import java.awt.MenuComponent; import java.awt.Rectangle; import java.awt.Toolkit; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.peer.FramePeer; /** @@ -169,4 +177,27 @@ public abstract class LightweightFrame extends Frame { hostW = w; hostH = h; } + + /** + * Create a drag gesture recognizer for the lightweight frame. + */ + public abstract T createDragGestureRecognizer( + Class abstractRecognizerClass, + DragSource ds, Component c, int srcActions, + DragGestureListener dgl); + + /** + * Create a drag source context peer for the lightweight frame. + */ + public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException; + + /** + * Adds a drop target to the lightweight frame. + */ + public abstract void addDropTarget(DropTarget dt); + + /** + * Removes a drop target from the lightweight frame. + */ + public abstract void removeDropTarget(DropTarget dt); } diff --git a/jdk/src/share/classes/sun/awt/SunToolkit.java b/jdk/src/share/classes/sun/awt/SunToolkit.java index d98cbf8e6c2..29f8c297717 100644 --- a/jdk/src/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/share/classes/sun/awt/SunToolkit.java @@ -2014,6 +2014,19 @@ public abstract class SunToolkit extends Toolkit return isInstanceOf(cls.getSuperclass(), type); } + protected static LightweightFrame getLightweightFrame(Component c) { + for (; c != null; c = c.getParent()) { + if (c instanceof LightweightFrame) { + return (LightweightFrame)c; + } + if (c instanceof Window) { + // Don't traverse owner windows + return null; + } + } + return null; + } + /////////////////////////////////////////////////////////////////////////// // // The following methods help set and identify whether a particular diff --git a/jdk/src/share/classes/sun/swing/JLightweightFrame.java b/jdk/src/share/classes/sun/swing/JLightweightFrame.java index a3aa2968bec..d41412078eb 100644 --- a/jdk/src/share/classes/sun/swing/JLightweightFrame.java +++ b/jdk/src/share/classes/sun/swing/JLightweightFrame.java @@ -37,6 +37,13 @@ import java.awt.MouseInfo; import java.awt.Point; import java.awt.Rectangle; import java.awt.Window; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import java.awt.image.BufferedImage; @@ -472,4 +479,27 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan content.setCursor(target.getCursor()); } } + + public T createDragGestureRecognizer( + Class abstractRecognizerClass, + DragSource ds, Component c, int srcActions, + DragGestureListener dgl) + { + return content == null ? null : content.createDragGestureRecognizer( + abstractRecognizerClass, ds, c, srcActions, dgl); + } + + public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { + return content == null ? null : content.createDragSourceContextPeer(dge); + } + + public void addDropTarget(DropTarget dt) { + if (content == null) return; + content.addDropTarget(dt); + } + + public void removeDropTarget(DropTarget dt) { + if (content == null) return; + content.removeDropTarget(dt); + } } diff --git a/jdk/src/share/classes/sun/swing/LightweightContent.java b/jdk/src/share/classes/sun/swing/LightweightContent.java index 2296a173f57..d90d43f5d62 100644 --- a/jdk/src/share/classes/sun/swing/LightweightContent.java +++ b/jdk/src/share/classes/sun/swing/LightweightContent.java @@ -26,7 +26,15 @@ package sun.swing; import javax.swing.JComponent; +import java.awt.Component; import java.awt.Cursor; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragGestureRecognizer; +import java.awt.dnd.DragSource; +import java.awt.dnd.DropTarget; +import java.awt.dnd.InvalidDnDOperationException; +import java.awt.dnd.peer.DragSourceContextPeer; /** * The interface by means of which the {@link JLightweightFrame} class @@ -209,4 +217,33 @@ public interface LightweightContent { * @param cursor a cursor to set */ default public void setCursor(Cursor cursor) { } + + /** + * Create a drag gesture recognizer for the lightweight frame. + */ + default public T createDragGestureRecognizer( + Class abstractRecognizerClass, + DragSource ds, Component c, int srcActions, + DragGestureListener dgl) + { + return null; + } + + /** + * Create a drag source context peer for the lightweight frame. + */ + default public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException + { + return null; + } + + /** + * Adds a drop target to the lightweight frame. + */ + default public void addDropTarget(DropTarget dt) {} + + /** + * Removes a drop target from the lightweight frame. + */ + default public void removeDropTarget(DropTarget dt) {} } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java b/jdk/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java index 49d48c806ae..05e7573a392 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XLightweightFramePeer.java @@ -26,6 +26,7 @@ package sun.awt.X11; import java.awt.Graphics; +import java.awt.dnd.DropTarget; import sun.awt.LightweightFrame; import sun.swing.JLightweightFrame; @@ -69,4 +70,14 @@ public class XLightweightFramePeer extends XFramePeer { public void updateCursorImmediately() { SwingAccessor.getJLightweightFrameAccessor().updateCursor((JLightweightFrame)getLwTarget()); } + + @Override + public void addDropTarget(DropTarget dt) { + getLwTarget().addDropTarget(dt); + } + + @Override + public void removeDropTarget(DropTarget dt) { + getLwTarget().removeDropTarget(dt); + } } diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java index 390a3c6d9a3..4ed9439bb03 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java @@ -927,6 +927,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable { } public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { + final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent()); + if (f != null) { + return f.createDragSourceContextPeer(dge); + } + return XDragSourceContextPeer.createDragSourceContextPeer(dge); } @@ -938,6 +943,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable { int srcActions, DragGestureListener dgl) { + final LightweightFrame f = SunToolkit.getLightweightFrame(c); + if (f != null) { + return f.createDragGestureRecognizer(recognizerClass, ds, c, srcActions, dgl); + } + if (MouseDragGestureRecognizer.class.equals(recognizerClass)) return (T)new XMouseDragGestureRecognizer(ds, c, srcActions, dgl); else diff --git a/jdk/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java b/jdk/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java index 28f009a4c02..a84aa49d96a 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java +++ b/jdk/src/windows/classes/sun/awt/windows/WLightweightFramePeer.java @@ -27,6 +27,7 @@ package sun.awt.windows; import java.awt.Component; import java.awt.Graphics; +import java.awt.dnd.DropTarget; import java.awt.event.ComponentEvent; import java.awt.event.MouseEvent; @@ -94,4 +95,14 @@ public class WLightweightFramePeer extends WFramePeer { public boolean isLightweightFramePeer() { return true; } + + @Override + public void addDropTarget(DropTarget dt) { + getLwTarget().addDropTarget(dt); + } + + @Override + public void removeDropTarget(DropTarget dt) { + getLwTarget().removeDropTarget(dt); + } } diff --git a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java index cdccc81849b..efd8517a9f7 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java +++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java @@ -844,6 +844,11 @@ public final class WToolkit extends SunToolkit implements Runnable { @Override public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { + final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent()); + if (f != null) { + return f.createDragSourceContextPeer(dge); + } + return WDragSourceContextPeer.createDragSourceContextPeer(dge); } @@ -854,6 +859,11 @@ public final class WToolkit extends SunToolkit implements Runnable { DragSource ds, Component c, int srcActions, DragGestureListener dgl) { + final LightweightFrame f = SunToolkit.getLightweightFrame(c); + if (f != null) { + return f.createDragGestureRecognizer(abstractRecognizerClass, ds, c, srcActions, dgl); + } + if (MouseDragGestureRecognizer.class.equals(abstractRecognizerClass)) return (T)new WMouseDragGestureRecognizer(ds, c, srcActions, dgl); else