38
38
#import " DnDUtilities.h"
39
39
#import " ThreadUtilities.h"
40
40
#import " LWCToolkit.h"
41
+ #import " JNIUtilities.h"
41
42
42
43
43
44
// When sIsJavaDragging is true Java drag gesture has been recognized and a drag is/has been initialized.
@@ -69,9 +70,17 @@ + (void)javaDraggingEnd
69
70
}
70
71
@end
71
72
72
- JNF_CLASS_CACHE (DataTransfererClass, " sun/awt/datatransfer/DataTransferer" );
73
- JNF_CLASS_CACHE (CDragSourceContextPeerClass, " sun/lwawt/macosx/CDragSourceContextPeer" );
74
- JNF_CLASS_CACHE (CImageClass, " sun/lwawt/macosx/CImage" );
73
+ static jclass DataTransfererClass = NULL ;
74
+ static jclass CDragSourceContextPeerClass = NULL ;
75
+
76
+ #define GET_DT_CLASS () \
77
+ GET_CLASS (DataTransfererClass, " sun/awt/datatransfer/DataTransferer" );
78
+
79
+ #define GET_DT_CLASS_RETURN (ret ) \
80
+ GET_CLASS_RETURN (DataTransfererClass, " sun/awt/datatransfer/DataTransferer" , ret);
81
+
82
+ #define GET_DSCP_CLASS () \
83
+ GET_CLASS (CDragSourceContextPeerClass, " sun/lwawt/macosx/CDragSourceContextPeer" );
75
84
76
85
static NSDragOperation sDragOperation ;
77
86
static NSPoint sDraggingLocation ;
@@ -212,8 +221,11 @@ - (void)dealloc
212
221
//
213
222
- (jobject)dataTransferer : (JNIEnv*)env
214
223
{
215
- JNF_STATIC_MEMBER_CACHE (getInstanceMethod, DataTransfererClass, " getInstance" , " ()Lsun/awt/datatransfer/DataTransferer;" );
216
- return JNFCallStaticObjectMethod (env, getInstanceMethod);
224
+ GET_DT_CLASS_RETURN (NULL );
225
+ DECLARE_STATIC_METHOD_RETURN (getInstanceMethod, DataTransfererClass, " getInstance" , " ()Lsun/awt/datatransfer/DataTransferer;" , NULL );
226
+ jobject o = (*env)->CallStaticObjectMethod (env, DataTransfererClass, getInstanceMethod);
227
+ CHECK_EXCEPTION ();
228
+ return o;
217
229
}
218
230
219
231
// Appropriated from Windows' awt_DataTransferer.cpp:
@@ -227,9 +239,11 @@ - (jbyteArray)convertData:(jlong)format
227
239
jbyteArray data = nil ;
228
240
229
241
if (transferer != NULL ) {
230
- JNF_MEMBER_CACHE (convertDataMethod, DataTransfererClass, " convertData" , " (Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;JLjava/util/Map;Z)[B" );
231
- data = JNFCallObjectMethod (env, transferer, convertDataMethod, fComponent, fTransferable, format, fFormatMap, (jboolean) TRUE );
242
+ GET_DT_CLASS_RETURN (NULL );
243
+ DECLARE_METHOD_RETURN (convertDataMethod, DataTransfererClass, " convertData" , " (Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;JLjava/util/Map;Z)[B" , NULL );
244
+ data = (*env)->CallObjectMethod (env, transferer, convertDataMethod, fComponent, fTransferable, format, fFormatMap, (jboolean) TRUE );
232
245
}
246
+ CHECK_EXCEPTION ();
233
247
234
248
return data;
235
249
}
@@ -555,11 +569,14 @@ - (void)doDrag
555
569
}
556
570
557
571
// DragSourceContextPeer.dragDropFinished() should be called even if there was an error:
558
- JNF_MEMBER_CACHE (dragDropFinishedMethod, CDragSourceContextPeerClass, " dragDropFinished" , " (ZIII)V" );
572
+ GET_DSCP_CLASS ();
573
+ DECLARE_METHOD (dragDropFinishedMethod, CDragSourceContextPeerClass, " dragDropFinished" , " (ZIII)V" );
559
574
DLog3 (@" -> posting dragDropFinished, point %f , %f " , point.x , point.y );
560
- JNFCallVoidMethod (env, fDragSourceContextPeer, dragDropFinishedMethod, success, dragOp, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
561
- JNF_MEMBER_CACHE (resetHoveringMethod, CDragSourceContextPeerClass, " resetHovering" , " ()V" );
562
- JNFCallVoidMethod (env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable
575
+ (*env)->CallVoidMethod (env, fDragSourceContextPeer, dragDropFinishedMethod, success, dragOp, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
576
+ CHECK_EXCEPTION ();
577
+ DECLARE_METHOD (resetHoveringMethod, CDragSourceContextPeerClass, " resetHovering" , " ()V" );
578
+ (*env)->CallVoidMethod (env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable
579
+ CHECK_EXCEPTION ();
563
580
} @finally {
564
581
sNeedsEnter = NO ;
565
582
AWTToolkit.inDoDragDropLoop = NO ;
@@ -594,8 +611,10 @@ - (void)draggingOperationChanged:(NSDragOperation)dragOp {
594
611
DLog3 (@" -> posting operationChanged, point %f , %f " , point.x , point.y );
595
612
jint modifiedModifiers = fDragKeyModifiers | fDragMouseModifiers | [DnDUtilities javaKeyModifiersForNSDragOperation: dragOp];
596
613
597
- JNF_MEMBER_CACHE (operationChangedMethod, CDragSourceContextPeerClass, " operationChanged" , " (IIII)V" );
598
- JNFCallVoidMethod (env, fDragSourceContextPeer, operationChangedMethod, targetActions, modifiedModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
614
+ GET_DSCP_CLASS ();
615
+ DECLARE_METHOD (operationChangedMethod, CDragSourceContextPeerClass, " operationChanged" , " (IIII)V" );
616
+ (*env)->CallVoidMethod (env, fDragSourceContextPeer, operationChangedMethod, targetActions, modifiedModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
617
+ CHECK_EXCEPTION ();
599
618
}
600
619
601
620
- (NSDragOperation )draggingSourceOperationMaskForLocal : (BOOL )localDrag {
@@ -667,12 +686,14 @@ - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint {
667
686
DLog4 (@" [CDragSource draggedImage moved]: (%f , %f ) %@ \n " , screenPoint.x , screenPoint.y , self);
668
687
669
688
DLog3 (@" -> posting dragMotion, point %f , %f " , point.x , point.y );
670
- JNF_MEMBER_CACHE (dragMotionMethod, CDragSourceContextPeerClass, " dragMotion" , " (IIII)V" );
671
- JNFCallVoidMethod (env, fDragSourceContextPeer, dragMotionMethod, targetActions, (jint) fModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
672
-
689
+ GET_DSCP_CLASS ();
690
+ DECLARE_METHOD (dragMotionMethod, CDragSourceContextPeerClass, " dragMotion" , " (IIII)V" );
691
+ (*env)->CallVoidMethod (env, fDragSourceContextPeer, dragMotionMethod, targetActions, (jint) fModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
692
+ CHECK_EXCEPTION ();
673
693
DLog3 (@" -> posting dragMouseMoved, point %f , %f " , point.x , point.y );
674
- JNF_MEMBER_CACHE (dragMouseMovedMethod, CDragSourceContextPeerClass, " dragMouseMoved" , " (IIII)V" );
675
- JNFCallVoidMethod (env, fDragSourceContextPeer, dragMouseMovedMethod, targetActions, (jint) fModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
694
+ DECLARE_METHOD (dragMouseMovedMethod, CDragSourceContextPeerClass, " dragMouseMoved" , " (IIII)V" );
695
+ (*env)->CallVoidMethod (env, fDragSourceContextPeer, dragMouseMovedMethod, targetActions, (jint) fModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
696
+ CHECK_EXCEPTION ();
676
697
}
677
698
JNF_COCOA_EXIT (env);
678
699
}
@@ -696,8 +717,10 @@ - (void) postDragEnter {
696
717
697
718
NSPoint point = [self mapNSScreenPointToJavaWithOffset: sDraggingLocation ];
698
719
DLog3 (@" -> posting dragEnter, point %f , %f " , point.x , point.y );
699
- JNF_MEMBER_CACHE (dragEnterMethod, CDragSourceContextPeerClass, " dragEnter" , " (IIII)V" );
700
- JNFCallVoidMethod (env, fDragSourceContextPeer, dragEnterMethod, targetActions, (jint) fModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
720
+ GET_DSCP_CLASS ();
721
+ DECLARE_METHOD (dragEnterMethod, CDragSourceContextPeerClass, " dragEnter" , " (IIII)V" );
722
+ (*env)->CallVoidMethod (env, fDragSourceContextPeer, dragEnterMethod, targetActions, (jint) fModifiers, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
723
+ CHECK_EXCEPTION ();
701
724
}
702
725
703
726
- (void ) postDragExit {
@@ -706,8 +729,11 @@ - (void) postDragExit {
706
729
707
730
NSPoint point = [self mapNSScreenPointToJavaWithOffset: sDraggingLocation ];
708
731
DLog3 (@" -> posting dragExit, point %f , %f " , point.x , point.y );
709
- JNF_MEMBER_CACHE (dragExitMethod, CDragSourceContextPeerClass, " dragExit" , " (II)V" );
710
- JNFCallVoidMethod (env, fDragSourceContextPeer, dragExitMethod, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
732
+ GET_DSCP_CLASS ();
733
+ DECLARE_METHOD (dragExitMethod, CDragSourceContextPeerClass, " dragExit" , " (II)V" );
734
+ (*env)->CallVoidMethod (env, fDragSourceContextPeer, dragExitMethod, (jint) point.x , (jint) point.y ); // AWT_THREADING Safe (event)
735
+ CHECK_EXCEPTION ();
736
+
711
737
}
712
738
713
739
1 commit comments
openjdk-notifier[bot] commentedon Apr 8, 2021
Review
Issues