< prev index next >
src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c
Print this page
*** 50,60 ****
static void PreeditDoneCallback(XIC, XPointer, XPointer);
static void PreeditDrawCallback(XIC, XPointer,
XIMPreeditDrawCallbackStruct *);
static void PreeditCaretCallback(XIC, XPointer,
XIMPreeditCaretCallbackStruct *);
! #if defined(__linux__) || defined(MACOSX)
static void StatusStartCallback(XIC, XPointer, XPointer);
static void StatusDoneCallback(XIC, XPointer, XPointer);
static void StatusDrawCallback(XIC, XPointer,
XIMStatusDrawCallbackStruct *);
#endif
--- 50,60 ----
static void PreeditDoneCallback(XIC, XPointer, XPointer);
static void PreeditDrawCallback(XIC, XPointer,
XIMPreeditDrawCallbackStruct *);
static void PreeditCaretCallback(XIC, XPointer,
XIMPreeditCaretCallbackStruct *);
! #if defined(__linux__)
static void StatusStartCallback(XIC, XPointer, XPointer);
static void StatusDoneCallback(XIC, XPointer, XPointer);
static void StatusDrawCallback(XIC, XPointer,
XIMStatusDrawCallbackStruct *);
#endif
*** 64,74 ****
#define PreeditStartIndex 0
#define PreeditDoneIndex 1
#define PreeditDrawIndex 2
#define PreeditCaretIndex 3
! #if defined(__linux__) || defined(MACOSX)
#define StatusStartIndex 4
#define StatusDoneIndex 5
#define StatusDrawIndex 6
#define NCALLBACKS 7
#else
--- 64,74 ----
#define PreeditStartIndex 0
#define PreeditDoneIndex 1
#define PreeditDrawIndex 2
#define PreeditCaretIndex 3
! #if defined(__linux__)
#define StatusStartIndex 4
#define StatusDoneIndex 5
#define StatusDrawIndex 6
#define NCALLBACKS 7
#else
*** 82,99 ****
static XIMProc callback_funcs[NCALLBACKS] = {
(XIMProc)(void *)&PreeditStartCallback,
(XIMProc)PreeditDoneCallback,
(XIMProc)PreeditDrawCallback,
(XIMProc)PreeditCaretCallback,
! #if defined(__linux__) || defined(MACOSX)
(XIMProc)StatusStartCallback,
(XIMProc)StatusDoneCallback,
(XIMProc)StatusDrawCallback,
#endif
};
! #if defined(__linux__) || defined(MACOSX)
#define MAX_STATUS_LEN 100
typedef struct {
Window w; /*status window id */
Window root; /*the root window id */
Window parent; /*parent shell window */
--- 82,99 ----
static XIMProc callback_funcs[NCALLBACKS] = {
(XIMProc)(void *)&PreeditStartCallback,
(XIMProc)PreeditDoneCallback,
(XIMProc)PreeditDrawCallback,
(XIMProc)PreeditCaretCallback,
! #if defined(__linux__)
(XIMProc)StatusStartCallback,
(XIMProc)StatusDoneCallback,
(XIMProc)StatusDrawCallback,
#endif
};
! #if defined(__linux__)
#define MAX_STATUS_LEN 100
typedef struct {
Window w; /*status window id */
Window root; /*the root window id */
Window parent; /*parent shell window */
*** 122,132 ****
XIC ic_active; /* X Input Context for active clients */
XIC ic_passive; /* X Input Context for passive clients */
XIMCallback *callbacks; /* callback parameters */
jobject x11inputmethod; /* global ref to X11InputMethod instance */
/* associated with the XIC */
! #if defined(__linux__) || defined(MACOSX)
StatusWindow *statusWindow; /* our own status window */
#endif
char *lookup_buf; /* buffer used for XmbLookupString */
int lookup_buf_len; /* lookup buffer size in bytes */
} X11InputMethodData;
--- 122,132 ----
XIC ic_active; /* X Input Context for active clients */
XIC ic_passive; /* X Input Context for passive clients */
XIMCallback *callbacks; /* callback parameters */
jobject x11inputmethod; /* global ref to X11InputMethod instance */
/* associated with the XIC */
! #if defined(__linux__)
StatusWindow *statusWindow; /* our own status window */
#endif
char *lookup_buf; /* buffer used for XmbLookupString */
int lookup_buf_len; /* lookup buffer size in bytes */
} X11InputMethodData;
*** 173,183 ****
static X11InputMethodData * getX11InputMethodData(JNIEnv *, jobject);
static void setX11InputMethodData(JNIEnv *, jobject, X11InputMethodData *);
static void destroyX11InputMethodData(JNIEnv *, X11InputMethodData *);
static void freeX11InputMethodData(JNIEnv *, X11InputMethodData *);
! #if defined(__linux__) || defined(MACOSX)
static Window getParentWindow(Window);
#endif
#ifdef __solaris__
/* Prototype for this function is missing in Solaris X11R6 Xlib.h */
--- 173,183 ----
static X11InputMethodData * getX11InputMethodData(JNIEnv *, jobject);
static void setX11InputMethodData(JNIEnv *, jobject, X11InputMethodData *);
static void destroyX11InputMethodData(JNIEnv *, X11InputMethodData *);
static void freeX11InputMethodData(JNIEnv *, X11InputMethodData *);
! #if defined(__linux__)
static Window getParentWindow(Window);
#endif
#ifdef __solaris__
/* Prototype for this function is missing in Solaris X11R6 Xlib.h */
*** 373,383 ****
}
static void
freeX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
{
! #if defined(__linux__) || defined(MACOSX)
if (pX11IMData->statusWindow != NULL){
StatusWindow *sw = pX11IMData->statusWindow;
XFreeGC(awt_display, sw->lightGC);
XFreeGC(awt_display, sw->dimGC);
XFreeGC(awt_display, sw->bgGC);
--- 373,383 ----
}
static void
freeX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
{
! #if defined(__linux__)
if (pX11IMData->statusWindow != NULL){
StatusWindow *sw = pX11IMData->statusWindow;
XFreeGC(awt_display, sw->lightGC);
XFreeGC(awt_display, sw->dimGC);
XFreeGC(awt_display, sw->bgGC);
*** 476,494 ****
}
pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance);
if (pX11IMData == NULL) {
! #if defined(__linux__) || defined(MACOSX)
return False;
#else
return result;
#endif
}
if ((ic = pX11IMData->current_ic) == (XIC)0){
! #if defined(__linux__) || defined(MACOSX)
return False;
#else
return result;
#endif
}
--- 476,494 ----
}
pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance);
if (pX11IMData == NULL) {
! #if defined(__linux__)
return False;
#else
return result;
#endif
}
if ((ic = pX11IMData->current_ic) == (XIC)0){
! #if defined(__linux__)
return False;
#else
return result;
#endif
}
*** 576,586 ****
}
return result;
}
! #if defined(__linux__) || defined(MACOSX)
static StatusWindow *createStatusWindow(Window parent) {
StatusWindow *statusWindow;
XSetWindowAttributes attrib;
unsigned long attribmask;
Window containerWindow;
--- 576,586 ----
}
return result;
}
! #if defined(__linux__)
static StatusWindow *createStatusWindow(Window parent) {
StatusWindow *statusWindow;
XSetWindowAttributes attrib;
unsigned long attribmask;
Window containerWindow;
*** 850,860 ****
}
XMoveWindow(dpy, statusWindow->w, x, y);
}
}
}
! #endif /* __linux__ || MACOSX */
/*
* Creates two XICs, one for active clients and the other for passive
* clients. All information on those XICs are stored in the
* X11InputMethodData given by the pX11IMData parameter.
--- 850,860 ----
}
XMoveWindow(dpy, statusWindow->w, x, y);
}
}
}
! #endif /* __linux__ */
/*
* Creates two XICs, one for active clients and the other for passive
* clients. All information on those XICs are stored in the
* X11InputMethodData given by the pX11IMData parameter.
*** 896,917 ****
return FALSE ;
}
on_the_spot_styles |= XIMStatusNothing;
! #if defined(__linux__) || defined(MACOSX)
/*kinput does not support XIMPreeditCallbacks and XIMStatusArea
at the same time, so use StatusCallback to draw the status
ourself
*/
for (i = 0; i < im_styles->count_styles; i++) {
if (im_styles->supported_styles[i] == (XIMPreeditCallbacks | XIMStatusCallbacks)) {
on_the_spot_styles = (XIMPreeditCallbacks | XIMStatusCallbacks);
break;
}
}
! #endif /* __linux__ || MACOSX */
for (i = 0; i < im_styles->count_styles; i++) {
active_styles |= im_styles->supported_styles[i] & on_the_spot_styles;
passive_styles |= im_styles->supported_styles[i] & ROOT_WINDOW_STYLES;
no_styles |= im_styles->supported_styles[i] & NO_STYLES;
--- 896,917 ----
return FALSE ;
}
on_the_spot_styles |= XIMStatusNothing;
! #if defined(__linux__)
/*kinput does not support XIMPreeditCallbacks and XIMStatusArea
at the same time, so use StatusCallback to draw the status
ourself
*/
for (i = 0; i < im_styles->count_styles; i++) {
if (im_styles->supported_styles[i] == (XIMPreeditCallbacks | XIMStatusCallbacks)) {
on_the_spot_styles = (XIMPreeditCallbacks | XIMStatusCallbacks);
break;
}
}
! #endif /* __linux__ */
for (i = 0; i < im_styles->count_styles; i++) {
active_styles |= im_styles->supported_styles[i] & on_the_spot_styles;
passive_styles |= im_styles->supported_styles[i] & ROOT_WINDOW_STYLES;
no_styles |= im_styles->supported_styles[i] & NO_STYLES;
*** 961,971 ****
XNPreeditDrawCallback, &callbacks[PreeditDrawIndex],
XNPreeditCaretCallback, &callbacks[PreeditCaretIndex],
NULL);
if (preedit == (XVaNestedList)NULL)
goto err;
! #if defined(__linux__) || defined(MACOSX)
/*always try XIMStatusCallbacks for active client...*/
{
status = (XVaNestedList)XVaCreateNestedList(0,
XNStatusStartCallback, &callbacks[StatusStartIndex],
XNStatusDoneCallback, &callbacks[StatusDoneIndex],
--- 961,971 ----
XNPreeditDrawCallback, &callbacks[PreeditDrawIndex],
XNPreeditCaretCallback, &callbacks[PreeditCaretIndex],
NULL);
if (preedit == (XVaNestedList)NULL)
goto err;
! #if defined(__linux__)
/*always try XIMStatusCallbacks for active client...*/
{
status = (XVaNestedList)XVaCreateNestedList(0,
XNStatusStartCallback, &callbacks[StatusStartIndex],
XNStatusDoneCallback, &callbacks[StatusDoneIndex],
*** 983,1001 ****
XNStatusAttributes, status,
NULL);
XFree((void *)status);
XFree((void *)preedit);
}
! #else /* !__linux__ && !MACOSX */
pX11IMData->ic_active = XCreateIC(X11im,
XNClientWindow, w,
XNFocusWindow, w,
XNInputStyle, active_styles,
XNPreeditAttributes, preedit,
NULL);
XFree((void *)preedit);
! #endif /* __linux__ || MACOSX */
} else {
pX11IMData->ic_active = XCreateIC(X11im,
XNClientWindow, w,
XNFocusWindow, w,
XNInputStyle, active_styles,
--- 983,1001 ----
XNStatusAttributes, status,
NULL);
XFree((void *)status);
XFree((void *)preedit);
}
! #else /* !__linux__ */
pX11IMData->ic_active = XCreateIC(X11im,
XNClientWindow, w,
XNFocusWindow, w,
XNInputStyle, active_styles,
XNPreeditAttributes, preedit,
NULL);
XFree((void *)preedit);
! #endif /* __linux__ */
} else {
pX11IMData->ic_active = XCreateIC(X11im,
XNClientWindow, w,
XNFocusWindow, w,
XNInputStyle, active_styles,
*** 1171,1181 ****
{
/*ARGSUSED*/
/* printf("Native: PreeditCaretCallback\n"); */
}
! #if defined(__linux__) || defined(MACOSX)
static void
StatusStartCallback(XIC ic, XPointer client_data, XPointer call_data)
{
/*ARGSUSED*/
/*printf("StatusStartCallback:\n"); */
--- 1171,1181 ----
{
/*ARGSUSED*/
/* printf("Native: PreeditCaretCallback\n"); */
}
! #if defined(__linux__)
static void
StatusStartCallback(XIC ic, XPointer client_data, XPointer call_data)
{
/*ARGSUSED*/
/*printf("StatusStartCallback:\n"); */
*** 1260,1270 ****
}
finally:
AWT_UNLOCK();
}
! #endif /* __linux__ || MACOSX */
static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_data) {
JNIEnv *env = GetJNIEnv();
XIMText * text = (XIMText *)call_data;
X11InputMethodData *pX11IMData = NULL;
--- 1260,1270 ----
}
finally:
AWT_UNLOCK();
}
! #endif /* __linux__ */
static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_data) {
JNIEnv *env = GetJNIEnv();
XIMText * text = (XIMText *)call_data;
X11InputMethodData *pX11IMData = NULL;
*** 1354,1371 ****
dpy = (Display *)jlong_to_ptr(display);
/* Use IMInstantiate call back only on Linux, as there is a bug in Solaris
(4768335)
*/
! #if defined(__linux__) || defined(MACOSX)
registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL,
NULL, (XIDProc)OpenXIMCallback, NULL);
if (!registered) {
/* directly call openXIM callback */
#endif
OpenXIMCallback(dpy, NULL, NULL);
! #if defined(__linux__) || defined(MACOSX)
}
#endif
AWT_UNLOCK();
--- 1354,1371 ----
dpy = (Display *)jlong_to_ptr(display);
/* Use IMInstantiate call back only on Linux, as there is a bug in Solaris
(4768335)
*/
! #if defined(__linux__)
registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL,
NULL, (XIDProc)OpenXIMCallback, NULL);
if (!registered) {
/* directly call openXIM callback */
#endif
OpenXIMCallback(dpy, NULL, NULL);
! #if defined(__linux__)
}
#endif
AWT_UNLOCK();
*** 1396,1408 ****
return JNI_FALSE;
}
globalRef = (*env)->NewGlobalRef(env, this);
pX11IMData->x11inputmethod = globalRef;
! #if defined(__linux__) || defined(MACOSX)
pX11IMData->statusWindow = NULL;
! #endif /* __linux__ || MACOSX */
pX11IMData->lookup_buf = 0;
pX11IMData->lookup_buf_len = 0;
if (createXIC(env, pX11IMData, (Window)window) == False) {
--- 1396,1408 ----
return JNI_FALSE;
}
globalRef = (*env)->NewGlobalRef(env, this);
pX11IMData->x11inputmethod = globalRef;
! #if defined(__linux__)
pX11IMData->statusWindow = NULL;
! #endif /* __linux__ */
pX11IMData->lookup_buf = 0;
pX11IMData->lookup_buf_len = 0;
if (createXIC(env, pX11IMData, (Window)window) == False) {
*** 1448,1465 ****
*/
setXICWindowFocus(pX11IMData->current_ic, w);
setXICFocus(pX11IMData->current_ic, req);
currentX11InputMethodInstance = pX11IMData->x11inputmethod;
currentFocusWindow = w;
! #if defined(__linux__) || defined(MACOSX)
if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on)
onoffStatusWindow(pX11IMData, w, True);
#endif
} else {
currentX11InputMethodInstance = NULL;
currentFocusWindow = 0;
! #if defined(__linux__) || defined(MACOSX)
onoffStatusWindow(pX11IMData, 0, False);
if (pX11IMData->current_ic != NULL)
#endif
setXICFocus(pX11IMData->current_ic, req);
--- 1448,1465 ----
*/
setXICWindowFocus(pX11IMData->current_ic, w);
setXICFocus(pX11IMData->current_ic, req);
currentX11InputMethodInstance = pX11IMData->x11inputmethod;
currentFocusWindow = w;
! #if defined(__linux__)
if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on)
onoffStatusWindow(pX11IMData, w, True);
#endif
} else {
currentX11InputMethodInstance = NULL;
currentFocusWindow = 0;
! #if defined(__linux__)
onoffStatusWindow(pX11IMData, 0, False);
if (pX11IMData->current_ic != NULL)
#endif
setXICFocus(pX11IMData->current_ic, req);
*** 1490,1500 ****
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_turnoffStatusWindow
(JNIEnv *env, jobject this)
{
! #if defined(__linux__) || defined(MACOSX)
X11InputMethodData *pX11IMData;
StatusWindow *statusWindow;
AWT_LOCK();
--- 1490,1500 ----
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_turnoffStatusWindow
(JNIEnv *env, jobject this)
{
! #if defined(__linux__)
X11InputMethodData *pX11IMData;
StatusWindow *statusWindow;
AWT_LOCK();
*** 1605,1615 ****
(JNIEnv *env, jobject this, jboolean enable)
{
X11InputMethodData *pX11IMData;
char * ret = NULL;
XVaNestedList pr_atrb;
! #if defined(__linux__) || defined(MACOSX)
Boolean calledXSetICFocus = False;
#endif
AWT_LOCK();
pX11IMData = getX11InputMethodData(env, this);
--- 1605,1615 ----
(JNIEnv *env, jobject this, jboolean enable)
{
X11InputMethodData *pX11IMData;
char * ret = NULL;
XVaNestedList pr_atrb;
! #if defined(__linux__)
Boolean calledXSetICFocus = False;
#endif
AWT_LOCK();
pX11IMData = getX11InputMethodData(env, this);
*** 1617,1627 ****
if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
AWT_UNLOCK();
return JNI_FALSE;
}
! #if defined(__linux__) || defined(MACOSX)
if (NULL != pX11IMData->statusWindow) {
Window focus = 0;
int revert_to;
#if defined(_LP64) && !defined(_LITTLE_ENDIAN)
// The Window value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib
--- 1617,1627 ----
if ((pX11IMData == NULL) || (pX11IMData->current_ic == NULL)) {
AWT_UNLOCK();
return JNI_FALSE;
}
! #if defined(__linux__)
if (NULL != pX11IMData->statusWindow) {
Window focus = 0;
int revert_to;
#if defined(_LP64) && !defined(_LITTLE_ENDIAN)
// The Window value which is used for XGetICValues must be 32bit on BigEndian XOrg's xlib
*** 1645,1655 ****
pr_atrb = XVaCreateNestedList(0,
XNPreeditState, (enable ? XIMPreeditEnable : XIMPreeditDisable),
NULL);
ret = XSetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
XFree((void *)pr_atrb);
! #if defined(__linux__) || defined(MACOSX)
if (calledXSetICFocus) {
XSetICFocus(pX11IMData->ic_active);
}
#endif
AWT_UNLOCK();
--- 1645,1655 ----
pr_atrb = XVaCreateNestedList(0,
XNPreeditState, (enable ? XIMPreeditEnable : XIMPreeditDisable),
NULL);
ret = XSetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
XFree((void *)pr_atrb);
! #if defined(__linux__)
if (calledXSetICFocus) {
XSetICFocus(pX11IMData->ic_active);
}
#endif
AWT_UNLOCK();
*** 1712,1729 ****
}
JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
(JNIEnv *env, jobject this, jlong window)
{
! #if defined(__linux__) || defined(MACOSX)
AWT_LOCK();
adjustStatusWindow(window);
AWT_UNLOCK();
#endif
}
! #if defined(__linux__) || defined(MACOSX)
static Window getParentWindow(Window w)
{
Window root=None, parent=None, *ignore_children=NULL;
unsigned int ignore_uint=0;
Status status = 0;
--- 1712,1729 ----
}
JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
(JNIEnv *env, jobject this, jlong window)
{
! #if defined(__linux__)
AWT_LOCK();
adjustStatusWindow(window);
AWT_UNLOCK();
#endif
}
! #if defined(__linux__)
static Window getParentWindow(Window w)
{
Window root=None, parent=None, *ignore_children=NULL;
unsigned int ignore_uint=0;
Status status = 0;
< prev index next >