예제 #1
0
파일: IC.c 프로젝트: 13572293130/fcitx
/**
 * Interface for XIM Create Input Context
 *
 * @param  context Input Context
 * @param  priv private data passed by CreateIC
 * @return void
 **/
void XimCreateIC(void* arg, FcitxInputContext* context, void *priv)
{
    FcitxXimFrontend* xim = (FcitxXimFrontend*) arg;
    IMChangeICStruct * call_data = (IMChangeICStruct *)priv;
    context->privateic = fcitx_utils_malloc0(sizeof(FcitxXimIC));
    FcitxXimIC* privic = (FcitxXimIC*) context->privateic;
    FcitxGlobalConfig* config = FcitxInstanceGetGlobalConfig(xim->owner);

    privic->connect_id = call_data->connect_id;
    privic->id = ++ xim->icid;
    privic->offset_x = -1;
    privic->offset_y = -1;
    StoreIC(privic, call_data);
    SetTrackPos(xim, context, call_data);
    call_data->icid = privic->id;

    if (config->shareState == ShareState_PerProgram)
        FcitxInstanceSetICStateFromSameApplication(xim->owner, xim->frontendid, context);

    if (privic->input_style & XIMPreeditCallbacks)
        context->contextCaps |= CAPACITY_PREEDIT;
    else
        context->contextCaps &= ~CAPACITY_PREEDIT;

    return;
}
예제 #2
0
파일: xim.c 프로젝트: t3swing/fcitx-clone
Bool MyTriggerNotifyHandler (IMTriggerNotifyStruct * call_data)
{
    if (call_data->flag == 0) {
        /* Mainwindow always shows wrong input status, so fix it here */
        CurrentIC = (IC *) FindIC (call_data->icid);
        connect_id = call_data->connect_id;

        SetConnectID (call_data->connect_id, IS_CHN);
        icidSetIMState(call_data->icid, IS_CHN);

        EnterChineseMode (False);
        if (!bUseDBus)
            DrawMainWindow ();
    }

    SetTrackPos( (IMChangeICStruct *)call_data );
    if (bShowInputWindowTriggering && !bCorner) {
        DisplayInputWindow ();

#ifdef _ENABLE_TRAY
        if (!bUseDBus)
            DrawTrayWindow (ACTIVE_ICON, 0, 0, TRAY_ICON_HEIGHT, TRAY_ICON_WIDTH );
#endif
    }
    else
        return False;

    return True;
}
예제 #3
0
파일: xim.c 프로젝트: t3swing/fcitx-clone
Bool MySetICValuesHandler (IMChangeICStruct * call_data)
{
    SetIC (call_data);
    SetTrackPos(call_data);

    return True;
}
예제 #4
0
파일: ximhandler.c 프로젝트: adaptee/fcitx
Bool XIMSetFocusHandler(FcitxXimFrontend* xim, IMChangeFocusStruct * call_data)
{
    FcitxInputContext* ic =  FcitxInstanceFindIC(xim->owner, xim->frontendid, &call_data->icid);
    if (ic == NULL)
        return True;

    FcitxInputContext* oldic = FcitxInstanceGetCurrentIC(xim->owner);

    if (oldic && oldic != ic)
        FcitxUICommitPreedit(xim->owner);

    if (!FcitxInstanceSetCurrentIC(xim->owner, ic))
        return True;

    SetTrackPos(xim, ic, NULL);

    if (ic) {
        FcitxUIOnInputFocus(xim->owner);
    } else {
        FcitxUICloseInputWindow(xim->owner);
        FcitxUIMoveInputWindow(xim->owner);
    }

    return True;
}
예제 #5
0
파일: ximhandler.c 프로젝트: adaptee/fcitx
Bool XIMSetICValuesHandler(FcitxXimFrontend* xim, IMChangeICStruct * call_data)
{
    XimSetIC(xim, call_data);
    FcitxInputContext* ic = FcitxInstanceFindIC(xim->owner, xim->frontendid, &call_data->icid);
    SetTrackPos(xim, ic, call_data);

    return True;
}
예제 #6
0
파일: ximhandler.c 프로젝트: adaptee/fcitx
void XIMProcessKey(FcitxXimFrontend* xim, IMForwardEventStruct * call_data)
{
    KeySym originsym;
    FcitxKeySym sym;
    XKeyEvent *kev;
    int keyCount;
    uint32_t state;
    char strbuf[STRBUFLEN];
    FcitxInputContext* ic = FcitxInstanceGetCurrentIC(xim->owner);
    FcitxGlobalConfig* config = FcitxInstanceGetGlobalConfig(xim->owner);
    FcitxInputState* input = FcitxInstanceGetInputState(xim->owner);

    if (ic == NULL) {
        ic = FcitxInstanceFindIC(xim->owner, xim->frontendid, &call_data->icid);
        if (FcitxInstanceSetCurrentIC(xim->owner, ic) && ic)
            FcitxUIOnInputFocus(xim->owner);
    }

    if (ic == NULL)
        return;

    if (ic->frontendid != xim->frontendid || GetXimIC(ic)->id != call_data->icid) {
        ic = FcitxInstanceFindIC(xim->owner, xim->frontendid, &call_data->icid);
        if (ic == NULL)
            return;
        if (FcitxInstanceSetCurrentIC(xim->owner, ic))
            FcitxUIOnInputFocus(xim->owner);
    }

    kev = (XKeyEvent *) & call_data->event;
    memset(strbuf, 0, STRBUFLEN);
    keyCount = XLookupString(kev, strbuf, STRBUFLEN, &originsym, NULL);

    const uint32_t originstate = kev->state;
    state = kev->state - (kev->state & FcitxKeyState_NumLock) - (kev->state & FcitxKeyState_CapsLock) - (kev->state & FcitxKeyState_ScrollLock);
    state &= FcitxKeyState_UsedMask;
    FcitxHotkeyGetKey((FcitxKeySym) originsym, state, &sym, &state);
    FcitxLog(DEBUG,
             "KeyRelease=%d  state=%d  KEYCODE=%d  KEYSYM=%d  keyCount=%d",
             (call_data->event.type == KeyRelease), state, kev->keycode, (int) sym, keyCount);

    xim->currentSerialNumberCallData = call_data->serial_number;
    xim->currentSerialNumberKey = kev->serial;

    FcitxKeyEventType type = (call_data->event.type == KeyRelease) ? (FCITX_RELEASE_KEY) : (FCITX_PRESS_KEY);

    if (ic->state == IS_CLOSED) {
        if (type == FCITX_PRESS_KEY && FcitxHotkeyIsHotKey(sym, state, config->hkTrigger)) {
            FcitxInstanceEnableIM(xim->owner, ic, false);
            return;
        } else {
            XimForwardKeyInternal(xim,
                                  GetXimIC(ic),
                                  &call_data->event
                                 );
            return;
        }
    }

    FcitxInputStateSetKeyCode(input, kev->keycode);
    FcitxInputStateSetKeySym(input, originsym);
    FcitxInputStateSetKeyState(input, originstate);
    INPUT_RETURN_VALUE retVal = FcitxInstanceProcessKey(xim->owner, type,
                                           kev->time,
                                           sym, state);
    FcitxInputStateSetKeyCode(input, 0);
    FcitxInputStateSetKeySym(input, 0);
    FcitxInputStateSetKeyState(input, 0);

    if ((retVal & IRV_FLAG_FORWARD_KEY) || retVal == IRV_TO_PROCESS) {
        XimForwardKeyInternal(xim,
                              GetXimIC(ic),
                              &call_data->event
                             );
    } else {
        if (!GetXimIC(ic)->bHasCursorLocation)
            SetTrackPos(xim, ic, NULL);
    }
    xim->currentSerialNumberCallData = xim->currentSerialNumberKey = 0L;
}