< prev index next >

src/java.desktop/aix/classes/sun/awt/X11InputMethod.java

Print this page

        

*** 125,134 **** --- 125,137 ---- // private data (X11InputMethodData structure defined in // awt_InputMethod.c) for native methods // this structure needs to be accessed within AWT_LOCK/UNLOCK private transient long pData = 0; // accessed by native + // to keep the instance of activating if IM resumed + static protected X11InputMethod activatedInstance = null; + // Initialize highlight mapping table static { @SuppressWarnings({"unchecked", "rawtypes"}) Map<TextAttribute, ?> styles[] = new Map[4]; HashMap<TextAttribute, Object> map;
*** 279,289 **** /** * Reset the composition state to the current composition state. */ private void resetCompositionState() { ! if (compositionEnableSupported) { try { /* Restore the composition mode to the last saved composition mode. */ setCompositionEnabled(savedCompositionState); } catch (UnsupportedOperationException e) { --- 282,292 ---- /** * Reset the composition state to the current composition state. */ private void resetCompositionState() { ! if (compositionEnableSupported && haveActiveClient()) { try { /* Restore the composition mode to the last saved composition mode. */ setCompositionEnabled(savedCompositionState); } catch (UnsupportedOperationException e) {
*** 311,329 **** --- 314,340 ---- /** * Activate input method. */ public synchronized void activate() { + activatedInstance = this; clientComponentWindow = getClientComponentWindow(); if (clientComponentWindow == null) return; if (lastXICFocussedComponent != null){ if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("XICFocused {0}, AWTFocused {1}", lastXICFocussedComponent, awtFocussedComponent); } + if (lastXICFocussedComponent != awtFocussedComponent) { + ComponentPeer lastXICFocussedComponentPeer = getPeer(lastXICFocussedComponent); + if (lastXICFocussedComponentPeer != null){ + setXICFocus(lastXICFocussedComponentPeer, false, isLastXICActive); + } + } + lastXICFocussedComponent = null; } if (pData == 0) { if (!createXIC()) { return;
*** 334,365 **** /* reset input context if necessary and set the XIC focus */ resetXICifneeded(); ComponentPeer lastXICFocussedComponentPeer = null; ComponentPeer awtFocussedComponentPeer = getPeer(awtFocussedComponent); - if (lastXICFocussedComponent != null) { - lastXICFocussedComponentPeer = getPeer(lastXICFocussedComponent); - } - - /* If the last XIC focussed component has a different peer as the - current focussed component, change the XIC focus to the newly - focussed component. - */ - if (isLastTemporary || lastXICFocussedComponentPeer != awtFocussedComponentPeer || - isLastXICActive != haveActiveClient()) { - if (lastXICFocussedComponentPeer != null) { - setXICFocus(lastXICFocussedComponentPeer, false, isLastXICActive); - } if (awtFocussedComponentPeer != null) { setXICFocus(awtFocussedComponentPeer, true, haveActiveClient()); } lastXICFocussedComponent = awtFocussedComponent; isLastXICActive = haveActiveClient(); - } - resetCompositionState(); isActive = true; } protected abstract boolean createXIC(); /** --- 345,365 ---- /* reset input context if necessary and set the XIC focus */ resetXICifneeded(); ComponentPeer lastXICFocussedComponentPeer = null; ComponentPeer awtFocussedComponentPeer = getPeer(awtFocussedComponent); + setStatusAreaVisible(true, pData); if (awtFocussedComponentPeer != null) { setXICFocus(awtFocussedComponentPeer, true, haveActiveClient()); } lastXICFocussedComponent = awtFocussedComponent; isLastXICActive = haveActiveClient(); isActive = true; + if (savedCompositionState) { + resetCompositionState(); + } } protected abstract boolean createXIC(); /**
*** 383,406 **** --- 383,419 ---- called, it can be restored correctly till activate is called on the newly focused component. (See also sun/awt/im/InputContext and bug 6184471). Last note, getCompositionState should be called before setXICFocus since setXICFocus here sets the XIC to 0. */ + activatedInstance = null; savedCompositionState = getCompositionState(); if (isTemporary){ //turn the status window off... turnoffStatusWindow(); } + if (!isTemporary){ + if (awtFocussedComponent != null ){ + ComponentPeer awtFocussedComponentPeer = getPeer(awtFocussedComponent); + if (awtFocussedComponentPeer != null){ + setXICFocus(awtFocussedComponentPeer, false, isAc); + } + } + lastXICFocussedComponent = null; + } else { /* Delay resetting the XIC focus until activate is called and the newly focussed component has a different peer as the last focussed component. */ lastXICFocussedComponent = awtFocussedComponent; + } + isLastXICActive = isAc; isLastTemporary = isTemporary; isActive = false; + setStatusAreaVisible(false, pData); } /** * Explicitly disable the native IME. Native IME is not disabled when * deactivate is called.
*** 418,427 **** --- 431,444 ---- } // implements java.awt.im.spi.InputMethod.hideWindows public void hideWindows() { // ??? need real implementation + if (pData != 0) { + setStatusAreaVisible(false, pData); + turnoffStatusWindow(); + } } /** * @see java.awt.Toolkit#mapInputMethodHighlight */
*** 609,618 **** --- 626,670 ---- && caretPosition == 0 && composedText == null && committedText == null) return; + // Recalculate chgOffset and chgLength for supplementary char + if (composedText != null){ + int tmpChgOffset=chgOffset; + int tmpChgLength=chgLength; + int index = 0; + for (int i=0;i < tmpChgOffset; i++,index++){ + if (index < composedText.length() + && Character.charCount(composedText.codePointAt(index))==2){ + index++; + chgOffset++; + } + } + // The index keeps value + for (int i=0;i < tmpChgLength; i++,index++){ + if (index < composedText.length() + && Character.charCount(composedText.codePointAt(index))==2){ + index++; + chgLength++; + } + } + } + + // Replace control character with a square box + if (chgText != null){ + StringBuffer newChgText = new StringBuffer(); + for (int i=0; i < chgText.length(); i++){ + char c = chgText.charAt(i); + if (Character.isISOControl(c)){ + c = '\u25A1'; + } + newChgText.append(c); + } + chgText=new String(newChgText); + } + if (composedText == null) { // TODO: avoid reallocation of those buffers composedText = new StringBuffer(INITIAL_SIZE); rawFeedbacks = new IntBuffer(INITIAL_SIZE); }
*** 643,656 **** } } } if (chgText != null) { composedText.insert(chgOffset, chgText); ! if (chgStyles != null) rawFeedbacks.insert(chgOffset, chgStyles); } if (composedText.length() == 0) { composedText = null; rawFeedbacks = null; // if there is any outstanding committed text stored by --- 695,747 ---- } } } if (chgText != null) { composedText.insert(chgOffset, chgText); ! if (chgStyles != null) { ! // Recalculate chgStyles for supplementary char ! if (chgText.length() > chgStyles.length){ ! int index=0; ! int[] newStyles = new int[chgText.length()]; ! for (int i=0; i < chgStyles.length; i++, index++){ ! newStyles[index]=chgStyles[i]; ! if (index < chgText.length() ! && Character.charCount(chgText.codePointAt(index))==2){ ! newStyles[++index]=chgStyles[i]; ! } ! } ! chgStyles=newStyles; ! } rawFeedbacks.insert(chgOffset, chgStyles); } + } + + else if (chgStyles != null) { + // Recalculate chgStyles to support supplementary char + int count=0; + for (int i=0; i < chgStyles.length; i++){ + if (composedText.length() > chgOffset+i+count + && Character.charCount(composedText.codePointAt(chgOffset+i+count))==2){ + count++; + } + } + if (count>0){ + int index=0; + int[] newStyles = new int[chgStyles.length+count]; + for (int i=0; i < chgStyles.length; i++, index++){ + newStyles[index]=chgStyles[i]; + if (composedText.length() > chgOffset+index + && Character.charCount(composedText.codePointAt(chgOffset+index))==2){ + newStyles[++index]=chgStyles[i]; + } + } + chgStyles=newStyles; + } + rawFeedbacks.replace(chgOffset, chgStyles); + } + if (composedText.length() == 0) { composedText = null; rawFeedbacks = null; // if there is any outstanding committed text stored by
*** 672,681 **** --- 763,781 ---- when); return; } + // Adjust caretPosition for supplementary char + for (int i=0; i< caretPosition; i++){ + if (i < composedText.length() + && Character.charCount(composedText.codePointAt(i))==2){ + caretPosition++; + i++; + } + } + // Now sending the composed text to the client int composedOffset; AttributedString inputText; // if there is any partially committed text, concatenate it to
*** 765,787 **** composedText = null; committedText = null; } } /* * Subclasses should override disposeImpl() instead of dispose(). Client * code should always invoke dispose(), never disposeImpl(). */ protected synchronized void disposeImpl() { disposeXIC(); awtLock(); ! composedText = null; ! committedText = null; ! rawFeedbacks = null; awtUnlock(); awtFocussedComponent = null; lastXICFocussedComponent = null; } /** * Frees all X Window resources associated with this object. * --- 865,911 ---- composedText = null; committedText = null; } } + /* Some IMs need forced Text clear */ + void clearComposedText(long when) { + composedText = null; + postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, + null, 0, null, null, + when); + if (committedText != null && committedText.length() > 0) { + dispatchCommittedText(committedText, when); + } + committedText = null; + rawFeedbacks = null; + } + + void clearComposedText() { + if (EventQueue.isDispatchThread()) { + clearComposedText(EventQueue.getMostRecentEventTime()); + } + } + /* * Subclasses should override disposeImpl() instead of dispose(). Client * code should always invoke dispose(), never disposeImpl(). */ protected synchronized void disposeImpl() { disposeXIC(); awtLock(); ! try { ! clearComposedText(); ! } finally { ! // Put awtUnlock into finally block in case an exception is thrown in clearComposedText. awtUnlock(); + } awtFocussedComponent = null; lastXICFocussedComponent = null; + needResetXIC = false; + savedCompositionState = false; + compositionEnableSupported = true; } /** * Frees all X Window resources associated with this object. *
*** 829,841 **** --- 953,977 ---- setCompositionEnabledNative may throw UnsupportedOperationException. Don't try to catch it since the method may be called by clients. Use package private mthod 'resetCompositionState' if you want the exception to be caught. */ + boolean pre, post; + pre=getCompositionState(); + if (setCompositionEnabledNative(enable)) { savedCompositionState = enable; } + + post=getCompositionState(); + if (pre != post && post == enable){ + if (enable == false) flushText(); + if (awtFocussedComponent != null && isActive){ + setXICFocus(getPeer(awtFocussedComponent), + true, haveActiveClient()); + } + } } /** * @see java.awt.im.spi.InputMethod#isCompositionEnabled */
*** 888,908 **** --- 1024,1048 ---- // dispatchComposedText call from X input method engine, but some // input method does not conform to the XIM specification and does // not call the preedit callback to erase preedit text on calling // XmbResetIC. To work around this problem, do it here by ourselves. awtLock(); + try { composedText = null; postInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, null, 0, null, null); if (text != null && text.length() > 0) { dispatchCommittedText(text); } + } finally { + // Put awtUnlock into finally block in case an exception is thrown. awtUnlock(); + } // Restore the preedit state if it was enabled if (savedCompositionState) { resetCompositionState(); }
*** 985,994 **** --- 1125,1135 ---- highlight = InputMethodHighlight.SELECTED_CONVERTED_TEXT_HIGHLIGHT; break; case XIMHighlight: highlight = InputMethodHighlight.SELECTED_RAW_TEXT_HIGHLIGHT; break; + case 0: //None of the value is set by Wnn case XIMPrimary: highlight = InputMethodHighlight.UNSELECTED_CONVERTED_TEXT_HIGHLIGHT; break; case XIMSecondary: highlight = InputMethodHighlight.SELECTED_CONVERTED_TEXT_HIGHLIGHT;
*** 1092,1097 **** --- 1233,1239 ---- private native String resetXIC(); private native void disposeXIC(); private native boolean setCompositionEnabledNative(boolean enable); private native boolean isCompositionEnabledNative(); private native void turnoffStatusWindow(); + private native void setStatusAreaVisible(boolean value, long data); }
< prev index next >