Compare commits

...

5 Commits

Author SHA1 Message Date
Nikita Provotorov
a40a99e6c0 JBR-6711: java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java: JButton JPanel not collected.
Fixes the patch of JBR-3697 so that sun.awt.X11InputMethodBase#removeNotify unsets its references to tracked components thus not preventing GC from collecting them.
2024-02-19 16:36:17 +01:00
Nikita Provotorov
8e2db04c49 JBR-3697: Letter-based command mode actions are not triggered when using Chinese input method.
Windows-specific fix: WInputMethod doesn't activate correctly after stopListening() + removeNotify() (but the opposite order - removeNotify() + stopListening() works well).
2024-02-16 07:55:21 +01:00
Nikita Provotorov
b508993b60 JBR-3697: Letter-based command mode actions are not triggered when using Chinese input method.
X Linux-specific fix that allows to keep the current keyboard layout when fcitx5 IMF is used and the input method support for the focused component is disabled and then enabled back. Before the patch, the layout used to reset to the default one (may not be reproduced with iBus instead of fcitx5).

It's done via disabling the current XIM when the input method support is disabled instead of disposing it.
2024-02-16 04:43:30 +01:00
Nikita Provotorov
38b521feac JBR-3697: Letter-based command mode actions are not triggered when using Chinese input method.
macOS-specific patch that allows to avoid showing native IM windows if the current focused text component has disabled input methods support.
2024-02-14 04:12:08 +01:00
Nikita Provotorov
f473fa15a1 JBR-3697: Letter-based command mode actions are not triggered when using Chinese input method.
Solution test.
2024-02-03 09:26:20 +01:00
6 changed files with 70 additions and 2 deletions

View File

@@ -235,6 +235,8 @@ public class CInputMethod extends InputMethodAdapter {
*/
public void activate() {
isActive = true;
enableListening(true);
}
public void deactivate(boolean isTemporary) {
@@ -267,6 +269,7 @@ public class CInputMethod extends InputMethodAdapter {
if (fAwtFocussedComponentPeer != null) {
long modelPtr = getNativeViewPtr(fAwtFocussedComponentPeer);
nativeEndComposition(modelPtr, fAwtFocussedComponent);
nativeEnableListening(modelPtr, false);
nativeNotifyPeer(modelPtr, null);
}
@@ -309,6 +312,11 @@ public class CInputMethod extends InputMethodAdapter {
}
}
@Override
protected void stopListening() {
enableListening(false);
}
/**
* @see java.awt.Toolkit#mapInputMethodHighlight
*/
@@ -414,6 +422,16 @@ public class CInputMethod extends InputMethodAdapter {
return null;
}
private void enableListening(boolean enable) {
if (fAwtFocussedComponentPeer != null) {
final long modelPtr = getNativeViewPtr(fAwtFocussedComponentPeer);
if (modelPtr != 0) {
nativeEnableListening(modelPtr, enable);
}
}
}
// =========================== NSTextInput callbacks ===========================
// The 'marked text' that we get from Cocoa. We need to track this separately, since
// Java doesn't let us ask the IM context for it.
@@ -810,6 +828,13 @@ public class CInputMethod extends InputMethodAdapter {
private native void nativeEndComposition(long nativePeer, Component component);
private native void nativeHandleEvent(LWComponentPeer<?, ?> peer, AWTEvent event);
/*
* Passing false to the second parameter disables any interaction with
* the AppKit text input management subsystem (i.e. input methods, dead keys, maybe smth else)
* Passing true there enables it back
*/
private native void nativeEnableListening(long nativePeerTarget, boolean enable);
// Returns the locale of the active input method.
static native Locale getNativeLocale();

View File

@@ -43,6 +43,7 @@
// Input method data
jobject fInputMethodLOCKABLE;
BOOL fInputMethodInteractionEnabled;
BOOL fKeyEventsNeeded;
BOOL fProcessingKeystroke;
NSString* actualCharacters;
@@ -68,5 +69,6 @@
// Input method-related events
- (void)setInputMethod:(jobject)inputMethod;
- (void)abandonInput:(jobject) component;
- (void)enableImInteraction:(BOOL)enabled;
@end

View File

@@ -85,6 +85,7 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, i
m_cPlatformView = cPlatformView;
fInputMethodLOCKABLE = NULL;
fInputMethodInteractionEnabled = YES;
fKeyEventsNeeded = NO;
fProcessingKeystroke = NO;
@@ -366,7 +367,9 @@ static void debugPrintNSEvent(NSEvent* event, const char* comment) {
NSString *eventCharacters = [event characters];
// Allow TSM to look at the event and potentially send back NSTextInputClient messages.
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
if (fInputMethodInteractionEnabled == YES) {
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
}
if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod] &&
fInputMethodLOCKABLE)
@@ -1577,6 +1580,17 @@ static jclass jc_CInputMethod = NULL;
[self unmarkText:component];
}
-(void)enableImInteraction:(BOOL)enabled
{
#ifdef IM_DEBUG
fprintf(stderr, "AWTView InputMethod Selector Called : [enableImInteraction:%d]\n", enabled);
#endif // IM_DEBUG
AWT_ASSERT_APPKIT_THREAD;
fInputMethodInteractionEnabled = (enabled == YES) ? YES : NO;
}
/******************************** END NSTextInputClient Protocol ********************************/
- (void)viewDidChangeBackingProperties {

View File

@@ -199,6 +199,30 @@ JNI_COCOA_ENTER(env);
JNI_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CInputMethod
* Method: nativeEnableListening
* Signature: (JZ)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CInputMethod_nativeEnableListening
(JNIEnv *env, jobject this, jlong nativePeer, jboolean enable)
{
JNI_COCOA_ENTER(env);
AWTView * const view = (AWTView *)jlong_to_ptr(nativePeer);
if (view == NULL) {
return;
}
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[view enableImInteraction:(enable == JNI_TRUE ? YES : NO)];
}];
JNI_COCOA_EXIT(env);
}
/*
* Class: sun_lwawt_macosx_CInputMethod
* Method: getNativeLocale

View File

@@ -564,7 +564,9 @@ public abstract class X11InputMethodBase extends InputMethodAdapter {
* @see java.awt.im.spi.InputMethod#removeNotify
*/
public synchronized void removeNotify() {
dispose();
stopListening();
awtFocussedComponent = null;
clientComponentWindow = null;
}
/**

View File

@@ -435,6 +435,7 @@ final class WInputMethod extends InputMethodAdapter
endCompositionNative(context, DISCARD_INPUT);
awtFocussedComponent = null;
awtFocussedComponentPeer = null;
stopListening();
}
/**