void X11ProcessSelectionNotifyEvent(FcitxX11 *x11priv, XSelectionEvent *selection_event) { X11ConvertSelection *convert; int id; int next_id; FcitxHandlerTable *table = x11priv->convertSelection; id = fcitx_handler_table_first_id(table, sizeof(Atom), &selection_event->selection); if (id == FCITX_OBJECT_POOL_INVALID_ID) return; unsigned long nitems; int ret_format; Atom ret_type = None; unsigned char *buff; buff = X11GetWindowProperty(x11priv, x11priv->eventWindow, selection_event->property, &ret_type, &ret_format, &nitems); for (;(convert = fcitx_handler_table_get_by_id(table, id));id = next_id) { next_id = fcitx_handler_table_next_id(table, convert); if (convert->cb(x11priv, selection_event->selection, selection_event->target, ret_format, nitems, buff, convert)) { fcitx_handler_table_remove_by_id(table, id); } } if (buff) { XFree(buff); buff = NULL; } }
FCITX_EXPORT_API void* fcitx_handler_table_first(FcitxHandlerTable *table, size_t keysize, const void *key) { unsigned int id = fcitx_handler_table_first_id(table, keysize, key); return fcitx_handler_table_get_by_id(table, id); }