[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 96469d4917e2d909
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
     1.1 --- a/src/core/linux/SDL_dbus.c	Sun Feb 01 21:08:54 2015 +0000
     1.2 +++ b/src/core/linux/SDL_dbus.c	Fri Feb 27 21:17:29 2015 +0000
     1.3 @@ -45,6 +45,7 @@
     1.4      SDL_DBUS_SYM(connection_set_exit_on_disconnect);
     1.5      SDL_DBUS_SYM(connection_get_is_connected);
     1.6      SDL_DBUS_SYM(connection_add_filter);
     1.7 +    SDL_DBUS_SYM(connection_try_register_object_path);
     1.8      SDL_DBUS_SYM(connection_send);
     1.9      SDL_DBUS_SYM(connection_send_with_reply_and_block);
    1.10      SDL_DBUS_SYM(connection_close);
     2.1 --- a/src/core/linux/SDL_dbus.h	Sun Feb 01 21:08:54 2015 +0000
     2.2 +++ b/src/core/linux/SDL_dbus.h	Fri Feb 27 21:17:29 2015 +0000
     2.3 @@ -41,6 +41,8 @@
     2.4      dbus_bool_t (*connection_get_is_connected)(DBusConnection *); 	
     2.5      dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction,
     2.6  	    void *, DBusFreeFunction);
     2.7 +    dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *,
     2.8 +        const DBusObjectPathVTable *, void *, DBusError *);
     2.9      dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *);
    2.10      DBusMessage *(*connection_send_with_reply_and_block)(DBusConnection *, DBusMessage *, int, DBusError *);
    2.11      void (*connection_close)(DBusConnection *);
     3.1 --- a/src/core/linux/SDL_ibus.c	Sun Feb 01 21:08:54 2015 +0000
     3.2 +++ b/src/core/linux/SDL_ibus.c	Fri Feb 27 21:17:29 2015 +0000
     3.3 @@ -123,7 +123,7 @@
     3.4  }
     3.5  
     3.6  static DBusHandlerResult
     3.7 -IBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *user_data)
     3.8 +IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data)
     3.9  {
    3.10      SDL_DBusContext *dbus = (SDL_DBusContext *)user_data;
    3.11          
    3.12 @@ -341,6 +341,8 @@
    3.13      const char *path = NULL;
    3.14      SDL_bool result = SDL_FALSE;
    3.15      DBusMessage *msg;
    3.16 +    DBusObjectPathVTable ibus_vtable = {0};
    3.17 +    ibus_vtable.message_function = &IBus_MessageHandler;
    3.18  
    3.19      ibus_conn = dbus->connection_open_private(addr, NULL);
    3.20  
    3.21 @@ -388,7 +390,7 @@
    3.22          SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL);
    3.23          
    3.24          dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL);
    3.25 -        dbus->connection_add_filter(ibus_conn, &IBus_MessageFilter, dbus, NULL);
    3.26 +        dbus->connection_try_register_object_path(ibus_conn, input_ctx_path, &ibus_vtable, dbus, NULL);
    3.27          dbus->connection_flush(ibus_conn);
    3.28      }
    3.29  
    3.30 @@ -668,7 +670,7 @@
    3.31          dbus->connection_read_write(ibus_conn, 0);
    3.32      
    3.33          while (dbus->connection_dispatch(ibus_conn) == DBUS_DISPATCH_DATA_REMAINS) {
    3.34 -            /* Do nothing, actual work happens in IBus_MessageFilter */
    3.35 +            /* Do nothing, actual work happens in IBus_MessageHandler */
    3.36          }
    3.37      }
    3.38  }