|
1 /* |
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
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, jlong 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 |
|
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 |
|
76 CDragSource* dragSource = (CDragSource*) jlong_to_ptr(nativeDragSourceVal); |
|
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 } |