Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/sun/awt/awt_util.c
32287 views
/*1* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/*26#ifdef HEADLESS27#error This file should not be included in headless library28#endif29*/3031#include "awt_p.h"32#include "color.h"33#include <X11/IntrinsicP.h>34#include <X11/Xatom.h>35#include <X11/Xmd.h>36#include <X11/Xutil.h>37#include <X11/Xproto.h>38#include <jni.h>39#include <jni_util.h>40#include <sys/time.h>414243#include "java_awt_event_MouseWheelEvent.h"4445/*46* Called by "ToolkitErrorHandler" function in "XlibWrapper.c" file.47*/48XErrorHandler current_native_xerror_handler = NULL;4950extern jint getModifiers(uint32_t state, jint button, jint keyCode);51extern jint getButton(uint32_t button);5253static Atom OLDecorDelAtom = 0;54static Atom MWMHints = 0;55static Atom DTWMHints = 0;56static Atom decor_list[9];5758#ifndef MAX59#define MAX(a,b) ((a) > (b) ? (a) : (b))60#endif6162#ifndef MIN63#define MIN(a,b) ((a) < (b) ? (a) : (b))64#endif6566jboolean67awtJNI_ThreadYield(JNIEnv *env) {6869static jclass threadClass = NULL;70static jmethodID yieldMethodID = NULL;7172/* Initialize our java identifiers once. Checking before locking73* is a huge performance win.74*/75if (threadClass == NULL) {76// should enter a monitor here...77Boolean err = FALSE;78if (threadClass == NULL) {79jclass tc = (*env)->FindClass(env, "java/lang/Thread");80CHECK_NULL_RETURN(tc, JNI_FALSE);81threadClass = (*env)->NewGlobalRef(env, tc);82(*env)->DeleteLocalRef(env, tc);83if (threadClass != NULL) {84yieldMethodID = (*env)->GetStaticMethodID(env,85threadClass,86"yield",87"()V"88);89}90}91if (yieldMethodID == NULL) {92threadClass = NULL;93err = TRUE;94}95if (err) {96return JNI_FALSE;97}98} /* threadClass == NULL*/99100(*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID);101DASSERT(!((*env)->ExceptionOccurred(env)));102return JNI_TRUE;103} /* awtJNI_ThreadYield() */104105106