460 JNF_STATIC_MEMBER_CACHE(getDropTargetContextPeerMethod, jc_CDropTargetContextPeer, "getDropTargetContextPeer", "()Lsun/lwawt/macosx/CDropTargetContextPeer;");
461 if (sDraggingError == FALSE) {
462 // Create a new drop target context peer:
463 jobject dropTargetContextPeer = JNFCallStaticObjectMethod(env, getDropTargetContextPeerMethod);
464
465 if (dropTargetContextPeer != nil) {
466 fDropTargetContextPeer = JNFNewGlobalRef(env, dropTargetContextPeer);
467 (*env)->DeleteLocalRef(env, dropTargetContextPeer);
468 }
469 }
470
471 // Get dragging types (dragging data is only copied if dropped):
472 if (sDraggingError == FALSE && [self copyDraggingTypes:sender] == FALSE)
473 sDraggingError = TRUE;
474 }
475
476 if (sDraggingError == FALSE) {
477 sDraggingExited = FALSE;
478 sDraggingLocation = [sender draggingLocation];
479 NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil];
480 DLog5(@"+ dragEnter: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y);
481
482 ////////// BEGIN Calculate the current drag actions //////////
483 jint actions = java_awt_dnd_DnDConstants_ACTION_NONE;
484 jint dropAction = actions;
485
486 [self calculateCurrentSourceActions:&actions dropAction:&dropAction];
487
488 sJavaDropOperation = dropAction;
489 ////////// END Calculate the current drag actions //////////
490
491 jlongArray formats = sDraggingFormats;
492
493 JNF_MEMBER_CACHE(handleEnterMessageMethod, jc_CDropTargetContextPeer, "handleEnterMessage", "(Ljava/awt/Component;IIII[JJ)I");
494 if (sDraggingError == FALSE) {
495 // Double-casting self gets rid of 'different size' compiler warning:
496 // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
497 actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod,
498 fComponent, (jint) javaLocation.x, (jint) javaLocation.y,
499 dropAction, actions, formats, ptr_to_jlong(self));
553 }
554
555 // b) drag actions (key modifiers) have changed (handleMotionMessage() will do proper notifications):
556 ////////// BEGIN Calculate the current drag actions //////////
557 jint actions = java_awt_dnd_DnDConstants_ACTION_NONE;
558 jint dropAction = actions;
559
560 [self calculateCurrentSourceActions:&actions dropAction:&dropAction];
561
562 if (sJavaDropOperation != dropAction) {
563 sJavaDropOperation = dropAction;
564 notifyJava = TRUE;
565 }
566 ////////// END Calculate the current drag actions //////////
567
568 jint userAction = dropAction;
569
570 // Should we notify Java things have changed?
571 if (sDraggingError == FALSE && notifyJava) {
572 NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil];
573 // For some reason even after the convertPoint drag events come with the y coordinate reverted
574 javaLocation.y = fView.window.frame.size.height - javaLocation.y;
575 //DLog5(@" : dragMoved: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y);
576
577 jlongArray formats = sDraggingFormats;
578
579 JNF_MEMBER_CACHE(handleMotionMessageMethod, jc_CDropTargetContextPeer, "handleMotionMessage", "(Ljava/awt/Component;IIII[JJ)I");
580 if (sDraggingError == FALSE) {
581 DLog3(@" >> posting handleMotionMessage, point %f, %f", javaLocation.x, javaLocation.y);
582 userAction = JNFCallIntMethod(env, fDropTargetContextPeer, handleMotionMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
583 }
584
585 if (sDraggingError == FALSE) {
586 dragOp = [DnDUtilities mapJavaDragOperationToNS:userAction];
587
588 // Remember the dragOp for no-op'd update messages:
589 sUpdateOperation = dragOp;
590 } else {
591 dragOp = NSDragOperationNone;
592 }
593 }
|
460 JNF_STATIC_MEMBER_CACHE(getDropTargetContextPeerMethod, jc_CDropTargetContextPeer, "getDropTargetContextPeer", "()Lsun/lwawt/macosx/CDropTargetContextPeer;");
461 if (sDraggingError == FALSE) {
462 // Create a new drop target context peer:
463 jobject dropTargetContextPeer = JNFCallStaticObjectMethod(env, getDropTargetContextPeerMethod);
464
465 if (dropTargetContextPeer != nil) {
466 fDropTargetContextPeer = JNFNewGlobalRef(env, dropTargetContextPeer);
467 (*env)->DeleteLocalRef(env, dropTargetContextPeer);
468 }
469 }
470
471 // Get dragging types (dragging data is only copied if dropped):
472 if (sDraggingError == FALSE && [self copyDraggingTypes:sender] == FALSE)
473 sDraggingError = TRUE;
474 }
475
476 if (sDraggingError == FALSE) {
477 sDraggingExited = FALSE;
478 sDraggingLocation = [sender draggingLocation];
479 NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil];
480 javaLocation.y = fView.window.frame.size.height - javaLocation.y;
481
482 DLog5(@"+ dragEnter: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y);
483
484 ////////// BEGIN Calculate the current drag actions //////////
485 jint actions = java_awt_dnd_DnDConstants_ACTION_NONE;
486 jint dropAction = actions;
487
488 [self calculateCurrentSourceActions:&actions dropAction:&dropAction];
489
490 sJavaDropOperation = dropAction;
491 ////////// END Calculate the current drag actions //////////
492
493 jlongArray formats = sDraggingFormats;
494
495 JNF_MEMBER_CACHE(handleEnterMessageMethod, jc_CDropTargetContextPeer, "handleEnterMessage", "(Ljava/awt/Component;IIII[JJ)I");
496 if (sDraggingError == FALSE) {
497 // Double-casting self gets rid of 'different size' compiler warning:
498 // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
499 actions = JNFCallIntMethod(env, fDropTargetContextPeer, handleEnterMessageMethod,
500 fComponent, (jint) javaLocation.x, (jint) javaLocation.y,
501 dropAction, actions, formats, ptr_to_jlong(self));
555 }
556
557 // b) drag actions (key modifiers) have changed (handleMotionMessage() will do proper notifications):
558 ////////// BEGIN Calculate the current drag actions //////////
559 jint actions = java_awt_dnd_DnDConstants_ACTION_NONE;
560 jint dropAction = actions;
561
562 [self calculateCurrentSourceActions:&actions dropAction:&dropAction];
563
564 if (sJavaDropOperation != dropAction) {
565 sJavaDropOperation = dropAction;
566 notifyJava = TRUE;
567 }
568 ////////// END Calculate the current drag actions //////////
569
570 jint userAction = dropAction;
571
572 // Should we notify Java things have changed?
573 if (sDraggingError == FALSE && notifyJava) {
574 NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil];
575 javaLocation.y = fView.window.frame.size.height - javaLocation.y;
576 //DLog5(@" : dragMoved: loc native %f, %f, java %f, %f\n", sDraggingLocation.x, sDraggingLocation.y, javaLocation.x, javaLocation.y);
577
578 jlongArray formats = sDraggingFormats;
579
580 JNF_MEMBER_CACHE(handleMotionMessageMethod, jc_CDropTargetContextPeer, "handleMotionMessage", "(Ljava/awt/Component;IIII[JJ)I");
581 if (sDraggingError == FALSE) {
582 DLog3(@" >> posting handleMotionMessage, point %f, %f", javaLocation.x, javaLocation.y);
583 userAction = JNFCallIntMethod(env, fDropTargetContextPeer, handleMotionMessageMethod, fComponent, (jint) javaLocation.x, (jint) javaLocation.y, dropAction, actions, formats, ptr_to_jlong(self)); // AWT_THREADING Safe (CToolkitThreadBlockedHandler)
584 }
585
586 if (sDraggingError == FALSE) {
587 dragOp = [DnDUtilities mapJavaDragOperationToNS:userAction];
588
589 // Remember the dragOp for no-op'd update messages:
590 sUpdateOperation = dragOp;
591 } else {
592 dragOp = NSDragOperationNone;
593 }
594 }
|