Пример #1
0
static void
_fcitx_client_g_signal(GDBusProxy *proxy,
                       gchar      *sender_name,
                       gchar      *signal_name,
                       GVariant   *parameters,
                       gpointer    user_data)
{
    FCITX_UNUSED(proxy);
    FCITX_UNUSED(sender_name);
    if (strcmp(signal_name, "EnableIM") == 0) {
        g_signal_emit(user_data, signals[ENABLE_IM_SIGNAL], 0);
    }
    else if (strcmp(signal_name, "CloseIM") == 0) {
        g_signal_emit(user_data, signals[CLOSE_IM_SIGNAL], 0);
    }
    else if (strcmp(signal_name, "CommitString") == 0) {
        const gchar* data = NULL;
        g_variant_get(parameters, "(s)", &data);
        if (data) {
            g_signal_emit(user_data, signals[COMMIT_STRING_SIGNAL], 0, data);
        }
    }
    else if (strcmp(signal_name, "ForwardKey") == 0) {
        guint32 key, state;
        gint32 type;
        g_variant_get(parameters, "(uui)", &key, &state, &type);
        g_signal_emit(user_data, signals[FORWARD_KEY_SIGNAL], 0, key, state, type);
    }
    else if (strcmp(signal_name, "DeleteSurroundingText") == 0) {
        guint32 nchar;
        gint32 offset;
        g_variant_get(parameters, "(iu)", &offset, &nchar);
        g_signal_emit(user_data, signals[DELETE_SURROUNDING_TEXT_SIGNAL], 0, offset, nchar);
    }
    else if (strcmp(signal_name, "UpdateClientSideUI") == 0) {
        const gchar* auxup, *auxdown, *preedit, *candidate, *imname;
        int cursor;
        g_variant_get(parameters, "(sssssi)", &auxup, &auxdown, &preedit, &candidate, &imname, &cursor);
        g_signal_emit(user_data, signals[UPDATE_CLIENT_SIDE_UI_SIGNAL], 0, auxup, auxdown, preedit, candidate, imname, cursor);
    }
    else if (strcmp(signal_name, "UpdateFormattedPreedit") == 0) {
        int cursor_pos;
        GPtrArray* array = g_ptr_array_new_with_free_func(_item_free);
        GVariantIter* iter;
        g_variant_get(parameters, "(a(si)i)", &iter, &cursor_pos);

        gchar* string;
        int type;
        while (g_variant_iter_next(iter, "(si)", &string, &type, NULL)) {
            FcitxPreeditItem* item = g_malloc0(sizeof(FcitxPreeditItem));
            item->string = strdup(string);
            item->type = type;
            g_ptr_array_add(array, item);
            g_free(string);
        }
        g_variant_iter_free(iter);
        g_signal_emit(user_data, signals[UPDATED_FORMATTED_PREEDIT_SIGNAL], 0, array, cursor_pos);
        g_ptr_array_free(array, TRUE);
    }
}
Пример #2
0
static void
_process_cb(GObject* obj, GAsyncResult* res, gpointer user_data)
{
    FCITX_UNUSED(obj);
    FCITX_UNUSED(res);
    FCITX_UNUSED(user_data);
}
Пример #3
0
void fcitx_static_library_unload(const FcitxAddonConfig* addonConfig, FcitxAddonInstance* addonInst, FcitxAddonManager* manager, void* data)
{
    FCITX_UNUSED(addonConfig);
    FCITX_UNUSED(manager);
    FCITX_UNUSED(data);
    FCITX_UNUSED(addonInst);
}
Пример #4
0
bool structs_foreach(const char* key, size_t keyLen, void** data, void* userData)
{
    FCITX_UNUSED(keyLen);
    FCITX_UNUSED(data);
    FcitxDescription* desc = userData;
    fcitx_configuration_foreach(desc->rootConfig, key, false, "", struct_attribute_foreach, userData);
    return false;
}
Пример #5
0
void fcitx_shared_library_unload(const FcitxAddonConfig* addonConfig, FcitxAddonInstance* addonInst, FcitxAddonManager* manager, void* data)
{
    FCITX_UNUSED(addonConfig);
    FCITX_UNUSED(manager);
    FCITX_UNUSED(data);
    fcitx_library_unload(addonInst->resolverData);
    fcitx_library_free(addonInst->resolverData);
}
Пример #6
0
static void fcitx_input_method_g_signal(GDBusProxy *proxy,
                                        const gchar *sender_name,
                                        const gchar *signal_name,
                                        GVariant *parameters) {
    FCITX_UNUSED(proxy);
    FCITX_UNUSED(sender_name);
    FCITX_UNUSED(signal_name);
    FCITX_UNUSED(parameters);
}
Пример #7
0
static void
X11CompManagerSelectionNotify(FcitxX11 *x11priv, Atom selection, int subtype,
                              X11SelectionNotify *notify)
{
    FCITX_UNUSED(selection);
    FCITX_UNUSED(subtype);
    FCITX_UNUSED(notify);
    X11HandlerComposite(x11priv, X11GetCompositeManager(x11priv));
}
Пример #8
0
int _fcitx_configuration_compare(const char* keyA, size_t keyALen, const void* dataA, const char* keyB, size_t keyBLen, const void* dataB, void* userData)
{
    FCITX_UNUSED(keyA);
    FCITX_UNUSED(keyALen);
    FCITX_UNUSED(keyB);
    FCITX_UNUSED(keyBLen);
    fcitx_configuration_compare_context* context = userData;
    return context->callback(dataA, dataB, context->userData);
}
Пример #9
0
void* fcitx_keyboard_init(FcitxAddonManager* manager, const FcitxAddonConfig* config)
{
    FCITX_UNUSED(manager);
    FCITX_UNUSED(config);
    FcitxKeyboard* keyboard = fcitx_utils_new(FcitxKeyboard);
    char* localepath = fcitx_utils_get_fcitx_path("localedir");
    bindtextdomain("xkeyboard-config", localepath);
    bind_textdomain_codeset("xkeyboard-config", "UTF-8");
    free(localepath);

    return keyboard;
}
Пример #10
0
static void
_X11ClipboardClipboardNotifyCb(void *owner, const char *sel_str,
                               int subtype, void *data)
{
    FCITX_UNUSED(sel_str);
    FCITX_UNUSED(subtype);
    FCITX_UNUSED(data);
    FcitxClipboard *clipboard = owner;
    FcitxX11RequestConvertSelect(clipboard->owner, "CLIPBOARD", NULL,
                                 clipboard, _X11ClipboardClipboardConvertCb,
                                 NULL, NULL);
}
Пример #11
0
static void
_X11ClipboardClipboardConvertCb(
    void *owner, const char *sel_str, const char *tgt_str, int format,
    size_t nitems, const void *buff, void *data)
{
    FCITX_UNUSED(sel_str);
    FCITX_UNUSED(tgt_str);
    FCITX_UNUSED(data);
    FcitxClipboard *clipboard = owner;
    if (format != 8)
        return;
    ClipboardPushClipboard(clipboard, nitems, buff);
}
Пример #12
0
void KeyboardEngine::keyEvent(const InputMethodEntry &entry, KeyEvent &event) {
    // FIXME use entry to get layout info
    FCITX_UNUSED(entry);
    if (event.isRelease()) {
        return;
    }

    auto sym = event.key().sym();

    if (sym == FcitxKey_Shift_L || sym == FcitxKey_Shift_R || sym == FcitxKey_Alt_L || sym == FcitxKey_Alt_R ||
        sym == FcitxKey_Control_L || sym == FcitxKey_Control_R || sym == FcitxKey_Super_L || sym == FcitxKey_Super_R) {
        return;
    }

    auto compose = processCompose(event.key().sym(), event.key().states());
    if (compose == INVALID_COMPOSE_RESULT) {
        event.accept();
        return;
    }

    if (compose) {
        auto composeString = utf8::UCS4ToUTF8(compose);
        event.accept();
        event.inputContext()->commitString(composeString);
    }
}
Пример #13
0
/*
* 显示菜单上面的文字信息,只需要指定窗口,窗口宽度,需要显示文字的上边界,字体,显示的字符串和是否选择(选择后反色)
* 其他都固定,如背景和文字反色不反色的颜色,反色框和字的位置等
*/
void DisplayText(XlibMenu * menu, int shellindex, int line_y, int fontHeight)
{
    FcitxSkin *sc = &menu->owner->skin;
    int marginLeft = sc->skinMenu.marginLeft;
    int marginRight = sc->skinMenu.marginRight;
    cairo_t *  cr;
    cr = cairo_create(menu->menu_cs);
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;
    FCITX_UNUSED(dpi);

    SetFontContext(cr, menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);

    if (GetMenuItem(menu->menushell, shellindex)->isselect == 0) {
        fcitx_cairo_set_color(cr, &sc->skinFont.menuFontColor[MENU_INACTIVE]);

        OutputStringWithContext(cr, dpi, GetMenuItem(menu->menushell, shellindex)->tipstr, 15 + marginLeft , line_y);
    } else {
        cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
        fcitx_cairo_set_color(cr, &sc->skinMenu.activeColor);
        cairo_rectangle(cr, marginLeft , line_y, menu->width - marginRight - marginLeft, fontHeight + 4);
        cairo_fill(cr);

        fcitx_cairo_set_color(cr, &sc->skinFont.menuFontColor[MENU_ACTIVE]);
        OutputStringWithContext(cr, dpi, GetMenuItem(menu->menushell, shellindex)->tipstr , 15 + marginLeft , line_y);
    }
    ResetFontContext();
    cairo_destroy(cr);
}
Пример #14
0
static void
foreach_cb(gpointer data, gpointer user_data)
{
    FCITX_UNUSED(user_data);
    FcitxLayoutItem* item = data;
    g_debug("%s %s %s %s", item->layout, item->variant, item->name, item->langcode);
}
Пример #15
0
void find_top_level_structs(FcitxConfiguration* config, FcitxDescription* desc)
{
    FCITX_UNUSED(config);
    desc->topLevelStructs = fcitx_string_hashset_clone(desc->structs);

    fcitx_dict_foreach(desc->structs, structs_foreach, desc);
}
Пример #16
0
void GetMenuSize(XlibMenu * menu)
{
    int i = 0;
    int winheight = 0;
    int fontheight = 0;
    int menuwidth = 0;
    FcitxSkin *sc = &menu->owner->skin;
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;
    FCITX_UNUSED(dpi);

    winheight = sc->skinMenu.marginTop + sc->skinMenu.marginBottom;//菜单头和尾都空8个pixel
    fontheight = FontHeight(menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SIMPLE || GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU)
            winheight += 6 + fontheight;
        else if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_DIVLINE)
            winheight += 5;

        int width = StringWidth(GetMenuItem(menu->menushell, i)->tipstr, menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
        if (width > menuwidth)
            menuwidth = width;
    }
    menu->height = winheight;
    menu->width = menuwidth + sc->skinMenu.marginLeft + sc->skinMenu.marginRight + 15 + 20;
}
Пример #17
0
static void
_fcitx_client_disconnect(FcitxConnection* connection, gpointer user_data)
{
    FCITX_UNUSED(connection);
    FcitxClient *self = user_data;
    _fcitx_client_clean_up(self, FALSE);
}
Пример #18
0
uint32_t KeyboardEngine::processCompose(uint32_t keyval, uint32_t state) {
    // FIXME, should we check if state is 0?
    FCITX_UNUSED(state);
    if (!m_xkbComposeState) {
        return 0;
    }

    enum xkb_compose_feed_result result = xkb_compose_state_feed(m_xkbComposeState.get(), keyval);
    if (result == XKB_COMPOSE_FEED_IGNORED) {
        return 0;
    }

    enum xkb_compose_status status = xkb_compose_state_get_status(m_xkbComposeState.get());
    if (status == XKB_COMPOSE_NOTHING) {
        return 0;
    } else if (status == XKB_COMPOSE_COMPOSED) {
        char buffer[FCITX_UTF8_MAX_LENGTH + 1] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0'};
        int length = xkb_compose_state_get_utf8(m_xkbComposeState.get(), buffer, sizeof(buffer));
        xkb_compose_state_reset(m_xkbComposeState.get());
        if (length == 0) {
            return INVALID_COMPOSE_RESULT;
        }

        uint32_t c = 0;
        fcitx_utf8_get_char(buffer, &c);
        return c;
    } else if (status == XKB_COMPOSE_CANCELLED) {
        xkb_compose_state_reset(m_xkbComposeState.get());
    }

    return INVALID_COMPOSE_RESULT;
}
Пример #19
0
//根据Menu内容来绘制菜单内容
void DrawXlibMenu(XlibMenu * menu)
{
    FcitxSkin *sc = &menu->owner->skin;
    FcitxClassicUI *classicui = menu->owner;
    Display* dpy = classicui->dpy;
    GC gc = XCreateGC(dpy, menu->menuWindow, 0, NULL);
    int i = 0;
    int fontheight;
    int iPosY = 0;
    int dpi = sc->skinFont.respectDPI? menu->owner->dpi: 0;
    FCITX_UNUSED(dpi);

    fontheight = FontHeight(menu->owner->menuFont, sc->skinFont.menuFontSize, dpi);
    SkinImage *background = LoadImage(sc, sc->skinMenu.backImg, false);

    GetMenuSize(menu);
    EnlargeCairoSurface(&menu->menu_cs, menu->width, menu->height);

    if (background) {
        cairo_t* cr = cairo_create(menu->menu_cs);
        DrawResizableBackground(cr, background->image, menu->height, menu->width,
                                sc->skinMenu.marginLeft,
                                sc->skinMenu.marginTop,
                                sc->skinMenu.marginRight,
                                sc->skinMenu.marginBottom,
                                sc->skinMenu.fillV,
                                sc->skinMenu.fillH
                            );

        cairo_destroy(cr);
    }

    iPosY = sc->skinMenu.marginTop;
    for (i = 0; i < utarray_len(&menu->menushell->shell); i++) {
        if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SIMPLE || GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU) {
            DisplayText(menu, i, iPosY, fontheight);
            if (menu->menushell->mark == i)
                MenuMark(menu, iPosY, i);

            if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_SUBMENU)
                DrawArrow(menu, iPosY);
            iPosY = iPosY + 6 + fontheight;
        } else if (GetMenuItem(menu->menushell, i)->type == MENUTYPE_DIVLINE) {
            DrawDivLine(menu, iPosY);
            iPosY += 5;
        }
    }
    XResizeWindow(dpy, menu->menuWindow, menu->width, menu->height);
    _CAIRO_SETSIZE(menu->menu_x_cs, menu->width, menu->height);
    cairo_t* c = cairo_create(menu->menu_x_cs);
    cairo_set_operator(c, CAIRO_OPERATOR_SOURCE);
    cairo_set_source_surface(c, menu->menu_cs, 0, 0);
    cairo_rectangle(c, 0, 0, menu->width, menu->height);
    cairo_clip(c);
    cairo_paint(c);
    cairo_destroy(c);
    cairo_surface_flush(menu->menu_x_cs);
    XFreeGC(dpy, gc);
}
Пример #20
0
void
SpellCustomFreeDict(FcitxSpell *spell, SpellCustomDict *dict)
{
    FCITX_UNUSED(spell);
    fcitx_utils_free(dict->map);
    fcitx_utils_free(dict->words);
    free(dict);
}
Пример #21
0
boolean XimCheckICFromSameApplication(void* arg, FcitxInputContext* icToCheck, FcitxInputContext* ic)
{
    FCITX_UNUSED(arg);
    FcitxXimIC* ximictoCheck = GetXimIC(icToCheck);
    FcitxXimIC* ximic = GetXimIC(ic);

    return ximictoCheck->connect_id == ximic->connect_id;
}
Пример #22
0
static void
_connect_cb(FcitxClient* client, void* user_data)
{
    FCITX_UNUSED(user_data);
    GCancellable* cancellable = g_cancellable_new();
    fcitx_client_process_key_async(client, FcitxKey_a, 0, 0, 0, 0, -1, cancellable, _process_cb, NULL);
    g_cancellable_cancel(cancellable);
    g_object_unref(cancellable);
    fcitx_client_process_key_async(client, FcitxKey_a, 0, 0, 0, 0, -1, NULL, _process_cb, NULL);
}
Пример #23
0
void
_fcitx_client_process_key_cb(GObject *source_object,
                             GAsyncResult *res,
                             gpointer user_data)
{
    FCITX_UNUSED(source_object);
    ProcessKeyStruct* pk = user_data;
    pk->callback(G_OBJECT(pk->self), res, pk->user_data);
    _process_key_data_free(pk);
}
Пример #24
0
boolean  XimCheckIC(void* arg, FcitxInputContext* context, void* priv)
{
    FCITX_UNUSED(arg);
    CARD16* picid = (CARD16*) priv;
    FcitxXimIC* rec = (FcitxXimIC*) context->privateic;
    if (rec->id == *picid)
        return true;
    else
        return false;
}
Пример #25
0
static INPUT_RETURN_VALUE
LuaGetCandWord(void *arg, FcitxCandidateWord *candWord)
{
    FCITX_UNUSED(arg);
    LuaModule *luamodule = (LuaModule*)candWord->owner;
    FcitxInputState *input = FcitxInstanceGetInputState(GetFcitx(luamodule));
    strncpy(FcitxInputStateGetOutputString(input),
            candWord->strWord, MAX_USER_INPUT);
    return IRV_COMMIT_STRING;
}
Пример #26
0
static void
ChttransEnabledForIMFilter(FcitxGenericConfig *config, FcitxConfigGroup *group,
                           FcitxConfigOption *option, void *value,
                           FcitxConfigSync sync, void *arg)
{
    FCITX_UNUSED(group);
    FCITX_UNUSED(option);
    FCITX_UNUSED(arg);
    FcitxChttrans *chttrans = (FcitxChttrans*)config;
    char **enableForIM = (char**)value;
    if (sync == Value2Raw) {
        fcitx_utils_free(*enableForIM);
        *enableForIM = fcitx_string_map_to_string(chttrans->enableIM, ',');
    } else if (sync == Raw2Value) {
        if (*enableForIM) {
            fcitx_string_map_from_string(chttrans->enableIM, *enableForIM, ',');
        }
    }
}
Пример #27
0
static void
FcitxNotifyShowTipCallback(void *arg, uint32_t id, const char *action)
{
    FcitxNotifyShowTipData *data = arg;
    FCITX_UNUSED(id);
    if (!strcmp(action, "dont-show")) {
        fcitx_string_map_set(data->notify->hide_notify,
                             data->tip_id, true);
    }
}
Пример #28
0
static void
_fcitx_client_create_ic_phase1_finished(GObject *source_object,
                                        GAsyncResult *res,
                                        gpointer user_data)
{
    FCITX_UNUSED(source_object);
    fcitx_gclient_debug("_fcitx_client_create_ic_phase1_finished");
    g_return_if_fail (user_data != NULL);
    g_return_if_fail (FCITX_IS_CLIENT(user_data));
    FcitxClient* self = (FcitxClient*) user_data;
    if (self->priv->cancellable) {
        g_object_unref (self->priv->cancellable);
        self->priv->cancellable = NULL;
    }
    if (self->priv->improxy)
        g_object_unref(self->priv->improxy);
    self->priv->improxy = g_dbus_proxy_new_finish(res, NULL);

    do {
        if (!self->priv->improxy) {
            break;
        }

        gchar* owner_name = g_dbus_proxy_get_name_owner(self->priv->improxy);

        if (!owner_name) {
            g_object_unref(self->priv->improxy);
            self->priv->improxy = NULL;
            break;
        }
        g_free(owner_name);
    } while(0);

    if (!self->priv->improxy) {
        /* unref for create_ic */
        g_object_unref(self);
        return;
    }

    self->priv->cancellable = g_cancellable_new ();
    char* appname = fcitx_utils_get_process_name();
    int pid = getpid();
    g_dbus_proxy_call(
        self->priv->improxy,
        "CreateICv3",
        g_variant_new("(si)", appname, pid),
        G_DBUS_CALL_FLAGS_NONE,
        -1,           /* timeout */
        self->priv->cancellable,
        _fcitx_client_create_ic_cb,
        self
    );
    free(appname);

}
Пример #29
0
void find_structs_callback(FcitxConfiguration* config,
                          const char* path,
                          void* userData)
{
    FCITX_UNUSED(config);
    if (strcmp(path, "DescriptionFile") == 0) {
        return;
    }
    FcitxDescription* desc = userData;
    fcitx_string_hashset_insert(desc->structs, path);
}
Пример #30
0
bool fcitx_shared_library_resolve(const FcitxAddonConfig* addonConfig, FcitxAddonInstance* addonInst, FcitxAddonManager* manager, void* data)
{
    FCITX_UNUSED(data);
    FcitxStandardPath* standardPath = fcitx_addon_manager_get_standard_path(manager);
    char* toFree = NULL;
    const char* libraryName = NULL;
    if (!fcitx_utils_string_ends_with(addonConfig->addon.library, FCITX_LIBRARY_SUFFIX)) {
        asprintf(&toFree, "%s%s", addonConfig->addon.library, FCITX_LIBRARY_SUFFIX);
        libraryName = toFree;
    } else {
        libraryName = addonConfig->addon.library;
    }
    FcitxStandardPathFile* file = fcitx_standard_path_locate(standardPath, FSPT_Addon, libraryName, 0);
    free(toFree);
    if (!file) {
        return false;
    }

    bool result = false;
    FcitxLibrary* library = fcitx_library_new(file->path);
    do {
        if (!fcitx_library_load(library, FLLH_ResolveAllSymbolsHint | FLLH_PreventUnloadHint | FLLH_ExportExternalSymbolsHint)) {
            break;
        }

        int* version = _fcitx_library_get_symbol(library, addonConfig->addon.name, "ABI_VERSION");
        if (*version != FCITX_ABI_VERSION) {
            break;
        }

        addonInst->api = _fcitx_library_get_symbol(library, addonConfig->addon.name, addonType[addonConfig->addon.category]);
        if (!addonInst->api) {
            break;
        }

        FcitxAddonAPICommon* apiCommon = addonInst->api;
        if (!apiCommon->init && !apiCommon->destroy) {
            break;
        }
        addonInst->data = apiCommon->init(manager);
        if (!addonInst->data) {
            break;
        }

        addonInst->resolverData = library;
        result = true;
    } while(0);
    fcitx_standard_path_file_close(file);
    if (!result) {
        fcitx_library_free(library);
    }

    return result;
}