Fixed Bug 675503 - a regression in sync mode

This commit is contained in:
Takao Fujiwara 2011-02-08 19:02:01 +09:00
parent 0610dd694c
commit ee2c8d7341
3 changed files with 117 additions and 64 deletions

View File

@ -1,6 +1,6 @@
From 4b115935d47b1a849617aad5db44212856b48630 Mon Sep 17 00:00:00 2001 From 27788fb3bf62411c2b13d24bac45eb060483162f Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@unixuser.org> From: Daiki Ueno <ueno@unixuser.org>
Date: Fri, 4 Feb 2011 19:48:05 +0900 Date: Tue, 8 Feb 2011 18:27:00 +0900
Subject: [PATCH] Support surrounding-text retrieval. Subject: [PATCH] Support surrounding-text retrieval.
This change adds a new API function ibus_engine_get_surrounding_text(). This change adds a new API function ibus_engine_get_surrounding_text().
@ -216,7 +216,7 @@ index 32d51e8..20f561c 100644
context_signals[ENGINE_CHANGED], context_signals[ENGINE_CHANGED],
0); 0);
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 ab9c520..e61dd86 100644 index a4e46cb..d029b5c 100644
--- a/client/gtk2/ibusimcontext.c --- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c
@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
@ -237,7 +237,7 @@ index ab9c520..e61dd86 100644
}; };
struct _IBusIMContextClass { struct _IBusIMContextClass {
@@ -110,11 +112,18 @@ static void ibus_im_context_set_cursor_location @@ -111,11 +113,18 @@ static void ibus_im_context_set_cursor_location
static void ibus_im_context_set_use_preedit static void ibus_im_context_set_use_preedit
(GtkIMContext *context, (GtkIMContext *context,
gboolean use_preedit); gboolean use_preedit);
@ -256,7 +256,7 @@ index ab9c520..e61dd86 100644
static void _bus_connected_cb (IBusBus *bus, static void _bus_connected_cb (IBusBus *bus,
IBusIMContext *context); IBusIMContext *context);
@@ -128,14 +137,15 @@ static void _slave_preedit_start_cb (GtkIMContext *slave, @@ -129,14 +138,15 @@ static void _slave_preedit_start_cb (GtkIMContext *slave,
IBusIMContext *context); IBusIMContext *context);
static void _slave_preedit_end_cb (GtkIMContext *slave, static void _slave_preedit_end_cb (GtkIMContext *slave,
IBusIMContext *context); IBusIMContext *context);
@ -278,7 +278,7 @@ index ab9c520..e61dd86 100644
static void _create_fake_input_context (void); static void _create_fake_input_context (void);
@@ -247,6 +257,17 @@ _process_key_event_done (GObject *object, @@ -248,6 +258,17 @@ _process_key_event_done (GObject *object,
} }
@ -296,7 +296,7 @@ index ab9c520..e61dd86 100644
static gint static gint
_key_snooper_cb (GtkWidget *widget, _key_snooper_cb (GtkWidget *widget,
GdkEventKey *event, GdkEventKey *event,
@@ -333,6 +354,8 @@ _key_snooper_cb (GtkWidget *widget, @@ -334,6 +355,8 @@ _key_snooper_cb (GtkWidget *widget,
} while (0); } while (0);
@ -305,7 +305,7 @@ index ab9c520..e61dd86 100644
if (ibusimcontext != NULL) { if (ibusimcontext != NULL) {
ibusimcontext->time = event->time; ibusimcontext->time = event->time;
} }
@@ -429,6 +452,7 @@ ibus_im_context_class_init (IBusIMContextClass *class) @@ -430,6 +453,7 @@ ibus_im_context_class_init (IBusIMContextClass *class)
im_context_class->set_client_window = ibus_im_context_set_client_window; im_context_class->set_client_window = ibus_im_context_set_client_window;
im_context_class->set_cursor_location = ibus_im_context_set_cursor_location; im_context_class->set_cursor_location = ibus_im_context_set_cursor_location;
im_context_class->set_use_preedit = ibus_im_context_set_use_preedit; im_context_class->set_use_preedit = ibus_im_context_set_use_preedit;
@ -313,7 +313,7 @@ index ab9c520..e61dd86 100644
gobject_class->finalize = ibus_im_context_finalize; gobject_class->finalize = ibus_im_context_finalize;
_signal_commit_id = _signal_commit_id =
@@ -542,7 +566,12 @@ ibus_im_context_init (GObject *obj) @@ -577,7 +601,12 @@ ibus_im_context_init (GObject *obj)
ibusimcontext->ibuscontext = NULL; ibusimcontext->ibuscontext = NULL;
ibusimcontext->has_focus = FALSE; ibusimcontext->has_focus = FALSE;
ibusimcontext->time = GDK_CURRENT_TIME; ibusimcontext->time = GDK_CURRENT_TIME;
@ -327,7 +327,7 @@ index ab9c520..e61dd86 100644
// Create slave im context // Create slave im context
@@ -639,6 +668,8 @@ ibus_im_context_filter_keypress (GtkIMContext *context, @@ -674,6 +703,8 @@ ibus_im_context_filter_keypress (GtkIMContext *context,
if (ibusimcontext->client_window == NULL && event->window != NULL) if (ibusimcontext->client_window == NULL && event->window != NULL)
gtk_im_context_set_client_window ((GtkIMContext *)ibusimcontext, event->window); gtk_im_context_set_client_window ((GtkIMContext *)ibusimcontext, event->window);
@ -336,7 +336,7 @@ index ab9c520..e61dd86 100644
if (ibusimcontext != NULL) { if (ibusimcontext != NULL) {
ibusimcontext->time = event->time; ibusimcontext->time = event->time;
} }
@@ -733,6 +764,8 @@ ibus_im_context_focus_in (GtkIMContext *context) @@ -768,6 +799,8 @@ ibus_im_context_focus_in (GtkIMContext *context)
(gpointer *) &_focus_im_context); (gpointer *) &_focus_im_context);
_focus_im_context = context; _focus_im_context = context;
} }
@ -345,7 +345,7 @@ index ab9c520..e61dd86 100644
} }
static void static void
@@ -890,6 +923,25 @@ ibus_im_context_set_cursor_location (GtkIMContext *context, GdkRectangle *area) @@ -925,6 +958,25 @@ ibus_im_context_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
} }
static void static void
@ -371,7 +371,7 @@ index ab9c520..e61dd86 100644
ibus_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit) ibus_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
{ {
IDEBUG ("%s", __FUNCTION__); IDEBUG ("%s", __FUNCTION__);
@@ -898,17 +950,50 @@ ibus_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit) @@ -933,17 +985,50 @@ ibus_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
if(ibusimcontext->ibuscontext) { if(ibusimcontext->ibuscontext) {
if (use_preedit) { if (use_preedit) {
@ -425,7 +425,7 @@ index ab9c520..e61dd86 100644
_bus_connected_cb (IBusBus *bus, _bus_connected_cb (IBusBus *bus,
IBusIMContext *ibusimcontext) IBusIMContext *ibusimcontext)
{ {
@@ -927,6 +1012,8 @@ _ibus_context_commit_text_cb (IBusInputContext *ibuscontext, @@ -962,6 +1047,8 @@ _ibus_context_commit_text_cb (IBusInputContext *ibuscontext,
IDEBUG ("%s", __FUNCTION__); IDEBUG ("%s", __FUNCTION__);
g_signal_emit (ibusimcontext, _signal_commit_id, 0, text->text); g_signal_emit (ibusimcontext, _signal_commit_id, 0, text->text);
@ -434,7 +434,7 @@ index ab9c520..e61dd86 100644
} }
static gboolean static gboolean
@@ -1221,6 +1308,8 @@ _ibus_context_show_preedit_text_cb (IBusInputContext *ibuscontext, @@ -1256,6 +1343,8 @@ _ibus_context_show_preedit_text_cb (IBusInputContext *ibuscontext,
ibusimcontext->preedit_visible = TRUE; ibusimcontext->preedit_visible = TRUE;
g_signal_emit (ibusimcontext, _signal_preedit_start_id, 0); g_signal_emit (ibusimcontext, _signal_preedit_start_id, 0);
g_signal_emit (ibusimcontext, _signal_preedit_changed_id, 0); g_signal_emit (ibusimcontext, _signal_preedit_changed_id, 0);
@ -443,7 +443,7 @@ index ab9c520..e61dd86 100644
} }
static void static void
@@ -1286,6 +1375,14 @@ _ibus_context_destroy_cb (IBusInputContext *ibuscontext, @@ -1321,6 +1410,14 @@ _ibus_context_destroy_cb (IBusInputContext *ibuscontext,
} }
static void static void
@ -458,7 +458,7 @@ index ab9c520..e61dd86 100644
_create_input_context (IBusIMContext *ibusimcontext) _create_input_context (IBusIMContext *ibusimcontext)
{ {
IDEBUG ("%s", __FUNCTION__); IDEBUG ("%s", __FUNCTION__);
@@ -1328,6 +1425,10 @@ _create_input_context (IBusIMContext *ibusimcontext) @@ -1363,6 +1460,10 @@ _create_input_context (IBusIMContext *ibusimcontext)
"disabled", "disabled",
G_CALLBACK (_ibus_context_disabled_cb), G_CALLBACK (_ibus_context_disabled_cb),
ibusimcontext); ibusimcontext);
@ -469,7 +469,7 @@ index ab9c520..e61dd86 100644
g_signal_connect (ibusimcontext->ibuscontext, "destroy", g_signal_connect (ibusimcontext->ibuscontext, "destroy",
G_CALLBACK (_ibus_context_destroy_cb), G_CALLBACK (_ibus_context_destroy_cb),
ibusimcontext); ibusimcontext);
@@ -1384,17 +1485,21 @@ _slave_preedit_end_cb (GtkIMContext *slave, @@ -1419,17 +1520,21 @@ _slave_preedit_end_cb (GtkIMContext *slave,
g_signal_emit (ibusimcontext, _signal_preedit_end_id, 0); g_signal_emit (ibusimcontext, _signal_preedit_end_id, 0);
} }
@ -495,7 +495,7 @@ index ab9c520..e61dd86 100644
_slave_delete_surrounding_cb (GtkIMContext *slave, _slave_delete_surrounding_cb (GtkIMContext *slave,
gint offset_from_cursor, gint offset_from_cursor,
guint nchars, guint nchars,
@@ -1403,9 +1508,10 @@ _slave_delete_surrounding_cb (GtkIMContext *slave, @@ -1438,9 +1543,10 @@ _slave_delete_surrounding_cb (GtkIMContext *slave,
gboolean return_value; gboolean return_value;
if (ibusimcontext->enable && ibusimcontext->ibuscontext) { if (ibusimcontext->enable && ibusimcontext->ibuscontext) {
@ -508,12 +508,12 @@ index ab9c520..e61dd86 100644
#ifdef OS_CHROMEOS #ifdef OS_CHROMEOS
diff --git a/configure.ac b/configure.ac diff --git a/configure.ac b/configure.ac
index 05ceb18..0c06fbc 100644 index 81efe81..e5fe925 100644
--- a/configure.ac --- a/configure.ac
+++ b/configure.ac +++ b/configure.ac
@@ -368,6 +368,19 @@ else @@ -364,6 +364,19 @@ AC_ARG_WITH(sync-mode-apps,
enable_inputcontext_sync="no (disabled, use --enable-inputcontext-sync to enable)" AC_DEFINE_UNQUOTED(SYNC_MODE_APPS, "$SYNC_MODE_APPS",
fi [Enbale sync mode in those applications])
+# option for enable surrounding-text +# option for enable surrounding-text
+AC_ARG_ENABLE(surrounding-text, +AC_ARG_ENABLE(surrounding-text,
@ -531,9 +531,9 @@ index 05ceb18..0c06fbc 100644
# check iso-codes # check iso-codes
PKG_CHECK_MODULES(ISOCODES, [ PKG_CHECK_MODULES(ISOCODES, [
iso-codes iso-codes
@@ -439,5 +452,6 @@ Build options: @@ -435,5 +448,6 @@ Build options:
Enable key snooper $enable_key_snooper Enable key snooper $enable_key_snooper
Enable inputcontext sync $enable_inputcontext_sync Sync mode regexes "$SYNC_MODE_APPS"
No snooper regexes "$NO_SNOOPER_APPS" No snooper regexes "$NO_SNOOPER_APPS"
+ Enable surrounding-text $enable_surrounding_text + Enable surrounding-text $enable_surrounding_text
]) ])

View File

@ -93,71 +93,120 @@ index 745722f..608f294 100644
-- --
1.7.3.2 1.7.3.2
From 275087240dfa197177d5c31326d14d943e84bb29 Mon Sep 17 00:00:00 2001 From a00ebefde44cf5daaa642fc880c51357cb83f15b Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com> From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Fri, 4 Feb 2011 19:40:16 +0900 Date: Tue, 8 Feb 2011 18:17:11 +0900
Subject: [PATCH] Added the optional sync mode in IBusIMContext. Subject: [PATCH] Fixed typo.
Async mode always return TRUE in filter_keypress() so the caller could
ignore the events.
--- ---
client/gtk2/ibusimcontext.c | 5 +++-- client/gtk2/ibusimcontext.c | 10 +++++-----
configure.ac | 15 +++++++++++++++ 1 files changed, 5 insertions(+), 5 deletions(-)
2 files changed, 18 insertions(+), 2 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 745722f..ab9c520 100644 index 608f294..bb5ae5c 100644
--- a/client/gtk2/ibusimcontext.c --- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c
@@ -79,7 +79,7 @@ static const gchar *_no_snooper_apps = NO_SNOOPER_APPS; @@ -401,11 +401,11 @@ _get_boolean_env(const gchar *name,
if (value == NULL)
return defval;
- if (g_strcmp0 (name, "") == 0 ||
- g_strcmp0 (name, "0") == 0 ||
- g_strcmp0 (name, "false") == 0 ||
- g_strcmp0 (name, "False") == 0 ||
- g_strcmp0 (name, "FALSE") == 0)
+ if (g_strcmp0 (value, "") == 0 ||
+ g_strcmp0 (value, "0") == 0 ||
+ g_strcmp0 (value, "false") == 0 ||
+ g_strcmp0 (value, "False") == 0 ||
+ g_strcmp0 (value, "FALSE") == 0)
return FALSE;
return TRUE;
--
1.7.3.2
From c6949a852235bedb44126c3c6f36e1fba4b71bce Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Tue, 8 Feb 2011 18:21:50 +0900
Subject: [PATCH] Added the optional sync mode apps in IBusIMContext.
---
client/gtk2/ibusimcontext.c | 27 +++++++++++++++++++++++++++
configure.ac | 11 +++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index bb5ae5c..a4e46cb 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -79,6 +79,7 @@ static const gchar *_no_snooper_apps = NO_SNOOPER_APPS;
static gboolean _use_key_snooper = ENABLE_SNOOPER; static gboolean _use_key_snooper = ENABLE_SNOOPER;
static guint _key_snooper_id = 0; static guint _key_snooper_id = 0;
-static gboolean _use_sync_mode = FALSE; +static const gchar *_sync_mode_apps = SYNC_MODE_APPS;
+static gboolean _use_sync_mode = ENABLE_INPUTCONTEXT_SYNC; static gboolean _use_sync_mode = FALSE;
static GtkIMContext *_focus_im_context = NULL; static GtkIMContext *_focus_im_context = NULL;
static IBusInputContext *_fake_context = NULL; @@ -477,6 +478,32 @@ ibus_im_context_class_init (IBusIMContextClass *class)
@@ -457,7 +457,8 @@ ibus_im_context_class_init (IBusIMContextClass *class) g_strfreev (apps);
}
_use_key_snooper = !_get_boolean_env ("IBUS_DISABLE_SNOOPER", + /* env IBUS_SYNC_MODE_APPS for sync mode apps */
!(ENABLE_SNOOPER)); + /* It seems MetaDisplay does not take the events from gdk_event_put()
- _use_sync_mode = _get_boolean_env ("IBUS_ENABLE_SYNC_MODE", FALSE); + * in async mode. So if gnome-shell + mutter are used,
+ _use_sync_mode = _get_boolean_env ("IBUS_ENABLE_SYNC_MODE", + * the key events are lost in async mode.
+ ENABLE_INPUTCONTEXT_SYNC); + * gnome-shell search box, actually st_im_text_key_press_event(),
+ * does not call the parent filter_keypress() when the IM client
/* env IBUS_DISABLE_SNOOPER does not exist */ + * returns TRUE. The class inherits ClutterActor which is not
if (_use_key_snooper) { + * GtkWidget so the clutter does not call GTK snoopers.
+ * So ibus_im_context_filter_keypress() needs to return FALSE. */
+ if (!_use_sync_mode) {
+ /* enable sync mode if app is in _sync_mode_apps */
+ const gchar * prgname = g_get_prgname ();
+ if (g_getenv ("IBUS_SYNC_MODE_APPS")) {
+ _sync_mode_apps = g_getenv ("IBUS_SYNC_MODE_APPS");
+ }
+ gchar **p;
+ gchar ** apps = g_strsplit (_sync_mode_apps, ",", 0);
+ for (p = apps; *p != NULL; p++) {
+ if (g_regex_match_simple (*p, prgname, 0, 0)) {
+ _use_sync_mode = TRUE;
+ break;
+ }
+ }
+ g_strfreev (apps);
+ }
+
/* init bus object */
if (_bus == NULL) {
ibus_set_display (gdk_display_get_name (gdk_display_get_default ()));
diff --git a/configure.ac b/configure.ac diff --git a/configure.ac b/configure.ac
index 1a1e663..05ceb18 100644 index 1a1e663..81efe81 100644
--- a/configure.ac --- a/configure.ac
+++ b/configure.ac +++ b/configure.ac
@@ -354,6 +354,20 @@ AC_ARG_WITH(no-snooper-apps, @@ -354,6 +354,16 @@ AC_ARG_WITH(no-snooper-apps,
AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS", AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS",
[Does not enbale keyboard snooper in those applications]) [Does not enbale keyboard snooper in those applications])
+# option for always enable inputcontext sync. +# option for sync mode applications.
+AC_ARG_ENABLE(key-snooper, +AC_ARG_WITH(sync-mode-apps,
+ AS_HELP_STRING([--enable-inputcontext-sync], + AS_HELP_STRING([--with-sync-mode-apps[=regex1,regex2]],
+ [Always enable inputcontext sync in gtk im module]), + [Enable sync mode in those applications (like: .*chrome.*,firefox.*)]),
+ [enable_inputcontext_sync=$enableval], + [SYNC_MODE_APPS=$with_sync_mode_apps],
+ [enable_inputcontext_sync=yes] + [SYNC_MODE_APPS=[mutter]]
+) +)
+if test x"$enable_inputcontext_sync" = x"yes"; then +AC_DEFINE_UNQUOTED(SYNC_MODE_APPS, "$SYNC_MODE_APPS",
+ AC_DEFINE(ENABLE_INPUTCONTEXT_SYNC, TRUE, [Enable inputcontext sync]) + [Enbale sync mode in those applications])
+else
+ AC_DEFINE(ENABLE_INPUTCONTEXT_SYNC, FALSE, [Enable inputcontext sync])
+ enable_inputcontext_sync="no (disabled, use --enable-inputcontext-sync to enable)"
+fi
+ +
# check iso-codes # check iso-codes
PKG_CHECK_MODULES(ISOCODES, [ PKG_CHECK_MODULES(ISOCODES, [
iso-codes iso-codes
@@ -423,6 +437,7 @@ Build options: @@ -423,6 +433,7 @@ Build options:
Build vala binding $enable_vala Build vala binding $enable_vala
Build document $enable_gtk_doc Build document $enable_gtk_doc
Enable key snooper $enable_key_snooper Enable key snooper $enable_key_snooper
+ Enable inputcontext sync $enable_inputcontext_sync + Sync mode regexes "$SYNC_MODE_APPS"
No snooper regexes "$NO_SNOOPER_APPS" No snooper regexes "$NO_SNOOPER_APPS"
]) ])

View File

@ -12,7 +12,7 @@
Name: ibus Name: ibus
Version: 1.3.99.20110127 Version: 1.3.99.20110127
Release: 1%{?dist} Release: 2%{?dist}
Summary: Intelligent Input Bus for Linux OS Summary: Intelligent Input Bus for Linux OS
License: LGPLv2+ License: LGPLv2+
Group: System Environment/Libraries Group: System Environment/Libraries
@ -298,6 +298,10 @@ fi
%{_datadir}/gtk-doc/html/* %{_datadir}/gtk-doc/html/*
%changelog %changelog
* Tue Feb 08 2011 Takao Fujiwara <tfujiwar@redhat.com> - 1.3.99.20110127-2
- Fixed Bug 675503 - a regression in sync mode
Updated ibus-HEAD.patch from upstream.
* Fri Feb 04 2011 Takao Fujiwara <tfujiwar@redhat.com> - 1.3.99.20110127-1 * Fri Feb 04 2011 Takao Fujiwara <tfujiwar@redhat.com> - 1.3.99.20110127-1
- Updated to 1.3.99.20110127 - Updated to 1.3.99.20110127
- Updated ibus-HEAD.patch from upstream. - Updated ibus-HEAD.patch from upstream.