1 /*
2 * Copyright (c) 1996, 2014, 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
366 AWT_UNLOCK();
367 return (jobject)NULL;
368 }
369 }
370 if ((peer != NULL) &&
371 (JNU_IsInstanceOfByName(env, peer, "sun/awt/X11/XWindow") == 1)) {
372 target = (*env)->GetObjectField(env, peer, targetID);
373 }
374
375 if (target == NULL) {
376 (*env)->ExceptionClear(env);
377 JNU_ThrowNullPointerException(env, "NullPointerException");
378 AWT_UNLOCK();
379 return (jobject)NULL;
380 }
381
382 AWT_UNLOCK();
383
384 return target;
385 }
|
1 /*
2 * Copyright (c) 1996, 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
366 AWT_UNLOCK();
367 return (jobject)NULL;
368 }
369 }
370 if ((peer != NULL) &&
371 (JNU_IsInstanceOfByName(env, peer, "sun/awt/X11/XWindow") == 1)) {
372 target = (*env)->GetObjectField(env, peer, targetID);
373 }
374
375 if (target == NULL) {
376 (*env)->ExceptionClear(env);
377 JNU_ThrowNullPointerException(env, "NullPointerException");
378 AWT_UNLOCK();
379 return (jobject)NULL;
380 }
381
382 AWT_UNLOCK();
383
384 return target;
385 }
386
387 // EmbeddedFrame support
388
389 static char *const embeddedClassName = "sun/awt/X11/XEmbeddedFrame";
390
391 JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame
392 (JNIEnv* env, void* platformInfo)
393 {
394 static jmethodID mid = NULL;
395 static jclass cls;
396 if (mid == NULL) {
397 cls = (*env)->FindClass(env, embeddedClassName);
398 CHECK_NULL_RETURN(cls, NULL);
399 mid = (*env)->GetMethodID(env, cls, "<init>", "(JZ)V");
400 CHECK_NULL_RETURN(mid, NULL);
401 }
402 return (*env)->NewObject(env, cls, mid, platformInfo, JNI_TRUE);
403 }
404
405
406 JNIEXPORT void JNICALL awt_SetBounds
407 (JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h)
408 {
409 static jmethodID mid = NULL;
410 if (mid == NULL) {
411 jclass cls = (*env)->FindClass(env, embeddedClassName);
412 CHECK_NULL(cls);
413 mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V");
414 CHECK_NULL(mid);
415 }
416 (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h);
417 }
418
419 JNIEXPORT void JNICALL awt_SynthesizeWindowActivation
420 (JNIEnv *env, jobject embeddedFrame, jboolean doActivate)
421 {
422 static jmethodID mid = NULL;
423 if (mid == NULL) {
424 jclass cls = (*env)->FindClass(env, embeddedClassName);
425 CHECK_NULL(cls);
426 mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V");
427 CHECK_NULL(mid);
428 }
429 (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate);
430 }
|