8240290: Clean the "libawt_xawt" library from code for macOS

Reviewed-by: prr
This commit is contained in:
Sergey Bylokhov 2020-04-14 08:19:48 -07:00
parent 2d350addf7
commit 74b556d666
4 changed files with 35 additions and 42 deletions

View File

@ -405,15 +405,8 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
DTRACE_PRINTLN("RENDER extension available"); DTRACE_PRINTLN("RENDER extension available");
xrenderLibHandle = dlopen("libXrender.so.1", RTLD_LAZY | RTLD_GLOBAL); xrenderLibHandle = dlopen("libXrender.so.1", RTLD_LAZY | RTLD_GLOBAL);
#ifdef MACOSX
#define XRENDER_LIB "/usr/X11/lib/libXrender.dylib"
#else
#define XRENDER_LIB "libXrender.so"
#endif
if (xrenderLibHandle == NULL) { if (xrenderLibHandle == NULL) {
xrenderLibHandle = dlopen(XRENDER_LIB, xrenderLibHandle = dlopen("libXrender.so", RTLD_LAZY | RTLD_GLOBAL);
RTLD_LAZY | RTLD_GLOBAL);
} }
#if defined(__solaris__) #if defined(__solaris__)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -52,7 +52,7 @@ static void PreeditDrawCallback(XIC, XPointer,
XIMPreeditDrawCallbackStruct *); XIMPreeditDrawCallbackStruct *);
static void PreeditCaretCallback(XIC, XPointer, static void PreeditCaretCallback(XIC, XPointer,
XIMPreeditCaretCallbackStruct *); XIMPreeditCaretCallbackStruct *);
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
static void StatusStartCallback(XIC, XPointer, XPointer); static void StatusStartCallback(XIC, XPointer, XPointer);
static void StatusDoneCallback(XIC, XPointer, XPointer); static void StatusDoneCallback(XIC, XPointer, XPointer);
static void StatusDrawCallback(XIC, XPointer, static void StatusDrawCallback(XIC, XPointer,
@ -66,7 +66,7 @@ static void StatusDrawCallback(XIC, XPointer,
#define PreeditDoneIndex 1 #define PreeditDoneIndex 1
#define PreeditDrawIndex 2 #define PreeditDrawIndex 2
#define PreeditCaretIndex 3 #define PreeditCaretIndex 3
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
#define StatusStartIndex 4 #define StatusStartIndex 4
#define StatusDoneIndex 5 #define StatusDoneIndex 5
#define StatusDrawIndex 6 #define StatusDrawIndex 6
@ -84,14 +84,14 @@ static XIMProc callback_funcs[NCALLBACKS] = {
(XIMProc)PreeditDoneCallback, (XIMProc)PreeditDoneCallback,
(XIMProc)PreeditDrawCallback, (XIMProc)PreeditDrawCallback,
(XIMProc)PreeditCaretCallback, (XIMProc)PreeditCaretCallback,
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
(XIMProc)StatusStartCallback, (XIMProc)StatusStartCallback,
(XIMProc)StatusDoneCallback, (XIMProc)StatusDoneCallback,
(XIMProc)StatusDrawCallback, (XIMProc)StatusDrawCallback,
#endif #endif
}; };
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
#define MAX_STATUS_LEN 100 #define MAX_STATUS_LEN 100
typedef struct { typedef struct {
Window w; /*status window id */ Window w; /*status window id */
@ -124,7 +124,7 @@ typedef struct _X11InputMethodData {
XIMCallback *callbacks; /* callback parameters */ XIMCallback *callbacks; /* callback parameters */
jobject x11inputmethod; /* global ref to X11InputMethod instance */ jobject x11inputmethod; /* global ref to X11InputMethod instance */
/* associated with the XIC */ /* associated with the XIC */
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
StatusWindow *statusWindow; /* our own status window */ StatusWindow *statusWindow; /* our own status window */
#endif #endif
char *lookup_buf; /* buffer used for XmbLookupString */ char *lookup_buf; /* buffer used for XmbLookupString */
@ -175,7 +175,7 @@ static X11InputMethodData * getX11InputMethodData(JNIEnv *, jobject);
static void setX11InputMethodData(JNIEnv *, jobject, X11InputMethodData *); static void setX11InputMethodData(JNIEnv *, jobject, X11InputMethodData *);
static void destroyX11InputMethodData(JNIEnv *, X11InputMethodData *); static void destroyX11InputMethodData(JNIEnv *, X11InputMethodData *);
static void freeX11InputMethodData(JNIEnv *, X11InputMethodData *); static void freeX11InputMethodData(JNIEnv *, X11InputMethodData *);
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
static Window getParentWindow(Window); static Window getParentWindow(Window);
#endif #endif
@ -375,7 +375,7 @@ destroyX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
static void static void
freeX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData) freeX11InputMethodData(JNIEnv *env, X11InputMethodData *pX11IMData)
{ {
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
if (pX11IMData->statusWindow != NULL){ if (pX11IMData->statusWindow != NULL){
StatusWindow *sw = pX11IMData->statusWindow; StatusWindow *sw = pX11IMData->statusWindow;
XFreeGC(awt_display, sw->lightGC); XFreeGC(awt_display, sw->lightGC);
@ -478,7 +478,7 @@ awt_x11inputmethod_lookupString(XKeyPressedEvent *event, KeySym *keysymp)
pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance); pX11IMData = getX11InputMethodData(env, currentX11InputMethodInstance);
if (pX11IMData == NULL) { if (pX11IMData == NULL) {
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
return False; return False;
#else #else
return result; return result;
@ -486,7 +486,7 @@ awt_x11inputmethod_lookupString(XKeyPressedEvent *event, KeySym *keysymp)
} }
if ((ic = pX11IMData->current_ic) == (XIC)0){ if ((ic = pX11IMData->current_ic) == (XIC)0){
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
return False; return False;
#else #else
return result; return result;
@ -578,7 +578,7 @@ awt_x11inputmethod_lookupString(XKeyPressedEvent *event, KeySym *keysymp)
return result; return result;
} }
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
static StatusWindow *createStatusWindow(Window parent) { static StatusWindow *createStatusWindow(Window parent) {
StatusWindow *statusWindow; StatusWindow *statusWindow;
XSetWindowAttributes attrib; XSetWindowAttributes attrib;
@ -852,7 +852,7 @@ static void adjustStatusWindow(Window shell) {
} }
} }
} }
#endif /* __linux__ || MACOSX */ #endif /* __linux__ */
/* /*
* Creates two XICs, one for active clients and the other for passive * Creates two XICs, one for active clients and the other for passive
@ -898,7 +898,7 @@ createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
on_the_spot_styles |= XIMStatusNothing; on_the_spot_styles |= XIMStatusNothing;
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
/*kinput does not support XIMPreeditCallbacks and XIMStatusArea /*kinput does not support XIMPreeditCallbacks and XIMStatusArea
at the same time, so use StatusCallback to draw the status at the same time, so use StatusCallback to draw the status
ourself ourself
@ -909,7 +909,7 @@ createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
break; break;
} }
} }
#endif /* __linux__ || MACOSX */ #endif /* __linux__ */
for (i = 0; i < im_styles->count_styles; i++) { for (i = 0; i < im_styles->count_styles; i++) {
active_styles |= im_styles->supported_styles[i] & on_the_spot_styles; active_styles |= im_styles->supported_styles[i] & on_the_spot_styles;
@ -963,7 +963,7 @@ createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
NULL); NULL);
if (preedit == (XVaNestedList)NULL) if (preedit == (XVaNestedList)NULL)
goto err; goto err;
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
/*always try XIMStatusCallbacks for active client...*/ /*always try XIMStatusCallbacks for active client...*/
{ {
status = (XVaNestedList)XVaCreateNestedList(0, status = (XVaNestedList)XVaCreateNestedList(0,
@ -985,7 +985,7 @@ createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
XFree((void *)status); XFree((void *)status);
XFree((void *)preedit); XFree((void *)preedit);
} }
#else /* !__linux__ && !MACOSX */ #else /* !__linux__ */
pX11IMData->ic_active = XCreateIC(X11im, pX11IMData->ic_active = XCreateIC(X11im,
XNClientWindow, w, XNClientWindow, w,
XNFocusWindow, w, XNFocusWindow, w,
@ -993,7 +993,7 @@ createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
XNPreeditAttributes, preedit, XNPreeditAttributes, preedit,
NULL); NULL);
XFree((void *)preedit); XFree((void *)preedit);
#endif /* __linux__ || MACOSX */ #endif /* __linux__ */
} else { } else {
pX11IMData->ic_active = XCreateIC(X11im, pX11IMData->ic_active = XCreateIC(X11im,
XNClientWindow, w, XNClientWindow, w,
@ -1173,7 +1173,7 @@ PreeditCaretCallback(XIC ic, XPointer client_data,
/* printf("Native: PreeditCaretCallback\n"); */ /* printf("Native: PreeditCaretCallback\n"); */
} }
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
static void static void
StatusStartCallback(XIC ic, XPointer client_data, XPointer call_data) StatusStartCallback(XIC ic, XPointer client_data, XPointer call_data)
{ {
@ -1262,7 +1262,7 @@ StatusDrawCallback(XIC ic, XPointer client_data,
finally: finally:
AWT_UNLOCK(); AWT_UNLOCK();
} }
#endif /* __linux__ || MACOSX */ #endif /* __linux__ */
static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_data) { static void CommitStringCallback(XIC ic, XPointer client_data, XPointer call_data) {
JNIEnv *env = GetJNIEnv(); JNIEnv *env = GetJNIEnv();
@ -1356,14 +1356,14 @@ Java_sun_awt_X11_XInputMethod_openXIMNative(JNIEnv *env,
/* Use IMInstantiate call back only on Linux, as there is a bug in Solaris /* Use IMInstantiate call back only on Linux, as there is a bug in Solaris
(4768335) (4768335)
*/ */
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL, registered = XRegisterIMInstantiateCallback(dpy, NULL, NULL,
NULL, (XIDProc)OpenXIMCallback, NULL); NULL, (XIDProc)OpenXIMCallback, NULL);
if (!registered) { if (!registered) {
/* directly call openXIM callback */ /* directly call openXIM callback */
#endif #endif
OpenXIMCallback(dpy, NULL, NULL); OpenXIMCallback(dpy, NULL, NULL);
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
} }
#endif #endif
@ -1398,9 +1398,9 @@ Java_sun_awt_X11_XInputMethod_createXICNative(JNIEnv *env,
globalRef = (*env)->NewGlobalRef(env, this); globalRef = (*env)->NewGlobalRef(env, this);
pX11IMData->x11inputmethod = globalRef; pX11IMData->x11inputmethod = globalRef;
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
pX11IMData->statusWindow = NULL; pX11IMData->statusWindow = NULL;
#endif /* __linux__ || MACOSX */ #endif /* __linux__ */
pX11IMData->lookup_buf = 0; pX11IMData->lookup_buf = 0;
pX11IMData->lookup_buf_len = 0; pX11IMData->lookup_buf_len = 0;
@ -1450,14 +1450,14 @@ Java_sun_awt_X11_XInputMethod_setXICFocusNative(JNIEnv *env,
setXICFocus(pX11IMData->current_ic, req); setXICFocus(pX11IMData->current_ic, req);
currentX11InputMethodInstance = pX11IMData->x11inputmethod; currentX11InputMethodInstance = pX11IMData->x11inputmethod;
currentFocusWindow = w; currentFocusWindow = w;
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on) if (active && pX11IMData->statusWindow && pX11IMData->statusWindow->on)
onoffStatusWindow(pX11IMData, w, True); onoffStatusWindow(pX11IMData, w, True);
#endif #endif
} else { } else {
currentX11InputMethodInstance = NULL; currentX11InputMethodInstance = NULL;
currentFocusWindow = 0; currentFocusWindow = 0;
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
onoffStatusWindow(pX11IMData, 0, False); onoffStatusWindow(pX11IMData, 0, False);
if (pX11IMData->current_ic != NULL) if (pX11IMData->current_ic != NULL)
#endif #endif
@ -1492,7 +1492,7 @@ JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_initIDs
JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_turnoffStatusWindow JNIEXPORT void JNICALL Java_sun_awt_X11InputMethodBase_turnoffStatusWindow
(JNIEnv *env, jobject this) (JNIEnv *env, jobject this)
{ {
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
X11InputMethodData *pX11IMData; X11InputMethodData *pX11IMData;
StatusWindow *statusWindow; StatusWindow *statusWindow;
@ -1607,7 +1607,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_setCompositionEnabled
X11InputMethodData *pX11IMData; X11InputMethodData *pX11IMData;
char * ret = NULL; char * ret = NULL;
XVaNestedList pr_atrb; XVaNestedList pr_atrb;
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
Boolean calledXSetICFocus = False; Boolean calledXSetICFocus = False;
#endif #endif
@ -1619,7 +1619,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_setCompositionEnabled
return JNI_FALSE; return JNI_FALSE;
} }
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
if (NULL != pX11IMData->statusWindow) { if (NULL != pX11IMData->statusWindow) {
Window focus = 0; Window focus = 0;
int revert_to; int revert_to;
@ -1647,7 +1647,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_setCompositionEnabled
NULL); NULL);
ret = XSetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL); ret = XSetICValues(pX11IMData->current_ic, XNPreeditAttributes, pr_atrb, NULL);
XFree((void *)pr_atrb); XFree((void *)pr_atrb);
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
if (calledXSetICFocus) { if (calledXSetICFocus) {
XSetICFocus(pX11IMData->ic_active); XSetICFocus(pX11IMData->ic_active);
} }
@ -1714,14 +1714,14 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11InputMethodBase_isCompositionEnabledN
JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
(JNIEnv *env, jobject this, jlong window) (JNIEnv *env, jobject this, jlong window)
{ {
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
AWT_LOCK(); AWT_LOCK();
adjustStatusWindow(window); adjustStatusWindow(window);
AWT_UNLOCK(); AWT_UNLOCK();
#endif #endif
} }
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
static Window getParentWindow(Window w) static Window getParentWindow(Window w)
{ {
Window root=None, parent=None, *ignore_children=NULL; Window root=None, parent=None, *ignore_children=NULL;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,7 +50,7 @@
#include "java_awt_event_InputEvent.h" #include "java_awt_event_InputEvent.h"
#if defined(__linux__) || defined(MACOSX) #if defined(__linux__)
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -906,7 +906,7 @@ handleKeyEventWithNumLockMask(XEvent *event, KeySym *keysym)
{ {
KeySym originalKeysym = *keysym; KeySym originalKeysym = *keysym;
#if !defined(__linux__) && !defined(MACOSX) #if !defined(__linux__)
/* The following code on Linux will cause the keypad keys /* The following code on Linux will cause the keypad keys
* not to echo on JTextField when the NumLock is on. The * not to echo on JTextField when the NumLock is on. The
* keysyms will be 0, because the last parameter 2 is not defined. * keysyms will be 0, because the last parameter 2 is not defined.