Exemple #1
0
void InputWindowShow(InputWindow* inputWindow)
{
    if (!WindowIsVisable(inputWindow->parent.owner->dpy, inputWindow->parent.wId))
        InputWindowMoveWindow(&inputWindow->parent);
    XMapRaised(inputWindow->parent.owner->dpy, inputWindow->parent.wId);
    FcitxXlibWindowPaint(&inputWindow->parent);
}
Exemple #2
0
boolean MenuWindowEventHandler(void *arg, XEvent* event)
{
    XlibMenu* menu = (XlibMenu*) arg;
    FcitxXlibWindow* window = arg;
    FcitxClassicUI* classicui = window->owner;
    if (event->xany.window == window->wId) {
        switch (event->type) {
        case Expose:
            FcitxXlibWindowPaint(&menu->parent);
            break;
        case LeaveNotify: {
            int x = event->xcrossing.x_root;
            int y = event->xcrossing.y_root;

            if (!IsMouseInOtherMenu(menu, x, y)) {
                CloseAllSubMenuWindow(menu);
            }
        }
        break;
        case MotionNotify: {
            int offseth = 0;
            int i = SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth);
            boolean flag = ReverseColor(menu, i);
            FcitxMenuItem *item = GetMenuItem(menu->menushell, i);
            if (!flag) {
                XlibMenuShow(menu);
                if (item && item->type == MENUTYPE_SUBMENU && item->subMenu) {
                    XlibMenu* subxlibmenu = (XlibMenu*) item->subMenu->uipriv[classicui->isfallback];
                    CloseOtherSubMenuWindow(menu, subxlibmenu);
                    XlibMenuMoveSubMenu(subxlibmenu, menu, offseth);
                    XlibMenuShow(subxlibmenu);
                }
            }
            if (item == NULL)
                CloseOtherSubMenuWindow(menu, NULL);
        }
        break;
        case ButtonPress: {
            switch (event->xbutton.button) {
            case Button1: {
                int offseth;
                int i = SelectShellIndex(menu, event->xmotion.x, event->xmotion.y, &offseth);
                if (menu->menushell->MenuAction) {
                    if (menu->menushell->MenuAction(menu->menushell, i))
                        CloseAllMenuWindow(classicui);
                }
            }
            break;
            case Button3:
                CloseAllMenuWindow(classicui);
                break;
            }
        }
        break;
        }
        return true;
    }
    return false;
}
Exemple #3
0
void XlibMenuShow(XlibMenu* menu)
{
    if (!menu->visible) {
        FcitxMenuUpdate(menu->menushell);
    }
    FcitxXlibWindowPaint(&menu->parent);
    if (!menu->visible) {
        XMapRaised(menu->parent.owner->dpy, menu->parent.wId);
    }
    menu->visible = true;
}
Exemple #4
0
Fichier : skin.c Projet : ezc/fcitx
void DisplaySkin(FcitxClassicUI* classicui, char * skinname)
{
    char *pivot = classicui->skinType;
    classicui->skinType = strdup(skinname);
    if (pivot)
        free(pivot);

    if (LoadSkinConfig(&classicui->skin, &classicui->skinType))
        FcitxInstanceEnd(classicui->owner);

#ifndef _ENABLE_PANGO
    GetValidFont(classicui->strUserLocale, &classicui->font);
    GetValidFont(classicui->strUserLocale, &classicui->menuFont);
#endif

    FcitxXlibWindowPaint(&classicui->mainWindow->parent);
    FcitxXlibWindowPaint(&classicui->inputWindow->parent);
    TrayWindowDraw(classicui->trayWindow);

    SaveClassicUIConfig(classicui);

    classicui->epoch ++;
}
Exemple #5
0
boolean InputWindowEventHandler(void *arg, XEvent* event)
{
    FcitxXlibWindow* window = arg;
    InputWindow* inputWindow = arg;
    FcitxInstance* instance = window->owner->owner;
    FcitxInputState* input = FcitxInstanceGetInputState(instance);
    if (event->xany.window == window->wId) {
        switch (event->type) {
        case MotionNotify:
            {
                FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input);
                int             x,
                                y;
                x = event->xbutton.x;
                y = event->xbutton.y;

                boolean flag = false;
                int i;
                FcitxCandidateWord* candWord;
                uint32_t newHighlight = 0;
                for (candWord = FcitxCandidateWordGetCurrentWindow(candList), i = 0;
                     candWord != NULL;
                     candWord = FcitxCandidateWordGetCurrentWindowNext(candList, candWord), i ++) {
                    if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->candRect[i])) {
                        newHighlight = CANDIDATE_HIGHLIGHT(i);
                        flag = true;
                        break;
                    }
                }

                if (!flag) {
                    if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->prevRect)) {
                        newHighlight = PREVNEXT_HIGHLIGHT(true);
                    } else if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->nextRect)) {
                        newHighlight = PREVNEXT_HIGHLIGHT(false);
                    }
                }

                if (newHighlight != inputWindow->highlight) {
                    inputWindow->highlight = newHighlight;
                    FcitxXlibWindowPaint(&inputWindow->parent);
                }
            }
            break;
        case Expose:
            FcitxXlibWindowPaint(&inputWindow->parent);
            break;
        case ButtonPress:
            switch (event->xbutton.button) {
                case Button1: {

                    MainWindowSetMouseStatus(window->owner->mainWindow, NULL, RELEASE, RELEASE);
                    int             x,
                                    y;
                    x = event->xbutton.x;
                    y = event->xbutton.y;

                    FcitxCandidateWordList* candList = FcitxInputStateGetCandidateList(input);

                    boolean flag = false;
                    int i;
                    FcitxCandidateWord* candWord;
                    for (candWord = FcitxCandidateWordGetCurrentWindow(candList), i = 0;
                         candWord != NULL;
                         candWord = FcitxCandidateWordGetCurrentWindowNext(candList, candWord), i ++) {
                        if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->candRect[i])) {
                            FcitxInstanceChooseCandidateByIndex(instance, i);

                            flag = true;
                            break;
                        }
                    }

                    if (flag)
                        break;

                    if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->prevRect)) {
                        FcitxCandidateWordGoPrevPage(candList);
                        FcitxInstanceProcessInputReturnValue(window->owner->owner, IRV_DISPLAY_CANDWORDS);
                    } else if (IsInRect(x - window->contentX, y - window->contentY, &inputWindow->nextRect)) {
                        FcitxCandidateWordGoNextPage(candList);
                        FcitxInstanceProcessInputReturnValue(window->owner->owner, IRV_DISPLAY_CANDWORDS);
                    } else if (ClassicUIMouseClick(window->owner, window->wId, &x, &y)) {

                        FcitxInputContext* ic = FcitxInstanceGetCurrentIC(window->owner->owner);

                        if (ic) {
                            FcitxInstanceSetWindowOffset(window->owner->owner, ic, x - inputWindow->iOffsetX, y  - inputWindow->iOffsetY);
                        }

                        FcitxXlibWindowPaint(&inputWindow->parent);
                    }
                }
                break;
            }
            break;
        }
        return true;
    }
    return false;
}