jdk/src/solaris/native/sun/awt/awt_util.h
author serb
Sat, 12 Nov 2011 04:13:38 +0400
changeset 11093 e753252dc8a9
parent 5506 202f599c92aa
child 17679 a81555868357
permissions -rw-r--r--
6996291: command line selection of MToolkit by -Dawt.toolkit=sun.awt.motif.MToolkit fails from jdk7 b21 on Reviewed-by: art, dcherepanov, bae, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef _AWT_UTIL_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define _AWT_UTIL_H_
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "gdefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#define WITH_XERROR_HANDLER(f) do {             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
    XSync(awt_display, False);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    xerror_code = Success;                      \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    xerror_saved_handler = XSetErrorHandler(f); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/* Convenience macro for handlers to use */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define XERROR_SAVE(err) do {                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    xerror_code = (err)->error_code;            \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define RESTORE_XERROR_HANDLER do {             \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    XSync(awt_display, False);                  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    XSetErrorHandler(xerror_saved_handler);     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#define EXEC_WITH_XERROR_HANDLER(f, code) do {  \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    WITH_XERROR_HANDLER(f);                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    do {                                        \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        code;                                   \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    } while (0);                                \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    RESTORE_XERROR_HANDLER;                     \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
} while (0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * Since X reports protocol errors asynchronously, we often need to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * install an error handler that acts like a callback.  While that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * specialized handler is installed we save original handler here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
extern XErrorHandler xerror_saved_handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * A place for error handler to report the error code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
extern unsigned char xerror_code;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
#ifndef INTERSECTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
#define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
!((r2_x2 <= r1_x1) ||\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
  (r2_y2 <= r1_y1) ||\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  (r2_x1 >= r1_x2) ||\
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
  (r2_y1 >= r1_y2))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#ifndef MIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#define MIN(a,b) ((a) < (b) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#ifndef MAX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#define MAX(a,b) ((a) > (b) ? (a) : (b))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
struct DPos {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    int32_t x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    int32_t y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    int32_t mapped;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    void *data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    void *peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    int32_t echoC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
extern void awtJNI_ThreadYield(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Functions for accessing fields by name and signature
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
JNIEXPORT jobject JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
JNU_GetObjectField(JNIEnv *env, jobject self, const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                   const char *sig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
JNU_SetObjectField(JNIEnv *env, jobject self, const char *name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                   const char *sig, jobject val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
JNU_GetLongField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
JNU_GetIntField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
JNU_SetIntField(JNIEnv *env, jobject self, const char *name, jint val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
JNU_SetLongField(JNIEnv *env, jobject self, const char *name, jlong val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
JNU_GetBooleanField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
JNU_SetBooleanField(JNIEnv *env, jobject self, const char *name, jboolean val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
JNU_GetCharField(JNIEnv *env, jobject self, const char *name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
#endif           /* _AWT_UTIL_H_ */