From dae40bff0d53464fddb69e73f4a210e50473303c Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Fri, 27 Feb 2015 21:17:29 +0000 Subject: [PATCH] [IBus] Only register interest in messages sent to our input context. --- src/core/linux/SDL_dbus.c | 1 + src/core/linux/SDL_dbus.h | 2 ++ src/core/linux/SDL_ibus.c | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index 7c541ee0d..c342d58c5 100644 --- a/src/core/linux/SDL_dbus.c +++ b/src/core/linux/SDL_dbus.c @@ -45,6 +45,7 @@ load_dbus_syms(void) SDL_DBUS_SYM(connection_set_exit_on_disconnect); SDL_DBUS_SYM(connection_get_is_connected); SDL_DBUS_SYM(connection_add_filter); + SDL_DBUS_SYM(connection_try_register_object_path); SDL_DBUS_SYM(connection_send); SDL_DBUS_SYM(connection_send_with_reply_and_block); SDL_DBUS_SYM(connection_close); diff --git a/src/core/linux/SDL_dbus.h b/src/core/linux/SDL_dbus.h index c316c809f..dcfec77ef 100644 --- a/src/core/linux/SDL_dbus.h +++ b/src/core/linux/SDL_dbus.h @@ -41,6 +41,8 @@ typedef struct SDL_DBusContext { dbus_bool_t (*connection_get_is_connected)(DBusConnection *); dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction); + dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *, + const DBusObjectPathVTable *, void *, DBusError *); dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *); DBusMessage *(*connection_send_with_reply_and_block)(DBusConnection *, DBusMessage *, int, DBusError *); void (*connection_close)(DBusConnection *); diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index d3267ea8a..30aadf516 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -123,7 +123,7 @@ IBus_utf8_strlen(const char *str) } static DBusHandlerResult -IBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *user_data) +IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) { SDL_DBusContext *dbus = (SDL_DBusContext *)user_data; @@ -341,6 +341,8 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) const char *path = NULL; SDL_bool result = SDL_FALSE; DBusMessage *msg; + DBusObjectPathVTable ibus_vtable = {0}; + ibus_vtable.message_function = &IBus_MessageHandler; ibus_conn = dbus->connection_open_private(addr, NULL); @@ -388,7 +390,7 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL); dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL); - dbus->connection_add_filter(ibus_conn, &IBus_MessageFilter, dbus, NULL); + dbus->connection_try_register_object_path(ibus_conn, input_ctx_path, &ibus_vtable, dbus, NULL); dbus->connection_flush(ibus_conn); } @@ -668,7 +670,7 @@ SDL_IBus_PumpEvents(void) dbus->connection_read_write(ibus_conn, 0); while (dbus->connection_dispatch(ibus_conn) == DBUS_DISPATCH_DATA_REMAINS) { - /* Do nothing, actual work happens in IBus_MessageFilter */ + /* Do nothing, actual work happens in IBus_MessageHandler */ } } }