src/macosx/native/sun/awt/CDragSourceContextPeer.m

Print this page




  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     [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
  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


  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 }


  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


  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 }