From 353ed023c410973662458f37ba2e4fad89834c63 Mon Sep 17 00:00:00 2001
From: Peng Wu <pwu@redhat.com>
Date: Tue, 24 Mar 2020 15:50:43 +0800
Subject: [PATCH 1/2] text-input: Add preedit_commit_mode event for mouse click
 event

IBus update_preedit_string_with_mode feature send the preedit text and
the commit mode to the input method module, use preedit_commit_mode event
to send the commit mode together with the preeedit text.

IBusInputContext specify how input context interact with the keyboard,
but sometimes mouse click also interacts with the input context, too.

For Firefox, if some preedit text is visible with ibus-hangul input method;
after mouse click, the preedit will be committed twice.

To fix this issue, ibus-hangul can send preedit text and commit mode
together; after mouse click, the preedit is handled directly in
input method module of Firefox, and the preedit is committed in
the current text widget.

For detailed analysis, please read the merge request comments.
URL: https://gitlab.freedesktop.org/wayland/wayland-protocols/merge_requests/30
---
 .../text-input/text-input-unstable-v3.xml     | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/unstable/text-input/text-input-unstable-v3.xml b/unstable/text-input/text-input-unstable-v3.xml
index 8b710fd..f7fd12d 100644
--- a/unstable/text-input/text-input-unstable-v3.xml
+++ b/unstable/text-input/text-input-unstable-v3.xml
@@ -417,6 +417,32 @@
       </description>
       <arg name="serial" type="uint"/>
     </event>
+
+    <enum name="commit_mode">
+      <description summary="focus commit mode">
+        Pre-edit commit mode when the focus widget or the cursor position
+        is changed.
+      </description>
+      <entry name="clear" value="0" summary="pre-edit text is cleared."/>
+      <entry name="commit" value="1" summary="pre-edit text is committed."/>
+    </enum>
+
+    <event name="preedit_commit_mode">
+      <description summary="pre-edit commit mode">
+        Specify how the visible preedit should be handled
+        when switching the focus widget or changing the cursor position,
+        whether to commit the preedit text or clear the preedit text.
+
+        This is usually used together with the preedit_string event.
+
+        The commit behavior is the same for focus switch and
+        cursor position change.
+
+        The parameter mode selects the desired behavior and
+        its value is one from the commit mode enum.
+      </description>
+      <arg name="mode" type="uint" enum="commit_mode"/>
+    </event>
   </interface>
 
   <interface name="zwp_text_input_manager_v3" version="1">
-- 
2.29.2


From d38efcf2c9c9c7a0ee60de8234ae2e953f253b28 Mon Sep 17 00:00:00 2001
From: Peng Wu <pwu@redhat.com>
Date: Tue, 15 Sep 2020 14:35:53 +0800
Subject: [PATCH 2/2] text-input: bump text-input-unstable-v3 version

As the preedit_commit_mode event is added to text input protocol,
bump version to allow client and server detect the text input protocol version.
---
 unstable/text-input/text-input-unstable-v3.xml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/unstable/text-input/text-input-unstable-v3.xml b/unstable/text-input/text-input-unstable-v3.xml
index f7fd12d..42fc744 100644
--- a/unstable/text-input/text-input-unstable-v3.xml
+++ b/unstable/text-input/text-input-unstable-v3.xml
@@ -47,7 +47,7 @@
     interface version number is reset.
   </description>
 
-  <interface name="zwp_text_input_v3" version="1">
+  <interface name="zwp_text_input_v3" version="2">
     <description summary="text input">
       The zwp_text_input_v3 interface represents text input and input methods
       associated with a seat. It provides enter/leave events to follow the
@@ -427,7 +427,7 @@
       <entry name="commit" value="1" summary="pre-edit text is committed."/>
     </enum>
 
-    <event name="preedit_commit_mode">
+    <event name="preedit_commit_mode" since="2">
       <description summary="pre-edit commit mode">
         Specify how the visible preedit should be handled
         when switching the focus widget or changing the cursor position,
@@ -445,7 +445,7 @@
     </event>
   </interface>
 
-  <interface name="zwp_text_input_manager_v3" version="1">
+  <interface name="zwp_text_input_manager_v3" version="2">
     <description summary="text input manager">
       A factory for text-input objects. This object is a global singleton.
     </description>
-- 
2.29.2

