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
787 // We need to let Foundation know that this is a multithreaded application,
788 // if it isn't already.
789 if (![NSThread isMultiThreaded]) {
790 [[[[NSThread alloc] init] autorelease] start];
791 }
792
793 return JNI_VERSION_1_4;
794 }
795
796 /*
797 * Class: sun_lwawt_macosx_LWCToolkit
798 * Method: isEmbedded
799 * Signature: ()Z
800 */
801 JNIEXPORT jboolean JNICALL
802 Java_sun_lwawt_macosx_LWCToolkit_isEmbedded
803 (JNIEnv *env, jclass klass) {
804 return isEmbedded ? JNI_TRUE : JNI_FALSE;
805 }
806
|
1 /*
2 * Copyright (c) 2011, 2018, 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
787 // We need to let Foundation know that this is a multithreaded application,
788 // if it isn't already.
789 if (![NSThread isMultiThreaded]) {
790 [[[[NSThread alloc] init] autorelease] start];
791 }
792
793 return JNI_VERSION_1_4;
794 }
795
796 /*
797 * Class: sun_lwawt_macosx_LWCToolkit
798 * Method: isEmbedded
799 * Signature: ()Z
800 */
801 JNIEXPORT jboolean JNICALL
802 Java_sun_lwawt_macosx_LWCToolkit_isEmbedded
803 (JNIEnv *env, jclass klass) {
804 return isEmbedded ? JNI_TRUE : JNI_FALSE;
805 }
806
807 /*
808 * Class: sun_lwawt_macosx_LWCToolkit
809 * Method: isInAquaSession
810 * Signature: ()Z
811 */
812 JNIEXPORT jboolean JNICALL
813 Java_sun_lwawt_macosx_LWCToolkit_isInAquaSession
814 (JNIEnv *env, jclass klass) {
815 // copied from java.base/macosx/native/libjava/java_props_macosx.c
816 // environment variable to bypass the aqua session check
817 char *ev = getenv("AWT_FORCE_HEADFUL");
818 if (ev && (strncasecmp(ev, "true", 4) == 0)) {
819 // if "true" then tell the caller we're in an Aqua session without
820 // actually checking
821 return JNI_TRUE;
822 }
823 // Is the WindowServer available?
824 SecuritySessionId session_id;
825 SessionAttributeBits session_info;
826 OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
827 if (status == noErr) {
828 if (session_info & sessionHasGraphicAccess) {
829 return JNI_TRUE;
830 }
831 }
832 return JNI_FALSE;
833 }
|