From 67e1ed4f5daa9104f8dcb1ae1e35e8e78c6aeb65 Mon Sep 17 00:00:00 2001 From: duncanmcqueen Date: Wed, 14 Oct 2026 15:06:57 -0500 Subject: [PATCH] DropTargetContext: get the target actions from the peer getTargetActions() returned a field that only setTargetActions() set, and nothing calls setTargetActions() during a drag. Thus the field was 0, and DropTargetDragEvent.getDropAction(), which masks the drop action with the target actions, always returned ACTION_NONE. As in the JDK, remove the field and keep the actions in the DropTarget. getTargetActions() asks the peer, or returns the default actions of the drop target when there is no peer. setTargetActions() gives the actions to the peer, if there is one, and to the drop target. Also, as in the JDK, DropTargetDragEvent.getDropAction() now returns the drop action as given. The peer must limit the drop action to the target actions. DropTargetDropEvent.getDropAction() already did this. Co-Authored-By: Claude Opus 5.5 Signed-off-by: duncanmcqueen --- java/awt/dnd/DropTargetContext.java | 11 ++++++++--- java/awt/dnd/DropTargetDragEvent.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/java/awt/dnd/DropTargetContext.java b/java/awt/dnd/DropTargetContext.java index 4c21a6e8ad..d56b894022 100644 --- a/java/awt/dnd/DropTargetContext.java +++ b/java/awt/dnd/DropTargetContext.java @@ -85,7 +85,6 @@ public Object getTransferData(DataFlavor flavor) } private DropTarget dropTarget; - private int targetActions; private DropTargetContextPeer dtcp; // package private @@ -116,12 +115,18 @@ public void removeNotify() protected void setTargetActions(int actions) { - targetActions = actions; + if (dtcp != null) + dtcp.setTargetActions(actions); + dropTarget.setDefaultActions(actions); } protected int getTargetActions() { - return targetActions; + // As in the JDK, the peer knows the actions; without one, use the + // drop target's default actions. + if (dtcp != null) + return dtcp.getTargetActions(); + return dropTarget.getDefaultActions(); } /** diff --git a/java/awt/dnd/DropTargetDragEvent.java b/java/awt/dnd/DropTargetDragEvent.java index 21c9e2b35c..d258ba57ee 100644 --- a/java/awt/dnd/DropTargetDragEvent.java +++ b/java/awt/dnd/DropTargetDragEvent.java @@ -115,7 +115,7 @@ public List getCurrentDataFlavorsAsList () public int getDropAction() { - return dropAction & ((DropTargetContext) source).getTargetActions(); + return dropAction; } public Point getLocation ()