Fix to connect button-press-event for Hangul

Delete a previous workaround targeted to firefox only for Hangul
This commit is contained in:
Takao Fujiwara 2019-12-24 15:54:54 +09:00
parent b60ce10e89
commit 9f9e09d31a
2 changed files with 71 additions and 99 deletions

View File

@ -3027,28 +3027,21 @@ index 5e3457ba..ac5de809 100644
--
2.21.0
From 7830673205140e901df354b80a00254f7c08f30d Mon Sep 17 00:00:00 2001
From 0544e4b9c68c43d41c18c73b6e5a394fead1321a Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 11 Dec 2019 19:10:24 +0900
Subject: [PATCH] client/gtk2: Add IBUS_AUTO_PREEDIT_COMMIT_APPS env for
Hangul
Date: Tue, 24 Dec 2019 12:23:27 +0900
Subject: [PATCH] client/gtk2: Fix to connect button-press-event signal
Firefox no longer connect "button-press-event" but uses
GtkGestureMultiPress in GtkWindowPrivate and connects "pressed"
instead and do not propagate the event with "button-press-event".
We don't commit the preedit text in the client here for the
workaround and let firefox commit the preedit text to avoid the
double preedit text with mouse click.
IBus clients do not connect button-press-event in some conditions
and it will be fixed.
BUG=https://github.com/ibus/ibus/issues/1980
---
client/gtk2/ibusimcontext.c | 32 ++++++++++++++++++++++++++++----
configure.ac | 13 ++++++++++++-
2 files changed, 40 insertions(+), 5 deletions(-)
client/gtk2/ibusimcontext.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index ac5de809..df78ce48 100644
index ac5de809..6b5ab04f 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -2,8 +2,8 @@
@ -3062,94 +3055,69 @@ index ac5de809..df78ce48 100644
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -97,6 +97,9 @@ static gboolean _use_sync_mode = FALSE;
static const gchar *_discard_password_apps = "";
static gboolean _use_discard_password = FALSE;
@@ -73,7 +73,7 @@ struct _IBusIMContext {
GCancellable *cancellable;
GQueue *events_queue;
+static const gchar *_auto_commit_apps = AUTO_PREEDIT_COMMIT_APPS;
+static gboolean _use_auto_commit = FALSE;
+
static GtkIMContext *_focus_im_context = NULL;
static IBusInputContext *_fake_context = NULL;
static GdkWindow *_input_window = NULL;
@@ -636,6 +639,7 @@ ibus_im_context_class_init (IBusIMContextClass *class)
!(ENABLE_SNOOPER));
_use_sync_mode = _get_boolean_env ("IBUS_ENABLE_SYNC_MODE", FALSE);
_use_discard_password = _get_boolean_env ("IBUS_DISCARD_PASSWORD", FALSE);
+ _use_auto_commit = _get_boolean_env ("IBUS_AUTO_PREEDIT_COMMIT", FALSE);
- gboolean use_button_press_event;
+ gboolean use_button_press_event;
};
#define CHECK_APP_IN_CSV_ENV_VARIABLES(retval, \
env_apps, \
@@ -672,6 +676,12 @@ ibus_im_context_class_init (IBusIMContextClass *class)
_discard_password_apps,
TRUE);
}
+ if (!_use_auto_commit) {
+ CHECK_APP_IN_CSV_ENV_VARIABLES (_use_auto_commit,
+ IBUS_AUTO_PREEDIT_COMMIT_APPS,
+ _auto_commit_apps,
+ TRUE);
+ }
struct _IBusIMContextClass {
@@ -1125,6 +1125,10 @@ ibus_im_context_get_preedit_string (GtkIMContext *context,
#undef CHECK_APP_IN_CSV_ENV_VARIABLES
@@ -896,9 +906,23 @@ ibus_im_context_clear_preedit_text (IBusIMContext *ibusimcontext)
IBUS_ENGINE_PREEDIT_CLEAR,
ibusimcontext);
if (preedit_string) {
- g_signal_emit (ibusimcontext, _signal_commit_id, 0, preedit_string);
+ /* Firefox no longer connect "button-press-event" but uses
+ * GtkGestureMultiPress in GtkWindowPrivate and connects "pressed"
+ * instead and do not propagate the event with "button-press-event".
+ * We don't commit the preedit text in the client here for the
+ * workaround and let firefox commit the preedit text to avoid the
+ * double preedit text with mouse click.
+ * After we fix the GTK reset signal to always emit the reset signal
+ * with mouse click, also will try to fix the Firefox
+ * reset signal so that ibus clients receive the signal before Firefox
+ * composes the preedit text because the options of commit, clear,
+ * keep depends on each IBus engine but Firefox cannot know each engine.
+ */
+ if (!_use_auto_commit) {
+ g_signal_emit (ibusimcontext, _signal_commit_id, 0, preedit_string);
+ _request_surrounding_text (ibusimcontext);
+ }
g_free (preedit_string);
- _request_surrounding_text (ibusimcontext);
#if !GTK_CHECK_VERSION (3, 93, 0)
+/* Use the button-press-event signal until GtkIMContext always emits the reset
+ * signal.
+ * https://gitlab.gnome.org/GNOME/gtk/merge_requests/460
+ */
static gboolean
ibus_im_context_button_press_event_cb (GtkWidget *widget,
GdkEventButton *event,
@@ -1157,11 +1161,13 @@ _connect_button_press_event (IBusIMContext *ibusimcontext,
"button-press-event",
G_CALLBACK (ibus_im_context_button_press_event_cb),
ibusimcontext);
+ ibusimcontext->use_button_press_event = TRUE;
} else {
g_signal_handlers_disconnect_by_func (
widget,
G_CALLBACK (ibus_im_context_button_press_event_cb),
ibusimcontext);
+ ibusimcontext->use_button_press_event = FALSE;
}
}
}
diff --git a/configure.ac b/configure.ac
index ab74a380..12642834 100644
--- a/configure.ac
+++ b/configure.ac
@@ -540,6 +540,16 @@ AC_ARG_WITH(no-snooper-apps,
AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS",
[Does not enbale keyboard snooper in those applications])
+# Option for auto-preedit-commit applications.
+AC_ARG_WITH(auto-preedit-commit-apps,
+ AS_HELP_STRING([--with-auto-preedit-commit-apps[=regex1,regex2]],
+ [Applications have auto-commit of preedit with mouse click (like: .*chrome.*,firefox.*)]),
+ AUTO_PREEDIT_COMMIT_APPS=$with_auto_preedit_commit_apps,
+ AUTO_PREEDIT_COMMIT_APPS=[firefox.*,.*chrome.*,.*chromium.*]
+)
+AC_DEFINE_UNQUOTED(AUTO_PREEDIT_COMMIT_APPS, "$AUTO_PREEDIT_COMMIT_APPS",
+ [Applications have auto-commit of preedit with mouse click])
+
# GNOME 3 uses the theme's icon.
AC_ARG_WITH(panel-icon-keyboard,
AS_HELP_STRING([--with-panel-icon-keyboard[=icon_name]],
@@ -812,7 +822,8 @@ Build options:
Build UI $enable_ui
Build engine $enable_engine
Enable key snooper $enable_key_snooper
- No snooper regexes "$NO_SNOOPER_APPS"
+ No snooper apps "$NO_SNOOPER_APPS"
+ Auto preedit commit apps "$AUTO_PREEDIT_COMMIT_APPS"
Panel icon "$IBUS_ICON_KEYBOARD"
Enable surrounding-text $enable_surrounding_text
Enable Emoji dict $enable_emoji_dict
@@ -1180,6 +1186,8 @@ ibus_im_context_set_client_window (GtkIMContext *context, GdkWindow *client)
#if !GTK_CHECK_VERSION (3, 93, 0)
if (ibusimcontext->use_button_press_event)
_connect_button_press_event (ibusimcontext, FALSE);
+#else
+ ibusimcontext->use_button_press_event = TRUE;
#endif
g_object_unref (ibusimcontext->client_window);
ibusimcontext->client_window = NULL;
@@ -1188,8 +1196,10 @@ ibus_im_context_set_client_window (GtkIMContext *context, GdkWindow *client)
if (client != NULL) {
ibusimcontext->client_window = g_object_ref (client);
#if !GTK_CHECK_VERSION (3, 93, 0)
- if (ibusimcontext->use_button_press_event)
+ if (!ibusimcontext->use_button_press_event)
_connect_button_press_event (ibusimcontext, TRUE);
+#else
+ ibusimcontext->use_button_press_event = FALSE;
#endif
}
if (ibusimcontext->slave)
@@ -1660,7 +1670,6 @@ _ibus_context_update_preedit_text_cb (IBusInputContext *ibuscontext,
#if !GTK_CHECK_VERSION (3, 93, 0)
if (ibusimcontext->client_window) {
_connect_button_press_event (ibusimcontext, TRUE);
- ibusimcontext->use_button_press_event = TRUE;
}
#else
ibusimcontext->use_button_press_event = TRUE;
--
2.21.0

View File

@ -35,7 +35,7 @@
Name: ibus
Version: 1.5.21
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPLv2+
URL: https://github.com/ibus/%name/wiki
@ -464,9 +464,13 @@ dconf update || :
%{_datadir}/installed-tests/ibus
%changelog
* Tue Dec 24 2019 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.21-6
- Fix to connect button-press-event for Hangul
- Delete a previous workaround targeted to firefox only for Hangul
* Wed Dec 11 2019 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.21-5
- Add RHEL code reviews
- Fix Hangul preedit with mouse click for RHEL 8
- Fix Hangul preedit with mouse click
* Mon Nov 18 2019 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.21-4
- Replace push with cd for Posix SH