src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m

Print this page

        

@@ -82,11 +82,10 @@
     fKeyEventsNeeded = NO;
     fProcessingKeystroke = NO;
 
     fEnablePressAndHold = shouldUsePressAndHold();
     fInPressAndHold = NO;
-    fPAHNeedsToSelect = NO;
 
     mouseIsOver = NO;
     [self resetTrackingArea];
     [self setAutoresizesSubviews:NO];
 

@@ -285,11 +284,10 @@
 
     if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod]) {
         fProcessingKeystroke = NO;
         if (!fInPressAndHold) {
             fInPressAndHold = YES;
-            fPAHNeedsToSelect = YES;
         }
         return;
     }
 
     NSString *eventCharacters = [event characters];

@@ -876,11 +874,11 @@
 JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
 
 - (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
 {
 #ifdef IM_DEBUG
-    fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]);
+    fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s Repl: loc=%lu, length=%lu \n", [aString UTF8String], (unsigned long)replacementRange.location, (unsigned long)replacementRange.length);
 #endif // IM_DEBUG
 
     if (fInputMethodLOCKABLE == NULL) {
         return;
     }

@@ -896,29 +894,21 @@
     NSUInteger utf16Length = [aString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
 
     if ([self hasMarkedText] || !fProcessingKeystroke || (utf16Length > 2)) {
         JNIEnv *env = [ThreadUtilities getJNIEnv];
 
-        static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
-        // We need to select the previous glyph so that it is overwritten.
-        if (fPAHNeedsToSelect) {
-            JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
-            fPAHNeedsToSelect = NO;
-        }
-
-        static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
+        static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;II)V");
         jstring insertedText =  JNFNSToJavaString(env, aString);
-        JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
+        JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText, 
+            replacementRange.location == NSNotFound ? -1 : replacementRange.location, 
+            replacementRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
         (*env)->DeleteLocalRef(env, insertedText);
 
         // The input method event will create psuedo-key events for each character in the committed string.
         // We also don't want to send the character that triggered the insertText, usually a return. [3337563]
         fKeyEventsNeeded = NO;
     }
-
-    fPAHNeedsToSelect = NO;
-
 }
 
 - (void) doCommandBySelector:(SEL)aSelector
 {
 #ifdef IM_DEBUG

@@ -939,15 +929,17 @@
 
     BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
     NSAttributedString *attrString = (isAttributedString ? (NSAttributedString *)aString : nil);
     NSString *incomingString = (isAttributedString ? [aString string] : aString);
 #ifdef IM_DEBUG
-    fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", loc=%lu, length=%lu\n", [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length);
+    fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", Sel: loc=%lu, length=%lu, Repl: loc=%lu, length=%lu\n", 
+            [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length, 
+            (unsigned long)replacementRange.location, (unsigned long)replacementRange.length);
 #endif // IM_DEBUG
     static JNF_MEMBER_CACHE(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V");
     static JNF_MEMBER_CACHE(jm_addAttribute, jc_CInputMethod, "addAttribute", "(ZZII)V");
-    static JNF_MEMBER_CACHE(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIZ)V");
+    static JNF_MEMBER_CACHE(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIIIZ)V");
     JNIEnv *env = [ThreadUtilities getJNIEnv];
 
     // NSInputContext already did the analysis of the TSM event and created attributes indicating
     // the underlining and color that should be done to the string.  We need to look at the underline
     // style and color to determine what kind of Java hilighting needs to be done.

@@ -978,18 +970,13 @@
                 JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
             }
         }
     }
 
-    static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
-    // We need to select the previous glyph so that it is overwritten.
-    if (fPAHNeedsToSelect) {
-        JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
-        fPAHNeedsToSelect = NO;
-    }
-
-    JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
+    JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length,
+            replacementRange.location == NSNotFound ? -1 : replacementRange.location, 
+            replacementRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
 
     // If the marked text is being cleared (zero-length string) don't handle the key event.
     if ([incomingString length] == 0) {
         fKeyEventsNeeded = NO;
     }