Event Module


Event based Modules in Fcitx are using fd to notify the main-loop whether there is new event or not. Following definition is defined in fcitx/module.h.

typedef struct _FcitxModule
{
    /**
     * @brief construction function
     */
    void* (*Create)(struct _FcitxInstance* instance);
    /**
     * @brief set main loop watch fd, no need to implement
     */
    void (*SetFD)(void*);
    /**
     * @brief main loop event handle, no need to implement
     */
    void (*ProcessEvent)(void*);
    /**
     * @brief destruct function
     */
    void (*Destroy)(void*);
    /**
     * @brief reload config, no need to implement
     */
    void (*ReloadConfig)(void*);
} FcitxModule;
            

After select from multiple fd, the ProcessEvent will be called and modules will process there own event.

Module need to update rfds, wfds, efds in FcitxInstance and set the maxfd member in FcitxInstance, After modules process all events, all three fd_set will be set by FD_ZERO and SetFD will be called to set them.