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 <JavaNativeFoundation/JavaNativeFoundation.h>
27
28 #import "AWTSurfaceLayers.h"
29
30 #import "jni_util.h"
31
32 JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo
33 (JAWT_DrawingSurface* ds)
34 {
35 JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*)malloc(sizeof(JAWT_DrawingSurfaceInfo));
36
37 JNIEnv *env = ds->env;
38 jobject target = ds->target;
39
40 static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
41 static JNF_MEMBER_CACHE(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;");
42 jobject peer = JNFGetObjectField(env, target, jf_peer);
43
44 static JNF_CLASS_CACHE(jc_ComponentPeer, "sun/lwawt/LWComponentPeer");
45 static JNF_MEMBER_CACHE(jf_platformComponent, jc_ComponentPeer,
46 "platformComponent", "Lsun/lwawt/PlatformComponent;");
47 jobject platformComponent = JNFGetObjectField(env, peer, jf_platformComponent);
48
49 static JNF_CLASS_CACHE(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent");
50 static JNF_MEMBER_CACHE(jm_getPointer, jc_PlatformComponent, "getPointer", "()J");
51 AWTSurfaceLayers *surfaceLayers = jlong_to_ptr(JNFCallLongMethod(env, platformComponent, jm_getPointer));
52 // REMIND: assert(surfaceLayers)
53
54 dsi->platformInfo = surfaceLayers;
55 dsi->ds = ds;
56
57 static JNF_MEMBER_CACHE(jf_x, jc_Component, "x", "I");
58 static JNF_MEMBER_CACHE(jf_y, jc_Component, "y", "I");
59 static JNF_MEMBER_CACHE(jf_width, jc_Component, "width", "I");
60 static JNF_MEMBER_CACHE(jf_height, jc_Component, "height", "I");
61
62 dsi->bounds.x = JNFGetIntField(env, target, jf_x);
63 dsi->bounds.y = JNFGetIntField(env, target, jf_y);
64 dsi->bounds.width = JNFGetIntField(env, target, jf_width);
65 dsi->bounds.height = JNFGetIntField(env, target, jf_height);
66
67 dsi->clipSize = 1;
68 dsi->clip = &(dsi->bounds);
69
70 return dsi;
71 }
72
73 JNIEXPORT jint JNICALL awt_DrawingSurface_Lock
74 (JAWT_DrawingSurface* ds)
75 {
76 // TODO: implement
77 return 0;
78 }
79
80 JNIEXPORT void JNICALL awt_DrawingSurface_Unlock
81 (JAWT_DrawingSurface* ds)
82 {
83 // TODO: implement
84 }
85
131 {
132 // TODO: implement
133 return NULL;
134 }
135
136 // EmbeddedFrame support
137
138 static char *const embeddedClassName = "sun/lwawt/macosx/CViewEmbeddedFrame";
139
140 JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
141 (JNIEnv* env, void* platformInfo)
142 {
143 static jmethodID mid = NULL;
144 static jclass cls;
145 if (mid == NULL) {
146 cls = (*env)->FindClass(env, embeddedClassName);
147 CHECK_NULL_RETURN(cls, NULL);
148 mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V");
149 CHECK_NULL_RETURN(mid, NULL);
150 }
151 return (*env)->NewObject(env, cls, mid, platformInfo);
152 }
153
154 JNIEXPORT void JNICALL awt_SetBounds
155 (JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h)
156 {
157 static jmethodID mid = NULL;
158 if (mid == NULL) {
159 jclass cls = (*env)->FindClass(env, embeddedClassName);
160 CHECK_NULL(cls);
161 mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V");
162 CHECK_NULL(mid);
163 }
164 (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h);
165 }
166
167 JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
168 (JNIEnv *env, jobject embeddedFrame, jboolean doActivate)
169 {
170 static jmethodID mid = NULL;
171 if (mid == NULL) {
172 jclass cls = (*env)->FindClass(env, embeddedClassName);
173 CHECK_NULL(cls);
174 mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V");
175 CHECK_NULL(mid);
176 }
177 (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate);
178 }
|
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 "JNIUtilities.h"
27
28 #import "AWTSurfaceLayers.h"
29
30
31 JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo
32 (JAWT_DrawingSurface* ds)
33 {
34 JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*)malloc(sizeof(JAWT_DrawingSurfaceInfo));
35
36 JNIEnv *env = ds->env;
37 jobject target = ds->target;
38
39 DECLARE_CLASS_RETURN(jc_Component, "java/awt/Component", NULL);
40 DECLARE_FIELD_RETURN(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;", NULL);
41 jobject peer = (*env)->GetObjectField(env, target, jf_peer);
42
43 DECLARE_CLASS_RETURN(jc_ComponentPeer, "sun/lwawt/LWComponentPeer", NULL);
44 DECLARE_FIELD_RETURN(jf_platformComponent, jc_ComponentPeer,
45 "platformComponent", "Lsun/lwawt/PlatformComponent;", NULL);
46 jobject platformComponent = (*env)->GetObjectField(env, peer, jf_platformComponent);
47
48 DECLARE_CLASS_RETURN(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent", NULL);
49 DECLARE_METHOD_RETURN(jm_getPointer, jc_PlatformComponent, "getPointer", "()J", NULL);
50 AWTSurfaceLayers *surfaceLayers = jlong_to_ptr((*env)->CallLongMethod(env, platformComponent, jm_getPointer));
51 // REMIND: assert(surfaceLayers)
52
53 dsi->platformInfo = surfaceLayers;
54 dsi->ds = ds;
55
56 DECLARE_FIELD_RETURN(jf_x, jc_Component, "x", "I", NULL);
57 DECLARE_FIELD_RETURN(jf_y, jc_Component, "y", "I", NULL);
58 DECLARE_FIELD_RETURN(jf_width, jc_Component, "width", "I", NULL);
59 DECLARE_FIELD_RETURN(jf_height, jc_Component, "height", "I", NULL);
60
61 dsi->bounds.x = (*env)->GetIntField(env, target, jf_x);
62 dsi->bounds.y = (*env)->GetIntField(env, target, jf_y);
63 dsi->bounds.width = (*env)->GetIntField(env, target, jf_width);
64 dsi->bounds.height = (*env)->GetIntField(env, target, jf_height);
65
66 dsi->clipSize = 1;
67 dsi->clip = &(dsi->bounds);
68
69 return dsi;
70 }
71
72 JNIEXPORT jint JNICALL awt_DrawingSurface_Lock
73 (JAWT_DrawingSurface* ds)
74 {
75 // TODO: implement
76 return 0;
77 }
78
79 JNIEXPORT void JNICALL awt_DrawingSurface_Unlock
80 (JAWT_DrawingSurface* ds)
81 {
82 // TODO: implement
83 }
84
130 {
131 // TODO: implement
132 return NULL;
133 }
134
135 // EmbeddedFrame support
136
137 static char *const embeddedClassName = "sun/lwawt/macosx/CViewEmbeddedFrame";
138
139 JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
140 (JNIEnv* env, void* platformInfo)
141 {
142 static jmethodID mid = NULL;
143 static jclass cls;
144 if (mid == NULL) {
145 cls = (*env)->FindClass(env, embeddedClassName);
146 CHECK_NULL_RETURN(cls, NULL);
147 mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V");
148 CHECK_NULL_RETURN(mid, NULL);
149 }
150 jobject o = (*env)->NewObject(env, cls, mid, platformInfo);
151 CHECK_EXCEPTION();
152 return o;
153 }
154
155 JNIEXPORT void JNICALL awt_SetBounds
156 (JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h)
157 {
158 static jmethodID mid = NULL;
159 if (mid == NULL) {
160 jclass cls = (*env)->FindClass(env, embeddedClassName);
161 CHECK_NULL(cls);
162 mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V");
163 CHECK_NULL(mid);
164 }
165 (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h);
166 CHECK_EXCEPTION();
167 }
168
169 JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
170 (JNIEnv *env, jobject embeddedFrame, jboolean doActivate)
171 {
172 static jmethodID mid = NULL;
173 if (mid == NULL) {
174 jclass cls = (*env)->FindClass(env, embeddedClassName);
175 CHECK_NULL(cls);
176 mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V");
177 CHECK_NULL(mid);
178 }
179 (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate);
180 CHECK_EXCEPTION();
181 }
|