Path: blob/master/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c
41154 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#ifdef HEADLESS26#error This file should not be included in headless library27#endif2829#include "awt_p.h"30#include "color.h"31#include <X11/Xatom.h>32#include <X11/Xmd.h>33#include <X11/Xutil.h>34#include <X11/Xproto.h>35#include <jni.h>36#include <jni_util.h>37#include <sys/time.h>383940#include "java_awt_event_MouseWheelEvent.h"4142/*43* Called by "ToolkitErrorHandler" function in "XlibWrapper.c" file.44*/45XErrorHandler current_native_xerror_handler = NULL;4647extern jint getModifiers(uint32_t state, jint button, jint keyCode);48extern jint getButton(uint32_t button);4950static Atom OLDecorDelAtom = 0;51static Atom MWMHints = 0;52static Atom DTWMHints = 0;53static Atom decor_list[9];5455#ifndef MAX56#define MAX(a,b) ((a) > (b) ? (a) : (b))57#endif5859#ifndef MIN60#define MIN(a,b) ((a) < (b) ? (a) : (b))61#endif6263jboolean64awtJNI_ThreadYield(JNIEnv *env) {6566static jclass threadClass = NULL;67static jmethodID yieldMethodID = NULL;6869/* Initialize our java identifiers once. Checking before locking70* is a huge performance win.71*/72if (threadClass == NULL) {73// should enter a monitor here...74Boolean err = FALSE;75if (threadClass == NULL) {76jclass tc = (*env)->FindClass(env, "java/lang/Thread");77CHECK_NULL_RETURN(tc, JNI_FALSE);78threadClass = (*env)->NewGlobalRef(env, tc);79(*env)->DeleteLocalRef(env, tc);80if (threadClass != NULL) {81yieldMethodID = (*env)->GetStaticMethodID(env,82threadClass,83"yield",84"()V"85);86}87}88if (yieldMethodID == NULL) {89threadClass = NULL;90err = TRUE;91}92if (err) {93return JNI_FALSE;94}95} /* threadClass == NULL*/9697(*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID);98DASSERT(!((*env)->ExceptionOccurred(env)));99if ((*env)->ExceptionCheck(env)) {100return JNI_FALSE;101}102return JNI_TRUE;103} /* awtJNI_ThreadYield() */104105106