Ejemplo n.º 1
0
void XimCloseIM(void* arg, FcitxInputContext* ic)
{
    FcitxXimFrontend* xim = (FcitxXimFrontend*) arg;
    IMChangeFocusStruct call_data;
    FcitxXimIC* ximic = (FcitxXimIC*) ic->privateic;
    call_data.connect_id = ximic->connect_id;
    call_data.icid = ximic->id;
    IMPreeditEnd(xim->ims, (XPointer) &call_data);
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: Abioy/ibus
static void
_xim_preedit_end (XIMS xims, const X11IC *x11ic)
{
    IMPreeditStateStruct ips;
    ips.major_code = 0;
    ips.minor_code = 0;
    ips.icid = x11ic->icid;
    ips.connect_id = x11ic->connect_id;
    IMPreeditEnd (xims, (XPointer)&ips);
}
Ejemplo n.º 3
0
void
xim_cancel_preedit(XIMHandle* handle)
{
    IC* ic = icmgr_get_current();
    if (ic == NULL)
        return;

    IMPreeditStateStruct ps;
    ps.icid = ic->icid;
    ps.connect_id = ic->connect_id;
    IMPreeditEnd(handle, (XPointer) &ps);
}
Ejemplo n.º 4
0
void* XimConsumeQueue(void* arg, FcitxModuleFunctionArg args)
{
    FcitxXimFrontend* xim = arg;
    if (!xim->ims)
        return NULL;
    XimQueue* item;

    size_t len = utarray_len(xim->queue);

    for (item = (XimQueue*) utarray_front(xim->queue);
         item != NULL;
         item = (XimQueue*) utarray_next(xim->queue, item))
    {
        switch(item->type) {
        case XCT_FORWARD:
            {
                IMForwardEvent(xim->ims, item->ptr);
            }
            break;
        case XCT_CALLCALLBACK:
            {
                IMCallCallback(xim->ims, item->ptr);
                IMPreeditCBStruct* pcb = (IMPreeditCBStruct*) item->ptr;
                if (pcb->major_code == XIM_PREEDIT_DRAW) {
                    XFree(pcb->todo.draw.text->string.multi_byte);
                    free(pcb->todo.draw.text);
                }
            }
            break;
        case XCT_COMMIT:
            {
                IMCommitString(xim->ims, item->ptr);
                IMCommitStruct* cms = (IMCommitStruct*) item->ptr;
                XFree(cms->commit_string);
            }
            break;
        case XCT_PREEDIT_START:
            IMPreeditStart(xim->ims, item->ptr);
            break;
        case XCT_PREEDIT_END:
            IMPreeditEnd(xim->ims, item->ptr);
            break;
        }
        free(item->ptr);
    }

    utarray_clear(xim->queue);
    if (len)
        FcitxInstanceSetRecheckEvent(xim->owner);
    return NULL;
}
Ejemplo n.º 5
0
void SetIMState (Bool bState)
{
    IMChangeFocusStruct call_data;

    if (!CurrentIC)
        return;

    if (connect_id && CurrentIC->id) {
        call_data.connect_id = connect_id;
        call_data.icid = CurrentIC->id;

        if (bState) {
            IMPreeditStart (ims, (XPointer) & call_data);
            SetConnectID (connect_id, IS_CHN);
        }
        else {
            IMPreeditEnd (ims, (XPointer) & call_data);
            SetConnectID (connect_id, IS_CLOSED);
            bVK = False;

            SwitchIM (-2);
        }
    }
}
Ejemplo n.º 6
0
Bool MySetFocusHandler (IMChangeFocusStruct * call_data)
{
    CurrentIC = (IC *) FindIC (call_data->icid);
    connect_id = call_data->connect_id;

    if (ConnectIDGetState (connect_id) != IS_CLOSED) {
        if (icidGetIMState(call_data->icid) == IS_CLOSED)
            IMPreeditStart (ims, (XPointer) call_data);

        EnterChineseMode (lastConnectID == connect_id);

        if (!bUseDBus)
            DrawMainWindow ();

        if (ConnectIDGetState (connect_id) == IS_CHN) {
            if (bVK)
                DisplayVKWindow ();
        }
        else {
            XUnmapWindow (dpy, inputWindow);
            if (!bUseDBus)
                XUnmapWindow (dpy, VKWindow);
        }
    }
    else {
        if (icidGetIMState(call_data->icid) != IS_CLOSED)
            IMPreeditEnd (ims, (XPointer) call_data);

        CloseInputWindow();
        if (!bUseDBus) {
            XUnmapWindow (dpy, VKWindow);

#ifdef _ENABLE_TRAY
            DrawTrayWindow (INACTIVE_ICON, 0, 0, TRAY_ICON_HEIGHT, TRAY_ICON_WIDTH );
#endif
            if (hideMainWindow == HM_SHOW) {
                DisplayMainWindow ();
                DrawMainWindow ();
            }
            else
                XUnmapWindow (dpy, mainWindow);
        }
#ifdef _ENABLE_DBUS
        else
            updatePropertyByConnectID(connect_id);
#endif

        icidSetIMState(call_data->icid, ConnectIDGetState (connect_id));
        lastConnectID = connect_id;
        //When application gets the focus, re-record the time.
        bStartRecordType = False;
        iHZInputed = 0;

        if (ConnectIDGetTrackCursor (connect_id) && bTrackCursor) {
            position * pos = ConnectIDGetPos(connect_id);

            if (pos) {
                iClientCursorX = pos->x;
                iClientCursorY = pos->y;
                if (!bUseDBus)
                    XMoveWindow (dpy, inputWindow, iClientCursorX, iClientCursorY);
#ifdef _ENABLE_DBUS
                else
                    KIMUpdateSpotLocation(iClientCursorX, iClientCursorY);
#endif
            }
        }

#ifdef _ENABLE_DBUS
        if (bUseDBus)
            registerProperties();
#endif
    }

    return True;
}