src/solaris/native/sun/awt/awt_util.h

Print this page




  29 #ifndef HEADLESS
  30 #include "gdefs.h"
  31 
  32 /*
  33  * Expected types of arguments of the macro.
  34  * (JNIEnv*, const char*, const char*, jboolean, jobject)
  35  */
  36 #define WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature,                          \
  37                             handlerHasFlag, handlerRef) do {                                      \
  38     handlerRef = JNU_CallStaticMethodByName(env, NULL, handlerClassName, "getInstance",           \
  39         getInstanceSignature).l;                                                                  \
  40     if (handlerHasFlag == JNI_TRUE) {                                                             \
  41         JNU_CallMethodByName(env, NULL, handlerRef, "setErrorOccurredFlag", "(Z)V", JNI_FALSE);   \
  42     }                                                                                             \
  43     JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "WITH_XERROR_HANDLER", \
  44         "(Lsun/awt/X11/XErrorHandler;)V", handlerRef);                                            \
  45 } while (0)
  46 
  47 /*
  48  * Expected types of arguments of the macro.
  49  * (JNIEnv*)
  50  */
  51 #define RESTORE_XERROR_HANDLER(env) do {                                                          \
  52     JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil",                        \
  53         "RESTORE_XERROR_HANDLER", "()V");                                                         \
  54 } while (0)
  55 
  56 /*
  57  * Expected types of arguments of the macro.
  58  * (JNIEnv*, const char*, const char*, jboolean, jobject, jboolean, No type - C expression)
  59  */
  60 #define EXEC_WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag,     \
  61                                  handlerRef, errorOccurredFlag, code) do {                        \
  62     handlerRef = NULL;                                                                            \
  63     WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag, handlerRef); \
  64     do {                                                                                          \
  65         code;                                                                                     \
  66     } while (0);                                                                                  \
  67     RESTORE_XERROR_HANDLER(env);                                                                  \
  68     if (handlerHasFlag == JNI_TRUE) {                                                             \










  69         errorOccurredFlag = JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag",   \
  70             "()Z").z;                                                                             \
  71     }                                                                                             \
  72 } while (0)
  73 #endif /* !HEADLESS */
  74 
  75 #ifndef INTERSECTS
  76 #define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \
  77 !((r2_x2 <= r1_x1) ||\
  78   (r2_y2 <= r1_y1) ||\
  79   (r2_x1 >= r1_x2) ||\
  80   (r2_y1 >= r1_y2))
  81 #endif
  82 
  83 #ifndef MIN
  84 #define MIN(a,b) ((a) < (b) ? (a) : (b))
  85 #endif
  86 #ifndef MAX
  87 #define MAX(a,b) ((a) > (b) ? (a) : (b))
  88 #endif




  29 #ifndef HEADLESS
  30 #include "gdefs.h"
  31 
  32 /*
  33  * Expected types of arguments of the macro.
  34  * (JNIEnv*, const char*, const char*, jboolean, jobject)
  35  */
  36 #define WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature,                          \
  37                             handlerHasFlag, handlerRef) do {                                      \
  38     handlerRef = JNU_CallStaticMethodByName(env, NULL, handlerClassName, "getInstance",           \
  39         getInstanceSignature).l;                                                                  \
  40     if (handlerHasFlag == JNI_TRUE) {                                                             \
  41         JNU_CallMethodByName(env, NULL, handlerRef, "setErrorOccurredFlag", "(Z)V", JNI_FALSE);   \
  42     }                                                                                             \
  43     JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "WITH_XERROR_HANDLER", \
  44         "(Lsun/awt/X11/XErrorHandler;)V", handlerRef);                                            \
  45 } while (0)
  46 
  47 /*
  48  * Expected types of arguments of the macro.
  49  * (JNIEnv*, jboolean)
  50  */
  51 #define RESTORE_XERROR_HANDLER(env, doXSync) do {                                                 \
  52     JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil",                        \
  53         "RESTORE_XERROR_HANDLER", "(Z)V", doXSync);                                               \
  54 } while (0)
  55 
  56 /*
  57  * Expected types of arguments of the macro.
  58  * (JNIEnv*, const char*, const char*, jboolean, jobject, jboolean, No type - C expression)
  59  */
  60 #define EXEC_WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag,     \
  61                                  handlerRef, errorOccurredFlag, code) do {                        \
  62     handlerRef = NULL;                                                                            \
  63     WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag, handlerRef); \
  64     do {                                                                                          \
  65         code;                                                                                     \
  66     } while (0);                                                                                  \
  67     RESTORE_XERROR_HANDLER(env, JNI_TRUE);                                                        \
  68     if (handlerHasFlag == JNI_TRUE) {                                                             \
  69         GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag);                      \
  70     }                                                                                             \
  71 } while (0)
  72 
  73 /*
  74  * Expected types of arguments of the macro.
  75  * (JNIEnv*, jobject, jboolean)
  76  */
  77 #define GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef, errorOccurredFlag) do {                  \
  78     if (handlerRef != NULL) {                                                                     \
  79         errorOccurredFlag = JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag",   \
  80             "()Z").z;                                                                             \
  81     }                                                                                             \
  82 } while (0)
  83 #endif /* !HEADLESS */
  84 
  85 #ifndef INTERSECTS
  86 #define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \
  87 !((r2_x2 <= r1_x1) ||\
  88   (r2_y2 <= r1_y1) ||\
  89   (r2_x1 >= r1_x2) ||\
  90   (r2_y1 >= r1_y2))
  91 #endif
  92 
  93 #ifndef MIN
  94 #define MIN(a,b) ((a) < (b) ? (a) : (b))
  95 #endif
  96 #ifndef MAX
  97 #define MAX(a,b) ((a) > (b) ? (a) : (b))
  98 #endif