author | pchelko |
Thu, 09 Jan 2014 12:47:01 +0400 | |
changeset 23255 | ebd69e3d93c5 |
parent 23253 | 55425a62017f |
child 25196 | 48d9cfe3f138 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
23255
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
23253
diff
changeset
|
2 |
* Copyright (c) 2011, 2014, 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 |
#import "ThreadUtilities.h" |
|
28 |
#import "sun_lwawt_macosx_CWrapper_NSWindow.h" |
|
29 |
||
30 |
/* |
|
31 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
32 |
* Method: makeKeyAndOrderFront |
|
33 |
* Signature: (J)V |
|
34 |
*/ |
|
35 |
JNIEXPORT void JNICALL |
|
36 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeKeyAndOrderFront |
|
37 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
38 |
{ |
|
39 |
JNF_COCOA_ENTER(env); |
|
40 |
||
41 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
42 |
[ThreadUtilities performOnMainThread:@selector(makeKeyAndOrderFront:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
43 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
44 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
45 |
waitUntilDone:NO]; |
12047 | 46 |
|
47 |
JNF_COCOA_EXIT(env); |
|
48 |
} |
|
49 |
||
50 |
/* |
|
51 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
12177
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
52 |
* Method: makeKeyWindow |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
53 |
* Signature: (J)V |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
54 |
*/ |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
55 |
JNIEXPORT void JNICALL |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
56 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeKeyWindow |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
57 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
58 |
{ |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
59 |
JNF_COCOA_ENTER(env); |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
60 |
|
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
61 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
62 |
[ThreadUtilities performOnMainThread:@selector(makeKeyWindow) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
63 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
64 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
65 |
waitUntilDone:NO]; |
12177
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
66 |
|
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
67 |
JNF_COCOA_EXIT(env); |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
68 |
} |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
69 |
|
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
70 |
/* |
7b84ed7d0efa
7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents:
12047
diff
changeset
|
71 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
12047 | 72 |
* Method: makeMainWindow |
73 |
* Signature: (J)V |
|
74 |
*/ |
|
75 |
JNIEXPORT void JNICALL |
|
76 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeMainWindow |
|
77 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
78 |
{ |
|
79 |
JNF_COCOA_ENTER(env); |
|
80 |
||
81 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
82 |
[ThreadUtilities performOnMainThread:@selector(makeMainWindow) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
83 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
84 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
85 |
waitUntilDone:NO]; |
12047 | 86 |
|
87 |
JNF_COCOA_EXIT(env); |
|
88 |
} |
|
89 |
||
90 |
/* |
|
91 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
92 |
* Method: canBecomeMainWindow |
|
93 |
* Signature: (J)V |
|
94 |
*/ |
|
95 |
JNIEXPORT jboolean JNICALL |
|
96 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_canBecomeMainWindow |
|
97 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
98 |
{ |
|
99 |
__block jboolean canBecomeMainWindow = JNI_FALSE; |
|
100 |
||
101 |
JNF_COCOA_ENTER(env); |
|
102 |
||
103 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
104 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
12047 | 105 |
canBecomeMainWindow = [window canBecomeMainWindow]; |
106 |
}]; |
|
107 |
||
108 |
JNF_COCOA_EXIT(env); |
|
109 |
||
110 |
return canBecomeMainWindow; |
|
111 |
} |
|
112 |
||
113 |
/* |
|
114 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
115 |
* Method: isKeyWindow |
|
116 |
* Signature: (J)Z |
|
117 |
*/ |
|
118 |
JNIEXPORT jboolean JNICALL |
|
119 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_isKeyWindow |
|
120 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
121 |
{ |
|
122 |
__block jboolean isKeyWindow = JNI_FALSE; |
|
123 |
||
124 |
JNF_COCOA_ENTER(env); |
|
125 |
||
126 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
127 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
12047 | 128 |
isKeyWindow = [window isKeyWindow]; |
129 |
}]; |
|
130 |
||
131 |
JNF_COCOA_EXIT(env); |
|
132 |
||
133 |
return isKeyWindow; |
|
134 |
} |
|
135 |
||
136 |
/* |
|
137 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
138 |
* Method: orderFront |
|
139 |
* Signature: (J)V |
|
140 |
*/ |
|
141 |
JNIEXPORT void JNICALL |
|
142 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderFront |
|
143 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
144 |
{ |
|
145 |
JNF_COCOA_ENTER(env); |
|
146 |
||
147 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
148 |
[ThreadUtilities performOnMainThread:@selector(orderFront:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
149 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
150 |
withObject:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
151 |
waitUntilDone:NO]; |
12047 | 152 |
|
153 |
JNF_COCOA_EXIT(env); |
|
154 |
} |
|
155 |
||
156 |
/* |
|
157 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
158 |
* Method: orderOut |
|
159 |
* Signature: (J)V |
|
160 |
*/ |
|
161 |
JNIEXPORT void JNICALL |
|
162 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderOut |
|
163 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
164 |
{ |
|
165 |
JNF_COCOA_ENTER(env); |
|
166 |
||
167 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
168 |
[ThreadUtilities performOnMainThread:@selector(orderOut:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
169 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
170 |
withObject:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
171 |
waitUntilDone:NO]; |
12047 | 172 |
|
173 |
JNF_COCOA_EXIT(env); |
|
174 |
} |
|
175 |
||
176 |
/* |
|
177 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
178 |
* Method: orderFrontRegardless |
|
179 |
* Signature: (J)V |
|
180 |
*/ |
|
181 |
JNIEXPORT void JNICALL |
|
182 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderFrontRegardless |
|
183 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
184 |
{ |
|
185 |
JNF_COCOA_ENTER(env); |
|
186 |
||
187 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
188 |
[ThreadUtilities performOnMainThread:@selector(orderFrontRegardless) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
189 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
190 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
191 |
waitUntilDone:NO]; |
12047 | 192 |
|
193 |
JNF_COCOA_EXIT(env); |
|
194 |
} |
|
195 |
||
196 |
/* |
|
197 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
198 |
* Method: orderWindow |
|
199 |
* Signature: (JIJ)V |
|
200 |
*/ |
|
201 |
JNIEXPORT void JNICALL |
|
202 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderWindow |
|
203 |
(JNIEnv *env, jclass cls, jlong windowPtr, jint order, jlong relativeToPtr) |
|
204 |
{ |
|
205 |
JNF_COCOA_ENTER(env); |
|
206 |
||
207 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
208 |
NSWindow *relativeTo = (NSWindow *)jlong_to_ptr(relativeToPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
209 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
12047 | 210 |
[window orderWindow:(NSWindowOrderingMode)order relativeTo:[relativeTo windowNumber]]; |
211 |
}]; |
|
212 |
||
213 |
JNF_COCOA_EXIT(env); |
|
214 |
} |
|
215 |
||
216 |
// Used for CWrapper.NSWindow.setLevel() (and level() which isn't implemented yet) |
|
217 |
static NSInteger LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_MAX_WINDOW_LEVELS]; |
|
218 |
static void initLevels() |
|
219 |
{ |
|
220 |
static dispatch_once_t pred; |
|
221 |
||
222 |
dispatch_once(&pred, ^{ |
|
223 |
LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSNormalWindowLevel] = NSNormalWindowLevel; |
|
224 |
LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSFloatingWindowLevel] = NSFloatingWindowLevel; |
|
23253 | 225 |
LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSPopUpMenuWindowLevel] = NSPopUpMenuWindowLevel; |
12047 | 226 |
}); |
227 |
} |
|
228 |
||
229 |
/* |
|
230 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
231 |
* Method: setLevel |
|
232 |
* Signature: (JI)V |
|
233 |
*/ |
|
234 |
JNIEXPORT void JNICALL |
|
235 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setLevel |
|
236 |
(JNIEnv *env, jclass cls, jlong windowPtr, jint level) |
|
237 |
{ |
|
238 |
JNF_COCOA_ENTER(env); |
|
239 |
||
240 |
if (level >= 0 && level < sun_lwawt_macosx_CWrapper_NSWindow_MAX_WINDOW_LEVELS) { |
|
241 |
initLevels(); |
|
242 |
||
243 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
244 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
12047 | 245 |
[window setLevel: LEVELS[level]]; |
246 |
}]; |
|
247 |
} else { |
|
248 |
[JNFException raise:env as:kIllegalArgumentException reason:"unknown level"]; |
|
249 |
} |
|
250 |
||
251 |
JNF_COCOA_EXIT(env); |
|
252 |
} |
|
253 |
||
254 |
/* |
|
255 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
256 |
* Method: addChildWindow |
|
257 |
* Signature: (JJI)V |
|
258 |
*/ |
|
259 |
JNIEXPORT void JNICALL |
|
260 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_addChildWindow |
|
261 |
(JNIEnv *env, jclass cls, jlong parentPtr, jlong childPtr, jint order) |
|
262 |
{ |
|
263 |
JNF_COCOA_ENTER(env); |
|
264 |
||
265 |
NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr); |
|
266 |
NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
267 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
12047 | 268 |
[parent addChildWindow:child ordered:order]; |
269 |
}]; |
|
270 |
||
271 |
JNF_COCOA_EXIT(env); |
|
272 |
} |
|
273 |
||
274 |
/* |
|
275 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
276 |
* Method: removeChildWindow |
|
277 |
* Signature: (JJ)V |
|
278 |
*/ |
|
279 |
JNIEXPORT void JNICALL |
|
280 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_removeChildWindow |
|
281 |
(JNIEnv *env, jclass cls, jlong parentPtr, jlong childPtr) |
|
282 |
{ |
|
283 |
JNF_COCOA_ENTER(env); |
|
284 |
||
23255
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
23253
diff
changeset
|
285 |
NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr); |
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
23253
diff
changeset
|
286 |
NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr); |
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
287 |
[ThreadUtilities performOnMainThread:@selector(removeChildWindow:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
288 |
on:parent |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
289 |
withObject:child |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
290 |
waitUntilDone:NO]; |
12047 | 291 |
|
292 |
JNF_COCOA_EXIT(env); |
|
293 |
} |
|
294 |
||
295 |
/* |
|
296 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
297 |
* Method: setAlphaValue |
|
298 |
* Signature: (JF)V |
|
299 |
*/ |
|
300 |
JNIEXPORT void JNICALL |
|
301 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setAlphaValue |
|
302 |
(JNIEnv *env, jclass cls, jlong windowPtr, jfloat alpha) |
|
303 |
{ |
|
304 |
JNF_COCOA_ENTER(env); |
|
305 |
||
23255
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
23253
diff
changeset
|
306 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
307 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
12047 | 308 |
[window setAlphaValue:(CGFloat)alpha]; |
309 |
}]; |
|
310 |
||
311 |
JNF_COCOA_EXIT(env); |
|
312 |
} |
|
313 |
||
314 |
/* |
|
315 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
316 |
* Method: setOpaque |
|
317 |
* Signature: (Z)V |
|
318 |
*/ |
|
319 |
JNIEXPORT void JNICALL |
|
320 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setOpaque |
|
321 |
(JNIEnv *env, jclass cls, jlong windowPtr, jboolean opaque) |
|
322 |
{ |
|
323 |
JNF_COCOA_ENTER(env); |
|
324 |
||
23255
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
23253
diff
changeset
|
325 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
326 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
12047 | 327 |
[window setOpaque:(BOOL)opaque]; |
328 |
}]; |
|
329 |
||
330 |
JNF_COCOA_EXIT(env); |
|
331 |
} |
|
332 |
||
333 |
/* |
|
334 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
335 |
* Method: setBackgroundColor |
|
336 |
* Signature: (J)V |
|
337 |
*/ |
|
338 |
JNIEXPORT void JNICALL |
|
339 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setBackgroundColor |
|
340 |
(JNIEnv *env, jclass cls, jlong windowPtr, jlong colorPtr) |
|
341 |
{ |
|
342 |
JNF_COCOA_ENTER(env); |
|
343 |
||
23255
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
23253
diff
changeset
|
344 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
12047 | 345 |
NSColor *color = (NSColor *)jlong_to_ptr(colorPtr); |
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
346 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
12047 | 347 |
[window setBackgroundColor:color]; |
348 |
}]; |
|
349 |
||
350 |
JNF_COCOA_EXIT(env); |
|
351 |
} |
|
352 |
||
353 |
/* |
|
23255
ebd69e3d93c5
8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents:
23253
diff
changeset
|
354 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
12047 | 355 |
* Method: miniaturize |
356 |
* Signature: (J)V |
|
357 |
*/ |
|
358 |
JNIEXPORT void JNICALL |
|
359 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_miniaturize |
|
360 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
361 |
{ |
|
362 |
JNF_COCOA_ENTER(env); |
|
363 |
||
364 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
365 |
[ThreadUtilities performOnMainThread:@selector(miniaturize:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
366 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
367 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
368 |
waitUntilDone:NO]; |
12047 | 369 |
|
370 |
JNF_COCOA_EXIT(env); |
|
371 |
} |
|
372 |
||
373 |
/* |
|
374 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
375 |
* Method: deminiaturize |
|
376 |
* Signature: (J)V |
|
377 |
*/ |
|
378 |
JNIEXPORT void JNICALL |
|
379 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_deminiaturize |
|
380 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
381 |
{ |
|
382 |
JNF_COCOA_ENTER(env); |
|
383 |
||
384 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
385 |
[ThreadUtilities performOnMainThread:@selector(deminiaturize:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
386 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
387 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
388 |
waitUntilDone:NO]; |
12047 | 389 |
|
390 |
JNF_COCOA_EXIT(env); |
|
391 |
} |
|
392 |
||
393 |
/* |
|
394 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
20457
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
395 |
* Method: isZoomed |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
396 |
* Signature: (J)Z |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
397 |
*/ |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
398 |
JNIEXPORT jboolean JNICALL |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
399 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_isZoomed |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
400 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
401 |
{ |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
402 |
__block jboolean isZoomed = JNI_FALSE; |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
403 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
404 |
JNF_COCOA_ENTER(env); |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
405 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
406 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
407 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
408 |
isZoomed = [window isZoomed]; |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
409 |
}]; |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
410 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
411 |
JNF_COCOA_EXIT(env); |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
412 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
413 |
return isZoomed; |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
414 |
} |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
415 |
|
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
416 |
/* |
ecb935d774a3
8007219: [macosx] Frame size reverts meaning of maximized attribute if frame size close to display
alexsch
parents:
18759
diff
changeset
|
417 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
12047 | 418 |
* Method: zoom |
419 |
* Signature: (J)V |
|
420 |
*/ |
|
421 |
JNIEXPORT void JNICALL |
|
422 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_zoom |
|
423 |
(JNIEnv *env, jclass cls, jlong windowPtr) |
|
424 |
{ |
|
425 |
JNF_COCOA_ENTER(env); |
|
426 |
||
427 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
428 |
[ThreadUtilities performOnMainThread:@selector(zoom:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
429 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
430 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
431 |
waitUntilDone:NO]; |
12047 | 432 |
|
433 |
JNF_COCOA_EXIT(env); |
|
434 |
} |
|
435 |
||
436 |
/* |
|
437 |
* Class: sun_lwawt_macosx_CWrapper$NSWindow |
|
438 |
* Method: makeFirstResponder |
|
439 |
* Signature: (JJ)V |
|
440 |
*/ |
|
441 |
JNIEXPORT void JNICALL |
|
442 |
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeFirstResponder |
|
443 |
(JNIEnv *env, jclass cls, jlong windowPtr, jlong responderPtr) |
|
444 |
{ |
|
445 |
JNF_COCOA_ENTER(env); |
|
446 |
||
447 |
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); |
|
448 |
NSResponder *responder = (NSResponder *)jlong_to_ptr(responderPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
449 |
[ThreadUtilities performOnMainThread:@selector(makeFirstResponder:) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
450 |
on:window |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
451 |
withObject:responder |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
452 |
waitUntilDone:NO]; |
12047 | 453 |
|
454 |
JNF_COCOA_EXIT(env); |
|
455 |
} |
|
456 |
||
457 |
/* |
|
458 |
* Class: sun_lwawt_macosx_CWrapper$NSView |
|
459 |
* Method: addSubview |
|
460 |
* Signature: (JJ)V |
|
461 |
*/ |
|
462 |
JNIEXPORT void JNICALL |
|
463 |
Java_sun_lwawt_macosx_CWrapper_00024NSView_addSubview |
|
464 |
(JNIEnv *env, jclass cls, jlong viewPtr, jlong subviewPtr) |
|
465 |
{ |
|
466 |
JNF_COCOA_ENTER(env); |
|
467 |
||
468 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
|
469 |
NSView *subview = (NSView *)jlong_to_ptr(subviewPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
470 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
12047 | 471 |
[view addSubview:subview]; |
472 |
}]; |
|
473 |
||
474 |
JNF_COCOA_EXIT(env); |
|
475 |
} |
|
476 |
||
477 |
/* |
|
478 |
* Class: sun_lwawt_macosx_CWrapper$NSView |
|
479 |
* Method: removeFromSuperview |
|
480 |
* Signature: (J)V |
|
481 |
*/ |
|
482 |
JNIEXPORT void JNICALL |
|
483 |
Java_sun_lwawt_macosx_CWrapper_00024NSView_removeFromSuperview |
|
484 |
(JNIEnv *env, jclass cls, jlong viewPtr) |
|
485 |
{ |
|
486 |
JNF_COCOA_ENTER(env); |
|
487 |
||
488 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
489 |
[ThreadUtilities performOnMainThread:@selector(removeFromSuperview) |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
490 |
on:view |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
491 |
withObject:nil |
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
492 |
waitUntilDone:NO]; |
12047 | 493 |
|
494 |
JNF_COCOA_EXIT(env); |
|
495 |
} |
|
496 |
||
497 |
/* |
|
498 |
* Class: sun_lwawt_macosx_CWrapper$NSView |
|
499 |
* Method: setFrame |
|
500 |
* Signature: (JIIII)V |
|
501 |
*/ |
|
502 |
JNIEXPORT void JNICALL |
|
503 |
Java_sun_lwawt_macosx_CWrapper_00024NSView_setFrame |
|
504 |
(JNIEnv *env, jclass cls, jlong viewPtr, jint x, jint y, jint w, jint h) |
|
505 |
{ |
|
506 |
JNF_COCOA_ENTER(env); |
|
507 |
||
508 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
509 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
12047 | 510 |
[view setFrame:NSMakeRect(x, y, w, h)]; |
511 |
}]; |
|
512 |
||
513 |
JNF_COCOA_EXIT(env); |
|
514 |
} |
|
515 |
||
516 |
/* |
|
517 |
* Class: sun_lwawt_macosx_CWrapper$NSView |
|
518 |
* Method: window |
|
519 |
* Signature: (J)J |
|
520 |
*/ |
|
521 |
JNIEXPORT jlong JNICALL |
|
522 |
Java_sun_lwawt_macosx_CWrapper_00024NSView_window |
|
523 |
(JNIEnv *env, jclass cls, jlong viewPtr) |
|
524 |
{ |
|
525 |
__block jlong windowPtr = 0L; |
|
526 |
||
527 |
JNF_COCOA_ENTER(env); |
|
528 |
||
529 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
|
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
530 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
12047 | 531 |
windowPtr = ptr_to_jlong([view window]); |
532 |
}]; |
|
533 |
||
534 |
JNF_COCOA_EXIT(env); |
|
535 |
||
536 |
return windowPtr; |
|
537 |
} |
|
538 |
||
539 |
/* |
|
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
540 |
* Class: sun_lwawt_macosx_CWrapper$NSView |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
541 |
* Method: setHidden |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
542 |
* Signature: (JZ)V |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
543 |
*/ |
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
544 |
JNIEXPORT void JNICALL |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
545 |
Java_sun_lwawt_macosx_CWrapper_00024NSView_setHidden |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
546 |
(JNIEnv *env, jclass cls, jlong viewPtr, jboolean toHide) |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
547 |
{ |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
548 |
JNF_COCOA_ENTER(env); |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
549 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
550 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
551 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
14753
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
552 |
[view setHidden:(BOOL)toHide]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
553 |
}]; |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
554 |
|
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
555 |
JNF_COCOA_EXIT(env); |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
556 |
} |
a56a685d137f
7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents:
12177
diff
changeset
|
557 |
|
18241 | 558 |
/* |
559 |
* Class: sun_lwawt_macosx_CWrapper$NSView |
|
560 |
* Method: setToolTip |
|
561 |
* Signature: (JLjava/lang/String;)V |
|
562 |
*/ |
|
563 |
JNIEXPORT void JNICALL |
|
564 |
Java_sun_lwawt_macosx_CWrapper_00024NSView_setToolTip |
|
565 |
(JNIEnv *env, jclass cls, jlong viewPtr, jstring msg) |
|
566 |
{ |
|
567 |
||
568 |
JNF_COCOA_ENTER(env); |
|
569 |
||
570 |
NSView *view = (NSView *)jlong_to_ptr(viewPtr); |
|
571 |
NSString* s = JNFJavaToNSString(env, msg); |
|
572 |
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ |
|
573 |
[view setToolTip: s]; |
|
574 |
}]; |
|
575 |
||
576 |
JNF_COCOA_EXIT(env); |
|
577 |
} |
|
578 |
||
12047 | 579 |
/* |
580 |
* Class: sun_lwawt_macosx_CWrapper$NSColor |
|
581 |
* Method: clearColor |
|
582 |
* Signature: ()J |
|
583 |
*/ |
|
584 |
JNIEXPORT jlong JNICALL |
|
585 |
Java_sun_lwawt_macosx_CWrapper_00024NSColor_clearColor |
|
586 |
(JNIEnv *env, jclass cls) |
|
587 |
{ |
|
588 |
__block jlong clearColorPtr = 0L; |
|
589 |
||
590 |
JNF_COCOA_ENTER(env); |
|
591 |
||
15322
3638f33225ec
7179050: [macosx] Make LWAWT be able to run on AppKit thread
serb
parents:
14753
diff
changeset
|
592 |
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){ |
12047 | 593 |
clearColorPtr = ptr_to_jlong([NSColor clearColor]); |
594 |
}]; |
|
595 |
||
596 |
JNF_COCOA_EXIT(env); |
|
597 |
||
598 |
return clearColorPtr; |
|
599 |
} |
|
600 |