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

View File

@ -35,7 +35,7 @@
Name: ibus Name: ibus
Version: 1.5.21 Version: 1.5.21
Release: 5%{?dist} Release: 6%{?dist}
Summary: Intelligent Input Bus for Linux OS Summary: Intelligent Input Bus for Linux OS
License: LGPLv2+ License: LGPLv2+
URL: https://github.com/ibus/%name/wiki URL: https://github.com/ibus/%name/wiki
@ -464,9 +464,13 @@ dconf update || :
%{_datadir}/installed-tests/ibus %{_datadir}/installed-tests/ibus
%changelog %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 * Wed Dec 11 2019 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.21-5
- Add RHEL code reviews - 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 * Mon Nov 18 2019 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.21-4
- Replace push with cd for Posix SH - Replace push with cd for Posix SH