17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #import "sun_lwawt_macosx_CDragSourceContextPeer.h" 27 28 #import <JavaNativeFoundation/JavaNativeFoundation.h> 29 30 #import "CDragSource.h" 31 #import "ThreadUtilities.h" 32 33 34 /* 35 * Class: sun_lwawt_macosx_CDragSourceContextPeer 36 * Method: createNativeDragSource 37 * Signature: (Ljava/awt/Component;Ljava/awt/peer/ComponentPeer;JLjava/awt/datatransfer/Transferable;Ljava/awt/event/InputEvent;IIIIJLjava/awt/Cursor;IJIII[JLjava/util/Map;)J 38 */ 39 JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource 40 (JNIEnv *env, jobject jthis, jobject jcomponent, jobject jpeer, jlong jnativepeer, jobject jtransferable, 41 jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp, 42 jobject jcursor, jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety, 43 jint jsourceactions, jlongArray jformats, jobject jformatmap) 44 { 45 id controlObj = (id) jlong_to_ptr(jnativepeer); 46 __block CDragSource* dragSource = nil; 47 48 JNF_COCOA_ENTER(env); 49 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ 50 dragSource = [[CDragSource alloc] init:jthis component:jcomponent peer:jpeer control:controlObj 51 transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx 52 dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp 53 cursor:jcursor dragImage:jnsdragimage dragImageOffsetX:jdragimageoffsetx 54 dragImageOffsetY:jdragimageoffsety sourceActions:jsourceactions 55 formats:jformats formatMap:jformatmap]; 56 }]; 57 JNF_COCOA_EXIT(env); 58 59 if (dragSource) { 60 CFRetain(dragSource); // GC 61 [dragSource release]; 62 } 63 return ptr_to_jlong(dragSource); 64 } 65 66 /* 67 * Class: sun_lwawt_macosx_CDragSourceContextPeer 68 * Method: doDragging 69 * Signature: (J)V 70 */ 71 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_doDragging 72 (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal) 73 { 74 AWT_ASSERT_NOT_APPKIT_THREAD; 75 77 78 JNF_COCOA_ENTER(env); 79 [dragSource drag]; 80 JNF_COCOA_EXIT(env); 81 } 82 83 /* 84 * Class: sun_lwawt_macosx_CDragSourceContextPeer 85 * Method: releaseNativeDragSource 86 * Signature: (J)V 87 */ 88 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_releaseNativeDragSource 89 (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal) 90 { 91 CDragSource* dragSource = (CDragSource*) jlong_to_ptr(nativeDragSourceVal); 92 93 JNF_COCOA_ENTER(env); 94 [dragSource removeFromView:env]; 95 JNF_COCOA_EXIT(env); 96 } 97 98 /* 99 * Class: sun_lwawt_macosx_CDragSourceContextPeer 100 * Method: setNativeCursor 101 * Signature: (JLjava/awt/Cursor;I)V 102 */ 103 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_setNativeCursor 104 (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal, jobject jcursor, jint jcursortype) 105 { 106 //AWT_ASSERT_NOT_APPKIT_THREAD; 107 108 //JNF_COCOA_ENTER(env); 109 // jobject gCursor = JNFNewGlobalRef(env, jcursor); 110 // [EventFactory setJavaCursor:gCursor withEnv:env]; 111 //JNF_COCOA_EXIT(env); 112 } | 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #import "sun_lwawt_macosx_CDragSourceContextPeer.h" 27 28 #import <JavaNativeFoundation/JavaNativeFoundation.h> 29 30 #import "CDragSource.h" 31 #import "ThreadUtilities.h" 32 33 34 /* 35 * Class: sun_lwawt_macosx_CDragSourceContextPeer 36 * Method: createNativeDragSource 37 * Signature: (Ljava/awt/Component;JLjava/awt/datatransfer/Transferable; 38 Ljava/awt/event/InputEvent;IIIIJIJIII[JLjava/util/Map;)J 39 */ 40 JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_createNativeDragSource 41 (JNIEnv *env, jobject jthis, jobject jcomponent, jlong jnativepeer, jobject jtransferable, 42 jobject jtrigger, jint jdragposx, jint jdragposy, jint jextmodifiers, jint jclickcount, jlong jtimestamp, 43 jobject jnsdragimage, jint jdragimageoffsetx, jint jdragimageoffsety, 44 jint jsourceactions, jlongArray jformats, jobject jformatmap) 45 { 46 id controlObj = (id) jlong_to_ptr(jnativepeer); 47 __block CDragSource* dragSource = nil; 48 49 JNF_COCOA_ENTER(env); 50 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ 51 dragSource = [[CDragSource alloc] init:jthis 52 component:jcomponent 53 control:controlObj 54 transferable:jtransferable 55 triggerEvent:jtrigger 56 dragPosX:jdragposx 57 dragPosY:jdragposy 58 modifiers:jextmodifiers 59 clickCount:jclickcount 60 timeStamp:jtimestamp 61 dragImage:jnsdragimage 62 dragImageOffsetX:jdragimageoffsetx 63 dragImageOffsetY:jdragimageoffsety 64 sourceActions:jsourceactions 65 formats:jformats 66 formatMap:jformatmap]; 67 }]; 68 JNF_COCOA_EXIT(env); 69 70 if (dragSource) { 71 CFRetain(dragSource); // GC 72 [dragSource release]; 73 } 74 return ptr_to_jlong(dragSource); 75 } 76 77 /* 78 * Class: sun_lwawt_macosx_CDragSourceContextPeer 79 * Method: doDragging 80 * Signature: (J)V 81 */ 82 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_doDragging 83 (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal) 84 { 85 AWT_ASSERT_NOT_APPKIT_THREAD; 86 88 89 JNF_COCOA_ENTER(env); 90 [dragSource drag]; 91 JNF_COCOA_EXIT(env); 92 } 93 94 /* 95 * Class: sun_lwawt_macosx_CDragSourceContextPeer 96 * Method: releaseNativeDragSource 97 * Signature: (J)V 98 */ 99 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_releaseNativeDragSource 100 (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal) 101 { 102 CDragSource* dragSource = (CDragSource*) jlong_to_ptr(nativeDragSourceVal); 103 104 JNF_COCOA_ENTER(env); 105 [dragSource removeFromView:env]; 106 JNF_COCOA_EXIT(env); 107 } |