This commit is contained in:
Peng Huang 2010-06-12 08:53:43 +08:00
Родитель 79438c1322
Коммит 7e71514679
2 изменённых файлов: 30 добавлений и 19 удалений

Просмотреть файл

@ -75,7 +75,7 @@ static guint _signal_preedit_end_id = 0;
static guint _signal_delete_surrounding_id = 0; static guint _signal_delete_surrounding_id = 0;
static guint _signal_retrieve_surrounding_id = 0; static guint _signal_retrieve_surrounding_id = 0;
static const gchar * const _no_snooper_apps = NO_SNOOPER_APPS; static const gchar * const _snooper_apps = SNOOPER_APPS;
static gboolean _use_key_snooper = ENABLE_SNOOPER; static gboolean _use_key_snooper = ENABLE_SNOOPER;
static GtkIMContext *_focus_im_context = NULL; static GtkIMContext *_focus_im_context = NULL;
@ -288,19 +288,29 @@ ibus_im_context_class_init (IBusIMContextClass *klass)
g_signal_lookup ("retrieve-surrounding", G_TYPE_FROM_CLASS (klass)); g_signal_lookup ("retrieve-surrounding", G_TYPE_FROM_CLASS (klass));
g_assert (_signal_retrieve_surrounding_id != 0); g_assert (_signal_retrieve_surrounding_id != 0);
if (_use_key_snooper) { const gchar *ibus_snooper = g_getenv ("IBUS_SNOOPER");
if (g_getenv ("IBUS_DISABLE_SNOOPER") != NULL) { if (ibus_snooper) {
/* disable snooper if env IBUS_DISABLE_SNOOPER is set */ /* env IBUS_SNOOPER exist */
if (g_strcmp0 (ibus_snooper, "") == 0 ||
g_strcmp0 (ibus_snooper, "0") == 0 ||
g_strcmp0 (ibus_snooper, "false") == 0 ||
g_strcmp0 (ibus_snooper, "FALSE") == 0) {
_use_key_snooper = FALSE; _use_key_snooper = FALSE;
} }
else { else {
_use_key_snooper = TRUE;
}
}
else {
/* env IBUS_SNOOPER does not exist */
if (!_use_key_snooper) {
/* disable snooper if app is in _no_snooper_apps */ /* disable snooper if app is in _no_snooper_apps */
const gchar * prgname = g_get_prgname (); const gchar * prgname = g_get_prgname ();
gchar ** apps = g_strsplit (_no_snooper_apps, ",", 0); gchar ** apps = g_strsplit (_snooper_apps, ",", 0);
gchar **p; gchar **p;
for (p = apps; *p != NULL; p++) { for (p = apps; *p != NULL; p++) {
if (g_regex_match_simple (*p, prgname, 0, 0)) { if (g_regex_match_simple (*p, prgname, 0, 0)) {
_use_key_snooper = FALSE; _use_key_snooper = TRUE;
break; break;
} }
} }
@ -308,6 +318,7 @@ ibus_im_context_class_init (IBusIMContextClass *klass)
} }
} }
IDEBUG ("snooper = %d", _use_key_snooper);
if (_use_key_snooper) { if (_use_key_snooper) {
gtk_key_snooper_install (_key_snooper_cb, NULL); gtk_key_snooper_install (_key_snooper_cb, NULL);
} }

Просмотреть файл

@ -24,7 +24,7 @@
m4_define([ibus_released], [1]) m4_define([ibus_released], [1])
m4_define([ibus_major_version], [1]) m4_define([ibus_major_version], [1])
m4_define([ibus_minor_version], [3]) m4_define([ibus_minor_version], [3])
m4_define([ibus_micro_version], [4]) m4_define([ibus_micro_version], [5])
m4_define(ibus_maybe_datestamp, m4_define(ibus_maybe_datestamp,
m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi])) m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
@ -288,12 +288,12 @@ if test x"$enable_python" = x"yes"; then
fi fi
fi fi
# option for disable snooper applications # option for always enable snooper applications
AC_ARG_ENABLE(key-snooper, AC_ARG_ENABLE(key-snooper,
AS_HELP_STRING([--disable-key-snooper], AS_HELP_STRING([--enable-key-snooper],
[Disable key snooper in gtk im module]), [Always enable key snooper in gtk im module]),
[enable_key_snooper=$enableval], [enable_key_snooper=$enableval],
[enable_key_snooper=yes] [enable_key_snooper=no]
) )
if test x"$enable_key_snooper" = x"yes"; then if test x"$enable_key_snooper" = x"yes"; then
AC_DEFINE(ENABLE_SNOOPER, TRUE, [Enable key snooper]) AC_DEFINE(ENABLE_SNOOPER, TRUE, [Enable key snooper])
@ -303,14 +303,14 @@ else
fi fi
# option for no snooper applications # option for no snooper applications
AC_ARG_WITH(no-snooper-apps, AC_ARG_WITH(snooper-apps,
AS_HELP_STRING([--with-no-snooper-apps[=regex1,regex2]], AS_HELP_STRING([--with-snooper-apps[=regex1,regex2]],
[Does not enable keyboard snooper in those applications (like: .*chrome.*,firefox.*)]), [Enable keyboard snooper in those applications (default: xchat,pidgin,empathy)]),
NO_SNOOPER_APPS=$with_no_snooper_apps, SNOOPER_APPS=$with_snooper_apps,
NO_SNOOPER_APPS=.*chrome SNOOPER_APPS=[xchat,pidgin,empathy]
) )
AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS", AC_DEFINE_UNQUOTED(SNOOPER_APPS, "$SNOOPER_APPS",
[Does not enbale key snooper in those applications]) [Enbale keyboard snooper in those applications])
# check iso-codes # check iso-codes
PKG_CHECK_MODULES(ISOCODES, [ PKG_CHECK_MODULES(ISOCODES, [
@ -375,6 +375,6 @@ 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
No snooper regexes "$NO_SNOOPER_APPS" Snooper regexes "$SNOOPER_APPS"
]) ])