コード例 #1
0
ファイル: vk.c プロジェクト: areslp/fcitx
void VKUpdate(void* arg)
{
    FcitxVKState *vkstate = (FcitxVKState*) arg;
    VKWindow* vkWindow = vkstate->vkWindow;
    if (vkWindow) {

        if (FcitxInstanceGetCurrentState(vkstate->owner) != IS_CLOSED && vkstate->bVK) {
            DrawVKWindow(vkWindow);
            DisplayVKWindow(vkWindow);
        } else
            XUnmapWindow(vkWindow->dpy, vkWindow->window);
    }
}
コード例 #2
0
ファイル: vk.c プロジェクト: areslp/fcitx
void SwitchVK(FcitxVKState *vkstate)
{
    FcitxInstance* instance = vkstate->owner;
    if (vkstate->vkWindow == NULL)
        vkstate->vkWindow = CreateVKWindow(vkstate);
    VKWindow *vkWindow = vkstate->vkWindow;
    if (!vkstate->iVKCount)
        return;

    vkstate->bVK = !vkstate->bVK;

    if (vkstate->bVK) {
        int             x, y;
        int dwidth, dheight;
        InvokeVaArgs(vkstate->owner, FCITX_X11, GETSCREENSIZE,
                     &dwidth, &dheight);

        if (!FcitxUISupportMainWindow(instance)) {
            x = dwidth / 2 - VK_WINDOW_WIDTH / 2;
            y = 40;
        } else {
            int mx = 0, my = 0, mw = 0, mh = 0;
            FcitxUIGetMainWindowSize(instance, &mx, &my, &mw, &mh);
            x = mx;
            y = my + mh + 2;
            if ((y + VK_WINDOW_HEIGHT) >= dheight)
                y = my - VK_WINDOW_HEIGHT - 2;
            if (y < 0)
                y = 0;
        }
        if ((x + VK_WINDOW_WIDTH) >= dwidth)
            x = dwidth - VK_WINDOW_WIDTH - 1;
        if (x < 0)
            x = 0;


        XMoveWindow(vkWindow->dpy, vkWindow->window, x, y);
        DisplayVKWindow(vkWindow);
        FcitxUICloseInputWindow(instance);

        FcitxInputContext* ic = FcitxInstanceGetCurrentIC(instance);

        if (ic && FcitxInstanceGetCurrentState(instance) == IS_CLOSED)
            FcitxInstanceEnableIM(instance, ic, true);
    } else {
        XUnmapWindow(vkWindow->dpy, vkWindow->window);
        FcitxInstanceCleanInputWindow(instance);
        FcitxUIUpdateInputWindow(instance);
    }
}
コード例 #3
0
ファイル: xim.c プロジェクト: t3swing/fcitx-clone
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;
}