提交 da96d0ce 编写于 作者: K kizune

7161109: [macosx] JCK AWT interactive test DnDTextDropTest fails on MacOS

Reviewed-by: serb
上级 430f1bd4
...@@ -985,16 +985,23 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -985,16 +985,23 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
// DropTargetPeer Method // DropTargetPeer Method
@Override @Override
public void addDropTarget(DropTarget dt) { public void addDropTarget(DropTarget dt) {
synchronized (dropTargetLock){ LWWindowPeer winPeer = getWindowPeerOrSelf();
// 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only if (winPeer != null && winPeer != this) {
// if it's the first (or last) one for the component. Otherwise this call is a no-op. // We need to register the DropTarget in the
if (++fNumDropTargets == 1) { // peer of the window ancestor of the component
// Having a non-null drop target would be an error but let's check just in case: winPeer.addDropTarget(dt);
if (fDropTarget != null) } else {
System.err.println("CComponent.addDropTarget(): current drop target is non-null."); synchronized (dropTargetLock) {
// 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
// Create a new drop target: // if it's the first (or last) one for the component. Otherwise this call is a no-op.
fDropTarget = CDropTarget.createDropTarget(dt, target, this); if (++fNumDropTargets == 1) {
// Having a non-null drop target would be an error but let's check just in case:
if (fDropTarget != null)
System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
// Create a new drop target:
fDropTarget = CDropTarget.createDropTarget(dt, target, this);
}
} }
} }
} }
...@@ -1002,17 +1009,24 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent> ...@@ -1002,17 +1009,24 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
// DropTargetPeer Method // DropTargetPeer Method
@Override @Override
public void removeDropTarget(DropTarget dt) { public void removeDropTarget(DropTarget dt) {
synchronized (dropTargetLock){ LWWindowPeer winPeer = getWindowPeerOrSelf();
// 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only if (winPeer != null && winPeer != this) {
// if it's the first (or last) one for the component. Otherwise this call is a no-op. // We need to unregister the DropTarget in the
if (--fNumDropTargets == 0) { // peer of the window ancestor of the component
// Having a null drop target would be an error but let's check just in case: winPeer.removeDropTarget(dt);
if (fDropTarget != null) { } else {
// Dispose of the drop target: synchronized (dropTargetLock){
fDropTarget.dispose(); // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
fDropTarget = null; // if it's the first (or last) one for the component. Otherwise this call is a no-op.
} else if (--fNumDropTargets == 0) {
System.err.println("CComponent.removeDropTarget(): current drop target is null."); // Having a null drop target would be an error but let's check just in case:
if (fDropTarget != null) {
// Dispose of the drop target:
fDropTarget.dispose();
fDropTarget = null;
} else
System.err.println("CComponent.removeDropTarget(): current drop target is null.");
}
} }
} }
} }
......
...@@ -648,6 +648,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer; ...@@ -648,6 +648,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
if (sDraggingError == FALSE) { if (sDraggingError == FALSE) {
sDraggingLocation = [sender draggingLocation]; sDraggingLocation = [sender draggingLocation];
NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil]; NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil];
// The y coordinate that comes in the NSDraggingInfo seems to be reversed - probably
// has to do something with the type of view it comes to.
// This is the earliest place where we can correct it.
javaLocation.y = fView.window.frame.size.height - javaLocation.y;
jint actions = [DnDUtilities mapNSDragOperationMaskToJava:[sender draggingSourceOperationMask]]; jint actions = [DnDUtilities mapNSDragOperationMaskToJava:[sender draggingSourceOperationMask]];
jint dropAction = sJavaDropOperation; jint dropAction = sJavaDropOperation;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册