| 1 | /* |
| 2 | * Copyright (c) 1995, 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 |
| 23 | * questions. |
| 24 | */ |
| 25 | |
| 26 | #ifndef _AWT_UTIL_H_ |
| 27 | #define _AWT_UTIL_H_ |
| 28 | |
| 29 | #ifndef HEADLESS |
| 30 | #include "gdefs.h" |
| 31 | |
| 32 | #define WITH_XERROR_HANDLER(f) do { \ |
| 33 | XSync(awt_display, False); \ |
| 34 | current_native_xerror_handler = (f); \ |
| 35 | } while (0) |
| 36 | |
| 37 | #define RESTORE_XERROR_HANDLER do { \ |
| 38 | XSync(awt_display, False); \ |
| 39 | current_native_xerror_handler = NULL; \ |
| 40 | } while (0) |
| 41 | |
| 42 | #define EXEC_WITH_XERROR_HANDLER(f, code) do { \ |
| 43 | WITH_XERROR_HANDLER(f); \ |
| 44 | do { \ |
| 45 | code; \ |
| 46 | } while (0); \ |
| 47 | RESTORE_XERROR_HANDLER; \ |
| 48 | } while (0) |
| 49 | |
| 50 | /* |
| 51 | * Called by "ToolkitErrorHandler" function in "XlibWrapper.c" file. |
| 52 | */ |
| 53 | extern XErrorHandler current_native_xerror_handler; |
| 54 | |
| 55 | Window get_xawt_root_shell(JNIEnv *env); |
| 56 | |
| 57 | #endif /* !HEADLESS */ |
| 58 | |
| 59 | #ifndef INTERSECTS |
| 60 | #define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \ |
| 61 | !((r2_x2 <= r1_x1) ||\ |
| 62 | (r2_y2 <= r1_y1) ||\ |
| 63 | (r2_x1 >= r1_x2) ||\ |
| 64 | (r2_y1 >= r1_y2)) |
| 65 | #endif |
| 66 | |
| 67 | #ifndef MIN |
| 68 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
| 69 | #endif |
| 70 | #ifndef MAX |
| 71 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
| 72 | #endif |
| 73 | |
| 74 | struct DPos { |
| 75 | int32_t x; |
| 76 | int32_t y; |
| 77 | int32_t mapped; |
| 78 | void *data; |
| 79 | void *peer; |
| 80 | int32_t echoC; |
| 81 | }; |
| 82 | |
| 83 | extern jboolean awtJNI_ThreadYield(JNIEnv *env); |
| 84 | |
| 85 | /* |
| 86 | * Functions for accessing fields by name and signature |
| 87 | */ |
| 88 | |
| 89 | JNIEXPORT jobject JNICALL |
| 90 | JNU_GetObjectField(JNIEnv *env, jobject self, const char *name, |
| 91 | const char *sig); |
| 92 | |
| 93 | JNIEXPORT jboolean JNICALL |
| 94 | JNU_SetObjectField(JNIEnv *env, jobject self, const char *name, |
| 95 | const char *sig, jobject val); |
| 96 | |
| 97 | JNIEXPORT jlong JNICALL |
| 98 | JNU_GetLongField(JNIEnv *env, jobject self, const char *name); |
| 99 | |
| 100 | JNIEXPORT jint JNICALL |
| 101 | JNU_GetIntField(JNIEnv *env, jobject self, const char *name); |
| 102 | |
| 103 | JNIEXPORT jboolean JNICALL |
| 104 | JNU_SetIntField(JNIEnv *env, jobject self, const char *name, jint val); |
| 105 | |
| 106 | JNIEXPORT jboolean JNICALL |
| 107 | JNU_SetLongField(JNIEnv *env, jobject self, const char *name, jlong val); |
| 108 | |
| 109 | JNIEXPORT jboolean JNICALL |
| 110 | JNU_GetBooleanField(JNIEnv *env, jobject self, const char *name); |
| 111 | |
| 112 | JNIEXPORT jboolean JNICALL |
| 113 | JNU_SetBooleanField(JNIEnv *env, jobject self, const char *name, jboolean val); |
| 114 | |
| 115 | JNIEXPORT jint JNICALL |
| 116 | JNU_GetCharField(JNIEnv *env, jobject self, const char *name); |
| 117 | |
| 118 | #endif /* _AWT_UTIL_H_ */ |
| 119 | |