author | sveerabhadra |
Fri, 22 Dec 2017 11:00:06 +0530 | |
changeset 48640 | 42ad9a781f51 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
40708
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
2 |
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
12047 | 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 |
||
40708
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
30 |
#import "jni_util.h" |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
31 |
|
12047 | 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 |
||
86 |
JNIEXPORT void JNICALL awt_DrawingSurface_FreeDrawingSurfaceInfo |
|
87 |
(JAWT_DrawingSurfaceInfo* dsi) |
|
88 |
{ |
|
89 |
free(dsi); |
|
90 |
} |
|
91 |
||
92 |
JNIEXPORT JAWT_DrawingSurface* JNICALL awt_GetDrawingSurface |
|
93 |
(JNIEnv* env, jobject target) |
|
94 |
{ |
|
95 |
JAWT_DrawingSurface* ds = (JAWT_DrawingSurface*)malloc(sizeof(JAWT_DrawingSurface)); |
|
96 |
||
97 |
// TODO: "target instanceof" check |
|
98 |
||
99 |
ds->env = env; |
|
100 |
ds->target = (*env)->NewGlobalRef(env, target); |
|
101 |
ds->Lock = awt_DrawingSurface_Lock; |
|
102 |
ds->GetDrawingSurfaceInfo = awt_DrawingSurface_GetDrawingSurfaceInfo; |
|
103 |
ds->FreeDrawingSurfaceInfo = awt_DrawingSurface_FreeDrawingSurfaceInfo; |
|
104 |
ds->Unlock = awt_DrawingSurface_Unlock; |
|
105 |
||
106 |
return ds; |
|
107 |
} |
|
108 |
||
109 |
JNIEXPORT void JNICALL awt_FreeDrawingSurface |
|
110 |
(JAWT_DrawingSurface* ds) |
|
111 |
{ |
|
112 |
JNIEnv *env = ds->env; |
|
113 |
(*env)->DeleteGlobalRef(env, ds->target); |
|
114 |
free(ds); |
|
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 |
} |
|
40708
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
135 |
|
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
136 |
// EmbeddedFrame support |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
137 |
|
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
138 |
static char *const embeddedClassName = "sun/lwawt/macosx/CViewEmbeddedFrame"; |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
139 |
|
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
140 |
JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
141 |
(JNIEnv* env, void* platformInfo) |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
142 |
{ |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
143 |
static jmethodID mid = NULL; |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
144 |
static jclass cls; |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
145 |
if (mid == NULL) { |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
146 |
cls = (*env)->FindClass(env, embeddedClassName); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
147 |
CHECK_NULL_RETURN(cls, NULL); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
148 |
mid = (*env)->GetMethodID(env, cls, "<init>", "(J)V"); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
149 |
CHECK_NULL_RETURN(mid, NULL); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
150 |
} |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
151 |
return (*env)->NewObject(env, cls, mid, platformInfo); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
152 |
} |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
153 |
|
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
154 |
JNIEXPORT void JNICALL awt_SetBounds |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
155 |
(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
156 |
{ |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
157 |
static jmethodID mid = NULL; |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
158 |
if (mid == NULL) { |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
159 |
jclass cls = (*env)->FindClass(env, embeddedClassName); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
160 |
CHECK_NULL(cls); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
161 |
mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V"); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
162 |
CHECK_NULL(mid); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
163 |
} |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
164 |
(*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
165 |
} |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
166 |
|
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
167 |
JNIEXPORT void JNICALL awt_SynthesizeWindowActivation |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
168 |
(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
169 |
{ |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
170 |
static jmethodID mid = NULL; |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
171 |
if (mid == NULL) { |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
172 |
jclass cls = (*env)->FindClass(env, embeddedClassName); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
173 |
CHECK_NULL(cls); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
174 |
mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
175 |
CHECK_NULL(mid); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
176 |
} |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
177 |
(*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate); |
2516b180bfc0
8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame
serb
parents:
26751
diff
changeset
|
178 |
} |