src/core/linux/SDL_ibus.c
changeset 9646 9d4917e2d909
parent 9645 b1e7169d1dcb
child 9712 a964d651f1dd
equal deleted inserted replaced
9645:b1e7169d1dcb 9646:9d4917e2d909
   121     
   121     
   122     return utf8_len;
   122     return utf8_len;
   123 }
   123 }
   124 
   124 
   125 static DBusHandlerResult
   125 static DBusHandlerResult
   126 IBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *user_data)
   126 IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data)
   127 {
   127 {
   128     SDL_DBusContext *dbus = (SDL_DBusContext *)user_data;
   128     SDL_DBusContext *dbus = (SDL_DBusContext *)user_data;
   129         
   129         
   130     if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "CommitText")) {
   130     if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "CommitText")) {
   131         DBusMessageIter iter;
   131         DBusMessageIter iter;
   339 IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr)
   339 IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr)
   340 {
   340 {
   341     const char *path = NULL;
   341     const char *path = NULL;
   342     SDL_bool result = SDL_FALSE;
   342     SDL_bool result = SDL_FALSE;
   343     DBusMessage *msg;
   343     DBusMessage *msg;
       
   344     DBusObjectPathVTable ibus_vtable = {0};
       
   345     ibus_vtable.message_function = &IBus_MessageHandler;
   344 
   346 
   345     ibus_conn = dbus->connection_open_private(addr, NULL);
   347     ibus_conn = dbus->connection_open_private(addr, NULL);
   346 
   348 
   347     if (!ibus_conn) {
   349     if (!ibus_conn) {
   348         return SDL_FALSE;
   350         return SDL_FALSE;
   386 
   388 
   387     if (result) {
   389     if (result) {
   388         SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL);
   390         SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL);
   389         
   391         
   390         dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL);
   392         dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL);
   391         dbus->connection_add_filter(ibus_conn, &IBus_MessageFilter, dbus, NULL);
   393         dbus->connection_try_register_object_path(ibus_conn, input_ctx_path, &ibus_vtable, dbus, NULL);
   392         dbus->connection_flush(ibus_conn);
   394         dbus->connection_flush(ibus_conn);
   393     }
   395     }
   394 
   396 
   395     SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL);
   397     SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL);
   396     SDL_IBus_UpdateTextRect(NULL);
   398     SDL_IBus_UpdateTextRect(NULL);
   666     
   668     
   667     if (IBus_CheckConnection(dbus)) {
   669     if (IBus_CheckConnection(dbus)) {
   668         dbus->connection_read_write(ibus_conn, 0);
   670         dbus->connection_read_write(ibus_conn, 0);
   669     
   671     
   670         while (dbus->connection_dispatch(ibus_conn) == DBUS_DISPATCH_DATA_REMAINS) {
   672         while (dbus->connection_dispatch(ibus_conn) == DBUS_DISPATCH_DATA_REMAINS) {
   671             /* Do nothing, actual work happens in IBus_MessageFilter */
   673             /* Do nothing, actual work happens in IBus_MessageHandler */
   672         }
   674         }
   673     }
   675     }
   674 }
   676 }
   675 
   677 
   676 #endif
   678 #endif