changeset 5581:aea82d3547f2

RT-33909: Need a way to cancel input method composing Reviewed-by: anthony, psafrata
author Petr Pchelko <petr.pchelko@oracle.com>
date Wed, 30 Oct 2013 17:52:42 +0400
parents 0e86f96331d5
children 4b2e1c5831e9
files modules/graphics/src/main/java/com/sun/glass/ui/View.java modules/graphics/src/main/java/com/sun/glass/ui/win/WinView.java modules/graphics/src/main/java/com/sun/javafx/tk/TKScene.java modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java modules/graphics/src/main/java/com/sun/javafx/tk/quantum/ViewScene.java modules/graphics/src/main/native-glass/win/GlassView.cpp modules/graphics/src/main/native-glass/win/GlassView.h modules/graphics/src/test/java/com/sun/javafx/pgstub/StubScene.java
diffstat 8 files changed, 57 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/View.java	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/View.java	Wed Oct 30 17:52:42 2013 +0400
@@ -354,6 +354,9 @@
     }
 
     protected abstract void _enableInputMethodEvents(long ptr, boolean enable);
+    protected void _finishInputMethodComposition(long ptr) {
+        // Action needed only on Windows.
+    }
 
     /*
         Read by the checkNotClosed method which could be called from lock/unlock on render thread
@@ -624,6 +627,12 @@
         _enableInputMethodEvents(this.ptr, enable);
     }
 
+    public void finishInputMethodComposition() {
+        Application.checkEventThread();
+        checkNotClosed();
+        _finishInputMethodComposition(this.ptr);
+    }
+
     private double[] getInputMethodCandidatePos(int offset) {
         if (this.eventHandler != null) {
             return this.eventHandler.getInputMethodCandidatePos(offset);
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinView.java	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinView.java	Wed Oct 30 17:52:42 2013 +0400
@@ -71,6 +71,7 @@
     }
 
     @Override native protected void _enableInputMethodEvents(long ptr, boolean enable);
+    @Override native protected void _finishInputMethodComposition(long ptr);
 
     @Override native protected long _create(Map caps);
     @Override native protected long _getNativeView(long ptr);
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/TKScene.java	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/TKScene.java	Wed Oct 30 17:52:42 2013 +0400
@@ -78,6 +78,8 @@
 
     public void enableInputMethodEvents(boolean enable);
 
+    public void finishInputMethodComposition();
+
     public void entireSceneNeedsRepaint();
 
     public TKClipboard createDragboard(boolean isDragSource);
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedScene.java	Wed Oct 30 17:52:42 2013 +0400
@@ -116,6 +116,13 @@
         }
     }
 
+    @Override
+    public void finishInputMethodComposition() {
+        if (QuantumToolkit.verbose) {
+            System.err.println("EmbeddedScene.finishInputMethodComposition");
+        }
+    }
+
     // Called by EmbeddedPainter on the render thread under renderLock
     void uploadPixels(IntBuffer pixels, int stride) {
         textureBits = pixels;
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/ViewScene.java	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/ViewScene.java	Wed Oct 30 17:52:42 2013 +0400
@@ -150,6 +150,11 @@
         platformView.enableInputMethodEvents(enable);
     }
 
+    @Override
+    public void finishInputMethodComposition() {
+        platformView.finishInputMethodComposition();
+    }
+
     @Override public String toString() {
         View view = getPlatformView();
         return (" scene: " + hashCode() + " @ (" + view.getWidth() + "," + view.getHeight() + ")");
--- a/modules/graphics/src/main/native-glass/win/GlassView.cpp	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/main/native-glass/win/GlassView.cpp	Wed Oct 30 17:52:42 2013 +0400
@@ -134,6 +134,20 @@
     m_InputMethodEventsEnabled = enable;
 }
 
+void GlassView::FinishInputMethodComposition()
+{
+    HWND hwnd = GetHostHwnd();
+    if (hwnd)
+    {
+        HIMC hIMC = ::ImmGetContext(hwnd);
+        if(hIMC)
+        {
+            ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
+            ::ImmReleaseContext(hwnd, hIMC);
+        }
+    }
+}
+
 /*
  * JNI methods section
  *
@@ -528,4 +542,17 @@
     GlassView* view = (GlassView*)jlong_to_ptr(ptr);
     view->EnableInputMethodEvents(jbool_to_bool(enable));
 }
+
+/*
+ * Class:     com_sun_glass_ui_win_WinView
+ * Method:    _finishInputMethodComposition
+ * Signature: (JZ)V
+ */
+JNIEXPORT void JNICALL Java_com_sun_glass_ui_win_WinView__1finishInputMethodComposition
+  (JNIEnv *env, jobject jview, jlong ptr)
+{
+    GlassView* view = (GlassView*)jlong_to_ptr(ptr);
+    view->FinishInputMethodComposition();
+}
+
 }   // extern "C"
--- a/modules/graphics/src/main/native-glass/win/GlassView.h	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/main/native-glass/win/GlassView.h	Wed Oct 30 17:52:42 2013 +0400
@@ -47,6 +47,7 @@
 
     inline BOOL IsInputMethodEventEnabled() { return m_InputMethodEventsEnabled; }
     void EnableInputMethodEvents(BOOL enable);
+    void FinishInputMethodComposition();
 
 private:
     jobject m_grefThis;
--- a/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubScene.java	Wed Oct 30 14:02:01 2013 +0100
+++ b/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubScene.java	Wed Oct 30 17:52:42 2013 +0400
@@ -89,6 +89,11 @@
         // ignore
     }
 
+    @Override
+    public void finishInputMethodComposition() {
+        // ignore
+    }
+
     public void entireSceneNeedsRepaint() {
     }