From 566270731276e9028350dd90b6982c865490f243 Mon Sep 17 00:00:00 2001 From: Huang Peng Date: Tue, 10 Feb 2009 10:17:01 +0800 Subject: [PATCH] Do not use glib main loop in ibus_input_context_process_key function. --- src/ibusconnection.c | 22 ++++++++++++++++++---- src/ibusconnection.h | 2 ++ src/ibusinputcontext.c | 5 ++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/ibusconnection.c b/src/ibusconnection.c index 90776cd..4821d6d 100644 --- a/src/ibusconnection.c +++ b/src/ibusconnection.c @@ -370,6 +370,16 @@ ibus_connection_get_connection (IBusConnection *connection) return priv->connection; } +gboolean +ibus_connection_read_write_dispatch (IBusConnection *connection, + gint timeout) +{ + IBusConnectionPrivate *priv; + priv = IBUS_CONNECTION_GET_PRIVATE (connection); + + return dbus_connection_read_write_dispatch (priv->connection, timeout); +} + typedef struct _VTableCallData { IBusMessageFunc message_func; gpointer user_data; @@ -558,10 +568,14 @@ ibus_connection_send_with_reply (IBusConnection *connection, IBusConnectionPrivate *priv; priv = IBUS_CONNECTION_GET_PRIVATE (connection); - return dbus_connection_send_with_reply (priv->connection, - message, - pending_return, - timeout_milliseconds); + gboolean retval; + + retval = dbus_connection_send_with_reply (priv->connection, + message, + pending_return, + timeout_milliseconds); + + return retval; } IBusMessage * diff --git a/src/ibusconnection.h b/src/ibusconnection.h index e4a70f7..5a8e099 100644 --- a/src/ibusconnection.h +++ b/src/ibusconnection.h @@ -94,6 +94,8 @@ IBusConnection *ibus_connection_open_private (const gchar *address void ibus_connection_close (IBusConnection *connection); gboolean ibus_connection_is_connected (IBusConnection *connection); DBusConnection *ibus_connection_get_connection (IBusConnection *connection); +gboolean ibus_connection_read_write_dispatch(IBusConnection *connection, + gint timeout); gboolean ibus_connection_send (IBusConnection *connection, IBusMessage *message); gboolean ibus_connection_send_signal (IBusConnection *connection, diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c index 71de8fb..94de55a 100644 --- a/src/ibusinputcontext.c +++ b/src/ibusinputcontext.c @@ -573,7 +573,10 @@ ibus_input_context_process_key_event (IBusInputContext *context, } /* wait reply or timeout */ - ibus_pending_call_wait (pending); + IBusConnection *connection = ibus_proxy_get_connection ((IBusProxy *) context); + while (!ibus_pending_call_get_completed (pending)) { + ibus_connection_read_write_dispatch (connection, -1); + } reply_message = ibus_pending_call_steal_reply (pending); ibus_pending_call_unref (pending); -- 2.7.4