Path: blob/master/src/java.desktop/unix/native/common/awt/awt.h
41153 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* Common AWT definitions27*/2829#ifndef _AWT_30#define _AWT_3132#include "jvm.h"33#include "jni_util.h"34#include "debug_util.h"3536#if !defined(HEADLESS) && !defined(MACOSX)37#include <X11/Xlib.h>38#include <X11/Xutil.h>39typedef char Boolean;40#endif /* !HEADLESS && !MACOSX */414243/* The JVM instance: defined in awt_MToolkit.c */44extern JavaVM *jvm;4546extern jclass tkClass;47extern jmethodID awtLockMID;48extern jmethodID awtUnlockMID;49extern jmethodID awtWaitMID;50extern jmethodID awtNotifyMID;51extern jmethodID awtNotifyAllMID;52extern jboolean awtLockInited;5354/* Perform sanity and consistency checks on AWT locking */55#ifdef DEBUG56#define DEBUG_AWT_LOCK57#endif5859/*60* The following locking primitives should be defined61*62#define AWT_LOCK()63#define AWT_NOFLUSH_UNLOCK()64#define AWT_WAIT(tm)65#define AWT_NOTIFY()66#define AWT_NOTIFY_ALL()67*/6869/*70* Convenience macros based on AWT_NOFLUSH_UNLOCK71*/72extern void awt_output_flush();73#define AWT_UNLOCK() AWT_FLUSH_UNLOCK()74#define AWT_FLUSH_UNLOCK() do { \75awt_output_flush(); \76AWT_NOFLUSH_UNLOCK(); \77} while (0)7879#define AWT_UNLOCK_CHECK_EXCEPTION(env) \80do { \81AWT_UNLOCK(); \82JNU_CHECK_EXCEPTION(env); \83} while (0)8485#define AWT_LOCK_IMPL() \86do { \87(*env)->CallStaticVoidMethod(env, tkClass, awtLockMID); \88if ((*env)->ExceptionCheck(env)) { \89(*env)->ExceptionClear(env); \90} \91} while(0)9293#define AWT_NOFLUSH_UNLOCK_IMPL() \94do { \95jthrowable pendingException; \96if ((pendingException = (*env)->ExceptionOccurred(env)) != NULL) { \97(*env)->ExceptionClear(env); \98} \99(*env)->CallStaticVoidMethod(env, tkClass, awtUnlockMID); \100if ((*env)->ExceptionCheck(env)) { \101(*env)->ExceptionClear(env); \102} \103if (pendingException) { \104(*env)->Throw(env, pendingException); \105} \106} while (0)107#define AWT_WAIT_IMPL(tm) \108(*env)->CallStaticVoidMethod(env, tkClass, awtWaitMID, (jlong)(tm))109#define AWT_NOTIFY_IMPL() \110(*env)->CallStaticVoidMethod(env, tkClass, awtNotifyMID)111#define AWT_NOTIFY_ALL_IMPL() \112(*env)->CallStaticVoidMethod(env, tkClass, awtNotifyAllMID)113114/*115* Unfortunately AWT_LOCK debugging does not work with XAWT due to mixed116* Java/C use of AWT lock.117*/118#define AWT_LOCK() AWT_LOCK_IMPL()119#define AWT_NOFLUSH_UNLOCK() AWT_NOFLUSH_UNLOCK_IMPL()120#define AWT_WAIT(tm) AWT_WAIT_IMPL(tm)121#define AWT_NOTIFY() AWT_NOTIFY_IMPL()122#define AWT_NOTIFY_ALL() AWT_NOTIFY_ALL_IMPL()123124#if !defined(HEADLESS) && !defined(MACOSX)125extern Display *awt_display; /* awt_GraphicsEnv.c */126extern Boolean awt_ModLockIsShiftLock; /* XToolkit.c */127#endif /* !HEADLESS && !MACOSX */128129#endif /* ! _AWT_ */130131132