0N/A/*
6447N/A * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef _AWT_UTIL_H_
0N/A#define _AWT_UTIL_H_
0N/A
0N/A#ifndef HEADLESS
0N/A#ifndef XAWT
0N/A#include <Xm/VendorSEP.h>
0N/A#include <Xm/VendorSP.h>
0N/A#endif
0N/A#include "gdefs.h"
0N/A
0N/Atypedef struct ConvertEventTimeAndModifiers {
0N/A jlong when;
0N/A jint modifiers;
0N/A} ConvertEventTimeAndModifiers;
0N/A
0N/ABoolean awt_util_focusIsOnMenu(Display *display);
0N/Aint32_t awt_util_sendButtonClick(Display *display, Window window);
0N/A
0N/AWidget awt_util_createWarningWindow(Widget parent, char *warning);
0N/Avoid awt_util_show(Widget w);
0N/Avoid awt_util_hide(Widget w);
0N/Avoid awt_util_enable(Widget w);
0N/Avoid awt_util_disable(Widget w);
0N/Avoid awt_util_reshape(Widget w, jint x, jint y, jint wd, jint ht);
0N/Avoid awt_util_mapChildren(Widget w, void (*func)(Widget,void *),
0N/A int32_t applyToSelf, void *data);
0N/Aint32_t awt_util_setCursor(Widget w, Cursor c);
0N/Avoid awt_util_convertEventTimeAndModifiers
0N/A (XEvent *event, ConvertEventTimeAndModifiers *output);
0N/AWidget awt_WidgetAtXY(Widget root, Position x, Position y);
0N/Achar *awt_util_makeWMMenuItem(char *target, Atom protocol);
0N/ACardinal awt_util_insertCallback(Widget w);
0N/Avoid awt_util_consumeAllXEvents(Widget widget);
0N/Avoid awt_util_cleanupBeforeDestroyWidget(Widget widget);
0N/Avoid awt_util_debug_init();
0N/ATime awt_util_getCurrentServerTime();
0N/Ajlong awt_util_nowMillisUTC();
0N/Ajlong awt_util_nowMillisUTC_offset(Time server_offset);
0N/Avoid awt_util_do_wheel_scroll(Widget scrolled_window, jint scrollType,
0N/A jint scrollAmt, jint wheelAmt);
0N/AWidget awt_util_get_scrollbar_to_scroll(Widget window);
0N/A
0N/A
0N/Atypedef struct _EmbeddedFrame {
0N/A Widget embeddedFrame;
0N/A Window frameContainer;
0N/A jobject javaRef;
0N/A Boolean eventSelectedPreviously;
0N/A struct _EmbeddedFrame * next;
0N/A struct _EmbeddedFrame * prev;
0N/A} EmbeddedFrame;
0N/A
0N/Avoid awt_util_addEmbeddedFrame(Widget embeddedFrame, jobject javaRef);
0N/Avoid awt_util_delEmbeddedFrame(Widget embeddedFrame);
0N/ABoolean awt_util_processEventForEmbeddedFrame(XEvent *ev);
0N/A
6447N/A/*
6447N/A * Expected types of arguments of the macro.
6447N/A * (JNIEnv*, const char*, const char*, jboolean, jobject)
6447N/A */
6447N/A#define WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, \
6447N/A handlerHasFlag, handlerRef) do { \
6447N/A handlerRef = JNU_CallStaticMethodByName(env, NULL, handlerClassName, "getInstance", \
6447N/A getInstanceSignature).l; \
6447N/A if (handlerHasFlag == JNI_TRUE) { \
6447N/A JNU_CallMethodByName(env, NULL, handlerRef, "setErrorOccurredFlag", "(Z)V", JNI_FALSE); \
6447N/A } \
6447N/A JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", "WITH_XERROR_HANDLER", \
6447N/A "(Lsun/awt/X11/XErrorHandler;)V", handlerRef); \
0N/A} while (0)
0N/A
6447N/A/*
6447N/A * Expected types of arguments of the macro.
6447N/A * (JNIEnv*, jboolean)
6447N/A */
6447N/A#define RESTORE_XERROR_HANDLER(env, doXSync) do { \
6447N/A JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \
6447N/A "RESTORE_XERROR_HANDLER", "(Z)V", doXSync); \
0N/A} while (0)
0N/A
0N/A/*
6447N/A * Expected types of arguments of the macro.
6447N/A * (JNIEnv*, const char*, const char*, jboolean, jobject, jboolean, No type - C expression)
0N/A */
6447N/A#define EXEC_WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag, \
6447N/A handlerRef, errorOccurredFlag, code) do { \
6447N/A handlerRef = NULL; \
6447N/A WITH_XERROR_HANDLER(env, handlerClassName, getInstanceSignature, handlerHasFlag, handlerRef); \
6447N/A do { \
6447N/A code; \
6447N/A } while (0); \
6447N/A RESTORE_XERROR_HANDLER(env, JNI_TRUE); \
6447N/A if (handlerHasFlag == JNI_TRUE) { \
6447N/A errorOccurredFlag = GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef); \
6447N/A } \
6447N/A} while (0)
0N/A
0N/A/*
6447N/A * Expected types of arguments of the macro for jboolean expression.
6447N/A * (JNIEnv*, jobject)
0N/A */
6447N/A#define GET_HANDLER_ERROR_OCCURRED_FLAG(env, handlerRef) (handlerRef != NULL ? \
6447N/A JNU_CallMethodByName(env, NULL, handlerRef, "getErrorOccurredFlag", "()Z").z : JNI_FALSE)
0N/A
6447N/A/*
6447N/A * Expected types of arguments of the macro for jbyte expression.
6447N/A * (JNIEnv*, jobject)
6447N/A */
6447N/A#define GET_XERROR_CODE(env, savedError) \
6447N/A ((savedError = JNU_GetStaticFieldByName(env, NULL, "sun/awt/X11/XErrorHandlerUtil", \
6447N/A "saved_error", "Lsun/awt/X11/XErrorEvent;").l) != NULL ? \
6447N/A JNU_CallMethodByName(env, NULL, savedError, "get_error_code", "()B").b : Success)
0N/A#endif /* !HEADLESS */
0N/A
0N/A#ifndef INTERSECTS
0N/A#define INTERSECTS(r1_x1,r1_x2,r1_y1,r1_y2,r2_x1,r2_x2,r2_y1,r2_y2) \
0N/A!((r2_x2 <= r1_x1) ||\
0N/A (r2_y2 <= r1_y1) ||\
0N/A (r2_x1 >= r1_x2) ||\
0N/A (r2_y1 >= r1_y2))
0N/A#endif
0N/A
0N/A#ifndef MIN
0N/A#define MIN(a,b) ((a) < (b) ? (a) : (b))
0N/A#endif
0N/A#ifndef MAX
0N/A#define MAX(a,b) ((a) > (b) ? (a) : (b))
0N/A#endif
0N/A
0N/Astruct DPos {
0N/A int32_t x;
0N/A int32_t y;
0N/A int32_t mapped;
0N/A void *data;
0N/A void *peer;
0N/A int32_t echoC;
0N/A};
0N/A
0N/Aextern jobject awtJNI_GetCurrentThread(JNIEnv *env);
0N/Aextern void awtJNI_ThreadYield(JNIEnv *env);
0N/A
0N/A#ifndef HEADLESS
0N/Aextern Widget prevWidget;
0N/A#endif /* !HEADLESS */
0N/A
0N/A/*
0N/A * Functions for accessing fields by name and signature
0N/A */
0N/A
0N/AJNIEXPORT jobject JNICALL
0N/AJNU_GetObjectField(JNIEnv *env, jobject self, const char *name,
0N/A const char *sig);
0N/A
0N/AJNIEXPORT jboolean JNICALL
0N/AJNU_SetObjectField(JNIEnv *env, jobject self, const char *name,
0N/A const char *sig, jobject val);
0N/A
0N/AJNIEXPORT jlong JNICALL
0N/AJNU_GetLongField(JNIEnv *env, jobject self, const char *name);
0N/A
0N/AJNIEXPORT jint JNICALL
0N/AJNU_GetIntField(JNIEnv *env, jobject self, const char *name);
0N/A
0N/AJNIEXPORT jboolean JNICALL
0N/AJNU_SetIntField(JNIEnv *env, jobject self, const char *name, jint val);
0N/A
0N/AJNIEXPORT jboolean JNICALL
0N/AJNU_SetLongField(JNIEnv *env, jobject self, const char *name, jlong val);
0N/A
0N/AJNIEXPORT jboolean JNICALL
0N/AJNU_GetBooleanField(JNIEnv *env, jobject self, const char *name);
0N/A
0N/AJNIEXPORT jboolean JNICALL
0N/AJNU_SetBooleanField(JNIEnv *env, jobject self, const char *name, jboolean val);
0N/A
0N/AJNIEXPORT jint JNICALL
0N/AJNU_GetCharField(JNIEnv *env, jobject self, const char *name);
0N/A
0N/A#ifndef HEADLESS
0N/A#ifdef __solaris__
0N/Aextern Widget awt_util_getXICStatusAreaWindow(Widget w);
0N/A#else
4632N/A#if defined(MACOSX)
4632N/Aint32_t awt_util_getIMStatusHeight(Widget vw);
4632N/AWidget awt_util_getXICStatusAreaWindow(Widget w);
4632N/A#else
0N/Aint32_t awt_util_getIMStatusHeight(Widget vw);
0N/AXVaNestedList awt_util_getXICStatusAreaList(Widget w);
0N/AWidget awt_util_getXICStatusAreaWindow(Widget w);
0N/A#endif
4632N/A#endif
0N/A
0N/A
0N/A
0N/A
4632N/A#if defined(__linux__) || defined(MACOSX)
0N/Atypedef struct _XmImRefRec {
0N/A Cardinal num_refs; /* Number of referencing widgets. */
0N/A Cardinal max_refs; /* Maximum length of refs array. */
0N/A Widget* refs; /* Array of referencing widgets. */
0N/A XtPointer **callbacks;
0N/A} XmImRefRec, *XmImRefInfo;
0N/A
0N/Atypedef struct _PreeditBufferRec {
0N/A unsigned short length;
0N/A wchar_t *text;
0N/A XIMFeedback *feedback;
0N/A int32_t caret;
0N/A XIMCaretStyle style;
0N/A} PreeditBufferRec, *PreeditBuffer;
0N/A
0N/Atypedef struct _XmImXICRec {
0N/A struct _XmImXICRec *next; /* Links all have the same XIM. */
0N/A XIC xic; /* The XIC. */
0N/A Window focus_window; /* Cached information about the XIC. */
0N/A XIMStyle input_style; /* ...ditto... */
0N/A int32_t status_width; /* ...ditto... */
0N/A int32_t preedit_width; /* ...ditto... */
0N/A int32_t sp_height; /* ...ditto... */
0N/A Boolean has_focus; /* Does this XIC have keyboard focus. */
0N/A Boolean anonymous; /* Do we have exclusive rights to this XIC. */
0N/A XmImRefRec widget_refs; /* Widgets referencing this XIC. */
0N/A struct _XmImXICRec **source; /* Original source of shared XICs. */
0N/A PreeditBuffer preedit_buffer;
0N/A} XmImXICRec, *XmImXICInfo;
0N/A
0N/Atypedef struct _XmImShellRec {
0N/A /* per-Shell fields. */
0N/A Widget im_widget; /* Dummy widget to make intrinsics behave. */
0N/A Widget current_widget; /* Widget whose visual we're matching. */
0N/A
0N/A /* per <Shell,XIM> fields. */
0N/A XmImXICInfo shell_xic; /* For PER_SHELL sharing policy. */
0N/A XmImXICInfo iclist; /* All known XICs for this <XIM,Shell>. */
0N/A} XmImShellRec, *XmImShellInfo;
0N/A
0N/Atypedef struct {
0N/A /* per-Display fields. */
0N/A XContext current_xics; /* Map widget -> current XmImXICInfo. */
0N/A
0N/A /* per-XIM fields. */
0N/A XIM xim; /* The XIM. */
0N/A XIMStyles *styles; /* XNQueryInputStyle result. */
0N/A XmImRefRec shell_refs; /* Shells referencing this XIM. */
0N/A} XmImDisplayRec, *XmImDisplayInfo;
0N/A
0N/A#endif
0N/A#endif /* !HEADLESS */
0N/A#endif /* _AWT_UTIL_H_ */