1 /*
2 * Copyright (c) 2011, 2012, 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 <JavaNativeFoundation/JavaNativeFoundation.h>
27
28 #import "AWTSurfaceLayers.h"
29
30 JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo
31 (JAWT_DrawingSurface* ds)
32 {
33 JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*)malloc(sizeof(JAWT_DrawingSurfaceInfo));
34
35 JNIEnv *env = ds->env;
36 jobject target = ds->target;
37
38 static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
39 static JNF_MEMBER_CACHE(jf_peer, jc_Component, "peer", "Ljava/awt/peer/ComponentPeer;");
40 jobject peer = JNFGetObjectField(env, target, jf_peer);
41
42 static JNF_CLASS_CACHE(jc_ComponentPeer, "sun/lwawt/LWComponentPeer");
43 static JNF_MEMBER_CACHE(jf_platformComponent, jc_ComponentPeer,
44 "platformComponent", "Lsun/lwawt/PlatformComponent;");
45 jobject platformComponent = JNFGetObjectField(env, peer, jf_platformComponent);
46
47 static JNF_CLASS_CACHE(jc_PlatformComponent, "sun/lwawt/macosx/CPlatformComponent");
48 static JNF_MEMBER_CACHE(jm_getPointer, jc_PlatformComponent, "getPointer", "()J");
49 AWTSurfaceLayers *surfaceLayers = jlong_to_ptr(JNFCallLongMethod(env, platformComponent, jm_getPointer));
113 }
114
115 JNIEXPORT void JNICALL awt_Lock
116 (JNIEnv* env)
117 {
118 // TODO: implement
119 }
120
121 JNIEXPORT void JNICALL awt_Unlock
122 (JNIEnv* env)
123 {
124 // TODO: implement
125 }
126
127 JNIEXPORT jobject JNICALL awt_GetComponent
128 (JNIEnv* env, void* platformInfo)
129 {
130 // TODO: implement
131 return NULL;
132 }
|
1 /*
2 * Copyright (c) 2011, 2016, 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 <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));
115 }
116
117 JNIEXPORT void JNICALL awt_Lock
118 (JNIEnv* env)
119 {
120 // TODO: implement
121 }
122
123 JNIEXPORT void JNICALL awt_Unlock
124 (JNIEnv* env)
125 {
126 // TODO: implement
127 }
128
129 JNIEXPORT jobject JNICALL awt_GetComponent
130 (JNIEnv* env, void* platformInfo)
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 }
|