3261N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * Callback function pointers: the order has to match the *Index 0N/A int x, y;
/*parent's upperleft position */ 0N/A * X11InputMethodData keeps per X11InputMethod instance information. A pointer 0N/A * to this data structure is kept in an X11InputMethod object (pData). 0N/A /* associated with the XIC */ 0N/A * When XIC is created, a global reference is created for 0N/A * sun.awt.X11InputMethod object so that it could be used by the XIM callback 0N/A * functions. This could be a dangerous thing to do when the original 0N/A * X11InputMethod object is garbage collected and as a result, 0N/A * destroyX11InputMethodData is called to delete the global reference. 0N/A * If any XIM callback function still holds and uses the "already deleted" 0N/A * global reference, disaster is going to happen. So we have to maintain 0N/A * a list for these global references which is consulted first when the 0N/A * callback functions or any function tries to use "currentX11InputMethodObject" 0N/A * which always refers to the global reference try to use it. 0N/A/* reference to the current X11InputMethod instance, it is always 0N/A point to the global reference to the X11InputMethodObject since 0N/A it could be referenced by different threads. */ 0N/A method. (the best place to put this 0N/A information should be 0N/A currentX11InputMethodInstance's pData) */ 0N/A/* Solaris XIM Extention */ 0N/A/* Prototype for this function is missing in Solaris X11R6 Xlib.h */ 0N/A * It is used in setting the time in Java-level InputEvents 0N/A#
endif /* XAWT_HACK */ 0N/A * Converts the wchar_t string to a multi-byte string calling wcstombs(). A 0N/A * buffer is allocated by malloc() to store the multi-byte string. NULL is 0N/A * returned if the given wchar_t string pointer is NULL or buffer allocation is 0N/A /* TODO: check return values... Handle invalid characters properly... */ 0N/A * Find a class for the given class name and return a global reference to the 0N/A * Returns True if the global reference is still in the list, 0N/A * Add the new created global reference to the list. 0N/A * Remove the global reference from the list. 0N/A /* cX11InputMethodGRef always refers to the current node while 0N/A pX11InputMethodGRef refers to the previous node. 0N/A return;
/* Not found. */ 0N/A * In case the XIM server was killed somehow, reset X11InputMethodData. 0N/A The order of the following calls is critical since "imInstance" may 0N/A point to the global reference itself, if "freeX11InputMethodData" is called 0N/A first, the global reference will be destroyed and "setX11InputMethodData" 0N/A will in fact fail silently. So pX11IMData will not be set to NULL. 0N/A This could make the original java object refers to a deleted pX11IMData 0N/A/* this function should be called within AWT_LOCK() */ 0N/A /* Remove the global reference from the list, so that 0N/A the callback function or whoever refers to it could know. 0N/A * Sets or unsets the focus to the given XIC. 0N/A * Sets the focus window to the given XIC. 0N/A * Invokes XmbLookupString() to get something from the XIM. It invokes 0N/A * X11InputMethod.dispatchCommittedText() if XmbLookupString() returns 0N/A * committed text. This function is called from handleKeyEvent in canvas.c and 0N/A * it's under the Motif event loop thread context. 0N/A * Buffer usage: There is a bug in XFree86-4.3.0 XmbLookupString implementation, 0N/A * where it never returns XBufferOverflow. We need to allocate the initial lookup buffer 0N/A * big enough, so that the possibility that user encounters this problem is relatively 0N/A * small. When this bug gets fixed, we can make the initial buffer size smaller. 0N/A * Note that XmbLookupString() sometimes produces a non-null-terminated string. 0N/A * Returns True when there is a keysym value to be handled. 0N/A printf("lookupString: entering...\n"); 0N/A /* allocate the lookup buffer at the first invocation */ 0N/A * In case of overflow, a buffer is allocated and it retries 0N/A * XmbLookupString(). 0N/A /* Get keysym without taking modifiers into account first to map 0N/A * to AWT keyCode table. 0N/A printf("lookupString: status=XLookupChars, type=%d, state=%x, keycode=%x, keysym=%x\n", 0N/A event->type, event->state, event->keycode, keysym); 0N/A "dispatchCommittedText",
0N/A printf("lookupString: status=XLookupKeySym, type=%d, state=%x, keycode=%x, keysym=%x\n", 0N/A event->type, event->state, event->keycode, keysym); 0N/A printf("lookupString: status=XLookupNone, type=%d, state=%x, keycode=%x, keysym=%x\n", 0N/A event->type, event->state, event->keycode, keysym); 0N/A /* Variable for XCreateFontSet()*/ 0N/A unsigned long valuemask = 0;
/*ignore XGCvalue and use defaults*/ 0N/A /*hardcode the size right now, should get the size base on font*/ 0N/A bw =
2;
/*xwa.border_width does not have the correct value*/ 0N/A /*compare the size difference between parent container 0N/A and shell widget, the diff should be the border frame 0N/A and title bar height (?)*/ 0N/A /*get the size of root window*/ 0N/A "-*-*-medium-r-normal-*-*-120-*-*-*-*",
0N/A /* In case we didn't find the font set, release the list of missing characters */ 0N/A/* This method is to turn off or turn on the status window. */ 0N/A "getCurrentParentWindow",
0N/A /*too bad we failed to create a fontset for this locale*/ 0N/A "[InputMethod ON]",
strlen(
"[InputMethod ON]"));
0N/A /*need to reset the stackMode...*/ 0N/A case VisibilityNotify: 4632N/A#
endif /* __linux__ || MACOSX */ 0N/A * Creates two XICs, one for active clients and the other for passive 0N/A * clients. All information on those XICs are stored in the 0N/A * X11InputMethodData given by the pX11IMData parameter. 0N/A * For active clients: Try to use preedit callback to support 0N/A * on-the-spot. If tc is not null, the XIC to be created will 0N/A * share the Status Area with Motif widgets (TextComponents). If the 0N/A * preferable styles can't be used, fallback to root-window styles. If 0N/A * root-window styles failed, fallback to None styles. 0N/A * For passive clients: Try to use root-window styles. If failed, 0N/A * fallback to None styles. 0N/A * If the parent window has one or more TextComponents, the status 0N/A * area of Motif will be shared with the created XIC. Otherwise, 0N/A * root-window style status is used. 0N/A /*kinput does not support XIMPreeditCallbacks and XIMStatusArea 0N/A at the same time, so use StatusCallback to draw the status 4632N/A#
else /*! __linux__ && !MACOSX */ 0N/A * If the parent window has one or more TextComponents, the status 0N/A * area of Motif will be shared with the created XIC. Otherwise, 0N/A * root-window style status is used. 4632N/A#
endif /* __linux__ || MACOSX */ 0N/A /*always try XIMStatusCallbacks for active client...*/ 4632N/A#
else /* !__linux__ && !MACOSX */ 4632N/A#
endif /* __linux__ || MACOSX */ 0N/A * Use commit string call back if possible. 0N/A * This will ensure the correct order of preedit text and commit text 0N/A /* Add the global reference object to X11InputMethod to the list. */ 0N/A /* printf("Native: PreeditCaretCallback\n"); */ 0N/A /* printf("Native: StatusStartCallback\n"); */ 0N/A * Translate the preedit draw callback items to Java values and invoke 0N/A * X11InputMethod.dispatchComposedText(). 0N/A * client_data: X11InputMethod object 0N/A /* printf("Native: PreeditDrawCallback() \n"); */ 0N/A * Optimization to avoid copying the array 0N/A "dispatchComposedText",
0N/A /* printf("Native: PreeditCaretCallback\n"); */ 0N/A /*printf("StatusStartCallback:\n"); */ 0N/A /*printf("StatusDoneCallback:\n"); */ 0N/A /*printf("StatusDrawCallback:\n"); */ 0N/A /*just turnoff the status window 0N/A paintStatusWindow(statusWindow); 4632N/A#
endif /* __linux__ || MACOSX */ 0N/A "dispatchCommittedText",
0N/A /* mark that XIM server was destroyed */ 2789N/A /* free the old pX11IMData and set it to null. this also avoids crashing 2789N/A * the jvm if the XIM server reappears */ 0N/A * Class: java_sun_awt_motif_X11InputMethod 0N/A/* This function gets called from the static initializer for 0N/A to initialize the fieldIDs for fields that may be accessed from C */ 0N/A/* Use IMInstantiate call back only on Linux, as there is a bug in Solaris 0N/A /* directly call openXIM callback */ 4632N/A#
else /* !__linux__ && !MACOSX */ 4632N/A#
endif /* __linux__ || MACOSX */ 0N/A * On Solaris2.6, setXICWindowFocus() has to be invoked 0N/A * before setting focus. 0N/A * On Solaris2.6, setXICWindowFocus() has to be invoked 0N/A * before setting focus. 0N/A * If there is no reference to the current XIC, try to reset both XICs. 0N/A /*it may also means that the real client component does 0N/A not have focus -- has been deactivated... its xic should 0N/A not have the focus, bug#4284651 showes reset XIC for htt 0N/A may bring the focus back, so de-focus it again. 0N/A /*do nothing for linux? */ 0N/A * Class: sun_awt_X11InputMethod 0N/A * Method: setCompositionEnabledNative 0N/A * This method tries to set the XNPreeditState attribute associated with the current 0N/A * XIC to the passed in 'enable' state. 0N/A * Return JNI_TRUE if XNPreeditState attribute is successfully changed to the 0N/A * 'enable' state; Otherwise, if XSetICValues fails to set this attribute, 0N/A * java.lang.UnsupportedOperationException will be thrown. JNI_FALSE is returned if this 0N/A * method fails due to other reasons. 0N/A * Class: sun_awt_X11InputMethod 0N/A * Method: isCompositionEnabledNative 0N/A * This method tries to get the XNPreeditState attribute associated with the current XIC. 0N/A * Return JNI_TRUE if the XNPreeditState is successfully retrieved. Otherwise, if 0N/A * XGetICValues fails to get this attribute, java.lang.UnsupportedOperationException 0N/A * will be thrown. JNI_FALSE is returned if this method fails due to other reasons.