[IBus] Only register interest in messages sent to our input context.
authorAlex Baines <alex@abaines.me.uk>
Fri, 27 Feb 2015 21:17:29 +0000
changeset 9646 9d4917e2d909
parent 9645 b1e7169d1dcb
child 9647 5ab832f7bc38
[IBus] Only register interest in messages sent to our input context.
src/core/linux/SDL_dbus.c
src/core/linux/SDL_dbus.h
src/core/linux/SDL_ibus.c
--- a/src/core/linux/SDL_dbus.c	Sun Feb 01 21:08:54 2015 +0000
+++ b/src/core/linux/SDL_dbus.c	Fri Feb 27 21:17:29 2015 +0000
@@ -45,6 +45,7 @@
     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);
--- a/src/core/linux/SDL_dbus.h	Sun Feb 01 21:08:54 2015 +0000
+++ b/src/core/linux/SDL_dbus.h	Fri Feb 27 21:17:29 2015 +0000
@@ -41,6 +41,8 @@
     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 *);
--- a/src/core/linux/SDL_ibus.c	Sun Feb 01 21:08:54 2015 +0000
+++ b/src/core/linux/SDL_ibus.c	Fri Feb 27 21:17:29 2015 +0000
@@ -123,7 +123,7 @@
 }
 
 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 @@
     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 @@
         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 @@
         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 */
         }
     }
 }