Always reset and clear preedit on mouse click

- Show compose preedit with custom compose file
- Clear preedit in IBusEngineSimple with focus changes
- Obsolete ibus-xkbc since Fedora 30
This commit is contained in:
Takao Fujiwara 2018-12-10 14:18:18 +09:00
parent c3be8d630b
commit 4f9e8c7805
2 changed files with 313 additions and 1 deletions

View File

@ -1716,3 +1716,307 @@ index 73a0eaec..82af51a1 100644
--
2.17.1
From 4c40afba9c862b4f6651b1b971553e5e89e83343 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 6 Dec 2018 16:53:57 +0900
Subject: [PATCH] client/gtk2: Always reset and clear preedit on mouse click
Thinking about the reset signal again, now I think it's good to emit
the reset signal and clear the preedit on mouse click for any engines
besides Hangul because the behavior could be handled by each engine
with the reset signal.
BUG=https://github.com/ibus/ibus/issues/1980
---
client/gtk2/ibusimcontext.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index 82af51a1..ed7fea6e 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -869,16 +869,19 @@ ibus_im_context_finalize (GObject *obj)
static void
ibus_im_context_clear_preedit_text (IBusIMContext *ibusimcontext)
{
+ gchar *preedit_string = NULL;
g_assert (ibusimcontext->ibuscontext);
if (ibusimcontext->preedit_visible &&
ibusimcontext->preedit_mode == IBUS_ENGINE_PREEDIT_COMMIT) {
- gchar *preedit_string = g_strdup (ibusimcontext->preedit_string);
- _ibus_context_update_preedit_text_cb (ibusimcontext->ibuscontext,
- ibus_text_new_from_string (""),
- 0,
- FALSE,
- IBUS_ENGINE_PREEDIT_CLEAR,
- ibusimcontext);
+ preedit_string = g_strdup (ibusimcontext->preedit_string);
+ }
+ _ibus_context_update_preedit_text_cb (ibusimcontext->ibuscontext,
+ ibus_text_new_from_string (""),
+ 0,
+ FALSE,
+ IBUS_ENGINE_PREEDIT_CLEAR,
+ ibusimcontext);
+ if (preedit_string) {
g_signal_emit (ibusimcontext, _signal_commit_id, 0, preedit_string);
g_free (preedit_string);
_request_surrounding_text (ibusimcontext);
@@ -1114,12 +1117,9 @@ ibus_im_context_button_press_event_cb (GtkWidget *widget,
if (event->button != 1)
return FALSE;
- if (ibusimcontext->preedit_visible &&
- ibusimcontext->preedit_mode == IBUS_ENGINE_PREEDIT_COMMIT) {
- ibus_im_context_clear_preedit_text (ibusimcontext);
- if (ibusimcontext->ibuscontext)
- ibus_input_context_reset (ibusimcontext->ibuscontext);
- }
+ ibus_im_context_clear_preedit_text (ibusimcontext);
+ if (ibusimcontext->ibuscontext)
+ ibus_input_context_reset (ibusimcontext->ibuscontext);
return FALSE;
}
--
2.19.1
From ba41173c45a4ba6e047f94ac53474433c7643591 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Fri, 7 Dec 2018 17:38:09 +0900
Subject: [PATCH] src: Show compose preedit with custom compose file
IBusEngineSimple is fixed for custom compose files
- Show preeedit with custom compose file
- Tentative compose preedit can be deleted by Backspace
BUG=https://github.com/ibus/ibus/issues/2058
---
src/ibusenginesimple.c | 93 ++++++++++++++++++++++++------------------
1 file changed, 53 insertions(+), 40 deletions(-)
diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c
index aae6b8df..ba9d92b6 100644
--- a/src/ibusenginesimple.c
+++ b/src/ibusenginesimple.c
@@ -357,7 +357,7 @@ ibus_engine_simple_update_preedit_text (IBusEngineSimple *simple)
} else {
int hexchars = 0;
while (priv->compose_buffer[hexchars] != 0) {
- guint16 keysym= priv->compose_buffer[hexchars];
+ guint16 keysym = priv->compose_buffer[hexchars];
gunichar unichar = ibus_keysym_to_unicode (keysym, FALSE);
if (unichar > 0)
outbuf[len] = unichar;
@@ -620,6 +620,8 @@ check_table (IBusEngineSimple *simple,
guint16 *prev_seq;
+ priv->tentative_match = 0;
+ priv->tentative_match_len = 0;
/* Back up to the first sequence that matches to make sure
* we find the exact match if their is one.
*/
@@ -654,9 +656,9 @@ check_table (IBusEngineSimple *simple,
ibus_engine_simple_commit_char (simple, value);
priv->compose_buffer[0] = 0;
- ibus_engine_simple_update_preedit_text (simple);
// g_debug ("U+%04X\n", value);
}
+ ibus_engine_simple_update_preedit_text (simple);
return TRUE;
}
@@ -1057,6 +1059,51 @@ ibus_engine_simple_set_number_on_lookup_table (IBusEngineSimple *simple,
ibus_engine_simple_update_preedit_text (simple);
}
+static gboolean
+ibus_engine_simple_check_all_compose_table (IBusEngineSimple *simple,
+ gint n_compose)
+{
+ IBusEngineSimplePrivate *priv = simple->priv;
+ gboolean compose_finish;
+ gunichar output_char;
+ GSList *list = global_tables;
+
+ while (list) {
+ if (check_table (simple,
+ (IBusComposeTable *)list->data,
+ n_compose)) {
+ return TRUE;
+ }
+ list = list->next;
+ }
+
+ if (ibus_check_compact_table (&ibus_compose_table_compact,
+ priv->compose_buffer,
+ n_compose,
+ &compose_finish,
+ &output_char)) {
+ if (compose_finish) {
+ ibus_engine_simple_commit_char (simple, output_char);
+ priv->compose_buffer[0] = 0;
+ }
+ ibus_engine_simple_update_preedit_text (simple);
+ return TRUE;
+ }
+
+ if (ibus_check_algorithmically (priv->compose_buffer,
+ n_compose,
+ &output_char)) {
+ if (output_char) {
+ ibus_engine_simple_commit_char (simple, output_char);
+ priv->compose_buffer[0] = 0;
+ }
+ ibus_engine_simple_update_preedit_text (simple);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static gboolean
ibus_engine_simple_process_key_event (IBusEngine *engine,
guint keyval,
@@ -1076,8 +1123,6 @@ ibus_engine_simple_process_key_event (IBusEngine *engine,
guint hex_keyval;
guint printable_keyval;
gint i;
- gboolean compose_finish;
- gunichar output_char;
while (n_compose < EMOJI_SOURCE_LEN && priv->compose_buffer[n_compose] != 0)
n_compose++;
@@ -1247,7 +1292,8 @@ ibus_engine_simple_process_key_event (IBusEngine *engine,
if (n_compose > 0) {
n_compose--;
priv->compose_buffer[n_compose] = 0;
- ibus_engine_simple_update_preedit_text (simple);
+ priv->tentative_match = 0;
+ ibus_engine_simple_check_all_compose_table (simple, n_compose);
return TRUE;
}
}
@@ -1479,42 +1525,9 @@ ibus_engine_simple_process_key_event (IBusEngine *engine,
return TRUE;
}
- }
- else {
- GSList *list = global_tables;
- while (list) {
- if (check_table (simple,
- (IBusComposeTable *)list->data,
- n_compose)) {
- // g_debug("check_table returns true");
- return TRUE;
- }
- list = list->next;
- }
-
- if (ibus_check_compact_table (&ibus_compose_table_compact,
- priv->compose_buffer,
- n_compose,
- &compose_finish,
- &output_char)) {
- if (compose_finish) {
- ibus_engine_simple_commit_char (simple, output_char);
- priv->compose_buffer[0] = 0;
- }
- ibus_engine_simple_update_preedit_text (simple);
- return TRUE;
- }
-
- if (ibus_check_algorithmically (priv->compose_buffer,
- n_compose,
- &output_char)) {
- if (output_char) {
- ibus_engine_simple_commit_char (simple, output_char);
- priv->compose_buffer[0] = 0;
- }
- ibus_engine_simple_update_preedit_text (simple);
+ } else {
+ if (ibus_engine_simple_check_all_compose_table (simple, n_compose))
return TRUE;
- }
}
/* The current compose_buffer doesn't match anything */
--
2.19.1
From 28b0744ad141bd76281025e9d0857d2182bc2a65 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Mon, 10 Dec 2018 13:21:42 +0900
Subject: [PATCH] src: Clear preedit in IBusEngineSimple with focus changes
BUG=https://github.com/ibus/ibus/issues/2063
---
src/ibusenginesimple.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c
index ba9d92b6..7615f121 100644
--- a/src/ibusenginesimple.c
+++ b/src/ibusenginesimple.c
@@ -105,6 +105,8 @@ static GSList *global_tables;
/* functions prototype */
static void ibus_engine_simple_destroy (IBusEngineSimple *simple);
+static void ibus_engine_simple_focus_in (IBusEngine *engine);
+static void ibus_engine_simple_focus_out (IBusEngine *engine);
static void ibus_engine_simple_reset (IBusEngine *engine);
static gboolean ibus_engine_simple_process_key_event
(IBusEngine *engine,
@@ -136,6 +138,8 @@ ibus_engine_simple_class_init (IBusEngineSimpleClass *class)
ibus_object_class->destroy =
(IBusObjectDestroyFunc) ibus_engine_simple_destroy;
+ engine_class->focus_in = ibus_engine_simple_focus_in;
+ engine_class->focus_out = ibus_engine_simple_focus_out;
engine_class->reset = ibus_engine_simple_reset;
engine_class->process_key_event
= ibus_engine_simple_process_key_event;
@@ -176,6 +180,19 @@ ibus_engine_simple_destroy (IBusEngineSimple *simple)
IBUS_OBJECT (simple));
}
+static void
+ibus_engine_simple_focus_in (IBusEngine *engine)
+{
+ IBUS_ENGINE_CLASS (ibus_engine_simple_parent_class)->focus_in (engine);
+}
+
+static void
+ibus_engine_simple_focus_out (IBusEngine *engine)
+{
+ ibus_engine_simple_reset (engine);
+ IBUS_ENGINE_CLASS (ibus_engine_simple_parent_class)->focus_out (engine);
+}
+
static void
ibus_engine_simple_reset (IBusEngine *engine)
{
@@ -188,14 +205,14 @@ ibus_engine_simple_reset (IBusEngine *engine)
priv->in_hex_sequence = FALSE;
priv->tentative_match = 0;
priv->tentative_match_len = 0;
- ibus_engine_hide_preedit_text ((IBusEngine *)simple);
} else if (priv->tentative_emoji || priv->in_emoji_sequence) {
priv->in_emoji_sequence = FALSE;
g_clear_pointer (&priv->tentative_emoji, g_free);
- ibus_engine_hide_preedit_text ((IBusEngine *)simple);
} else if (!priv->in_hex_sequence && !priv->in_emoji_sequence) {
- ibus_engine_hide_preedit_text ((IBusEngine *)simple);
+ priv->tentative_match = 0;
+ priv->tentative_match_len = 0;
}
+ ibus_engine_hide_preedit_text ((IBusEngine *)simple);
}
static void
--
2.19.1

View File

@ -35,7 +35,7 @@
Name: ibus
Version: 1.5.19
Release: 9%{?dist}
Release: 10%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPLv2+
Group: System Environment/Libraries
@ -118,9 +118,11 @@ Requires: %{_sbindir}/alternatives
Requires(post): %{_sbindir}/alternatives
Requires(postun): %{_sbindir}/alternatives
%if (0%{?fedora} > 29 || 0%{?rhel} > 8)
# Obsoletes ibus-xkbc by ibus xkb engine
Provides: ibus-xkbc = 1.3.4
Obsoletes: ibus-xkbc < 1.3.4
%endif
%global _xinputconf %{_sysconfdir}/X11/xinit/xinput.d/ibus.conf
@ -434,6 +436,12 @@ dconf update || :
%{_datadir}/gtk-doc/html/*
%changelog
* Mon Dec 10 2018 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.19-10
- Always reset and clear preedit on mouse click
- Show compose preedit with custom compose file
- Clear preedit in IBusEngineSimple with focus changes
- Obsolete ibus-xkbc since Fedora 30
* Thu Nov 15 2018 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.19-9
- Detect mouse click to commit Hangul preedit
- Do not delete IBUS_CAP_SURROUNDING_TEXT