static void* PinyinEnhanceCreate(FcitxInstance *instance) { PinyinEnhance *pyenhance = fcitx_utils_new(PinyinEnhance); pyenhance->owner = instance; if (!PinyinEnhanceLoadConfig(&pyenhance->config)) { free(pyenhance); return NULL; } PinyinEnhanceSymInit(pyenhance); FcitxIMEventHook event_hook = { .arg = pyenhance, .func = PinyinEnhanceAddCandidateWord, }; FcitxInstanceRegisterUpdateCandidateWordHook(instance, event_hook); event_hook.func = PinyinEnhanceResetHook; FcitxInstanceRegisterResetInputHook(instance, event_hook); FcitxKeyFilterHook key_hook = { .arg = pyenhance, .func = PinyinEnhancePostInput }; FcitxInstanceRegisterPostInputFilter(pyenhance->owner, key_hook); key_hook.func = PinyinEnhancePreInput; FcitxInstanceRegisterPreInputFilter(pyenhance->owner, key_hook); FcitxPinyinEnhanceAddFunctions(instance); return pyenhance; }
void * QuickPhraseCreate(FcitxInstance *instance) { QuickPhraseState *qpstate = fcitx_utils_malloc0(sizeof(QuickPhraseState)); qpstate->owner = instance; qpstate->enabled = false; if (!LoadQuickPhraseConfig(&qpstate->config)) { free(qpstate); return NULL; } LoadQuickPhrase(qpstate); FcitxKeyFilterHook hk; hk.arg = qpstate; hk.func = QuickPhrasePostFilter; FcitxInstanceRegisterPostInputFilter(instance, hk); hk.func = QuickPhrasePreFilter; FcitxInstanceRegisterPreInputFilter(instance, hk); FcitxIMEventHook resethk; resethk.arg = qpstate; resethk.func = QuickPhraseReset; FcitxInstanceRegisterResetInputHook(instance, resethk); FcitxInstanceRegisterWatchableContext(instance, CONTEXT_DISABLE_QUICKPHRASE, FCT_Boolean, FCF_ResetOnInputMethodChange); FcitxAddon* addon = FcitxAddonsGetAddonByName( FcitxInstanceGetAddons(instance), FCITX_QUICKPHRASE_NAME); FcitxModuleAddFunction(addon, QuickPhraseLaunch); return qpstate; }
void *AutoEngCreate(FcitxInstance *instance) { FcitxAutoEngState* autoEngState = fcitx_utils_new(FcitxAutoEngState); autoEngState->owner = instance; LoadAutoEng(autoEngState); FcitxKeyFilterHook khk; khk.arg = autoEngState; khk.func = PreInputProcessAutoEng; FcitxInstanceRegisterPreInputFilter(instance, khk); khk.func = PostInputProcessAutoEng; FcitxInstanceRegisterPostInputFilter(instance, khk); FcitxIMEventHook rhk; rhk.arg = autoEngState; rhk.func = ResetAutoEng; FcitxInstanceRegisterResetInputHook(instance, rhk); FcitxInstanceRegisterWatchableContext(instance, CONTEXT_DISABLE_AUTOENG, FCT_Boolean, FCF_ResetOnInputMethodChange); ResetAutoEng(autoEngState); return autoEngState; }
static void* ClipboardCreate(FcitxInstance *instance) { FcitxClipboard *clipboard = fcitx_utils_new(FcitxClipboard); clipboard->owner = instance; if (!FcitxClipboardLoadConfig(&clipboard->config)) { ClipboardDestroy(clipboard); return NULL; } ClipboardInitReadHistory(clipboard); /* #ifdef ENABLE_X11 */ ClipboardInitX11(clipboard); /* #endif */ ApplyClipboardConfig(clipboard); FcitxKeyFilterHook key_hook = { .arg = clipboard, .func = ClipboardPreHook }; FcitxInstanceRegisterPreInputFilter(instance, key_hook); key_hook.func = ClipboardPostHook; FcitxInstanceRegisterPostInputFilter(instance, key_hook); FcitxIMEventHook reset_hook = { .arg = clipboard, .func = ClipboardReset }; FcitxInstanceRegisterResetInputHook(instance, reset_hook); FcitxAddon *self = FcitxClipboardGetAddon(instance); FcitxModuleAddFunction(self, ClipboardGetPrimary); FcitxModuleAddFunction(self, ClipboardGetClipboard); return clipboard; }
void* UnicodeCreate(FcitxInstance* instance) { UnicodeModule* uni = fcitx_utils_new(UnicodeModule); uni->owner = instance; if (!UnicodeLoadConfig(uni)) { free(uni); return NULL; } FcitxIMEventHook imhk; imhk.arg = uni; imhk.func = UnicodeReset; FcitxInstanceRegisterResetInputHook(instance, imhk); FcitxKeyFilterHook kfhk; kfhk.arg = uni; kfhk.func = UnicodePreFilter; FcitxInstanceRegisterPreInputFilter(instance, kfhk); kfhk.arg = &uni->enable; kfhk.func = FcitxDummyReleaseInputHook; FcitxInstanceRegisterPreReleaseInputFilter(instance, kfhk); FcitxHotkeyHook hkhk; hkhk.arg = uni; hkhk.hotkey = uni->key; hkhk.hotkeyhandle = UnicodeHotkey; FcitxInstanceRegisterHotkeyFilter(instance, hkhk); return uni; }
void *QuickPhraseCreate(FcitxInstance *instance) { QuickPhraseState *qpstate = fcitx_utils_new(QuickPhraseState); qpstate->owner = instance; qpstate->enabled = false; if (!LoadQuickPhraseConfig(&qpstate->config)) { free(qpstate); return NULL; } LoadQuickPhrase(qpstate); FcitxKeyFilterHook hk; hk.arg = qpstate; hk.func = QuickPhrasePostFilter; FcitxInstanceRegisterPostInputFilter(instance, hk); hk.func = QuickPhrasePreFilter; FcitxInstanceRegisterPreInputFilter(instance, hk); FcitxIMEventHook resethk; resethk.arg = qpstate; resethk.func = QuickPhraseReset; FcitxInstanceRegisterResetInputHook(instance, resethk); FcitxInstanceRegisterWatchableContext(instance, CONTEXT_DISABLE_QUICKPHRASE, FCT_Boolean, FCF_ResetOnInputMethodChange); FcitxQuickPhraseAddFunctions(instance); return qpstate; }
void* IMSelectorCreate(FcitxInstance* instance) { IMSelector* imselector = fcitx_utils_malloc0(sizeof(IMSelector)); imselector->owner = instance; if (!LoadIMSelectorConfig(imselector)) { free(imselector); return NULL; } FcitxKeyFilterHook hk; hk.arg = imselector; hk.func = IMSelectorPreFilter; FcitxInstanceRegisterPreInputFilter(instance, hk); FcitxHotkeyHook hkhk; hkhk.arg = imselector; hkhk.hotkeyhandle = IMSelectorLocalTrigger; hkhk.hotkey = imselector->localKey; FcitxInstanceRegisterHotkeyFilter(instance, hkhk); hkhk.arg = imselector; hkhk.hotkeyhandle = IMSelectorGlobalTrigger; hkhk.hotkey = imselector->globalKey; FcitxInstanceRegisterHotkeyFilter(instance, hkhk); FcitxIMEventHook resethk; resethk.arg = imselector; resethk.func = IMSelectorReset; FcitxInstanceRegisterResetInputHook(instance, resethk); return imselector; }
void* LightUICreate(FcitxInstance* instance) { FcitxModuleFunctionArg arg; FcitxLightUI* lightui = fcitx_utils_malloc0(sizeof(FcitxLightUI)); FcitxAddon* lightuiaddon = FcitxAddonsGetAddonByName(FcitxInstanceGetAddons(instance), FCITX_LIGHT_UI_NAME); lightui->owner = instance; if (!LoadLightUIConfig(lightui)) { free(lightui); return NULL; } lightui->dpy = InvokeFunction(instance, FCITX_X11, GETDISPLAY, arg); if (lightui->dpy == NULL) { free(lightui); return NULL; } lightui->isfallback = FcitxUIIsFallback(instance, lightuiaddon); lightui->iScreen = DefaultScreen(lightui->dpy); CreateFont(lightui); lightui->protocolAtom = XInternAtom (lightui->dpy, "WM_PROTOCOLS", False); lightui->killAtom = XInternAtom (lightui->dpy, "WM_DELETE_WINDOW", False); /* Main Menu Initial */ FcitxMenuInit(&lightui->mainMenu); FcitxUIMenu **menupp; UT_array* uimenus = FcitxInstanceGetUIMenus(instance); for (menupp = (FcitxUIMenu **) utarray_front(uimenus); menupp != NULL; menupp = (FcitxUIMenu **) utarray_next(uimenus, menupp) ) { FcitxUIMenu * menup = *menupp; if (!menup->isSubMenu) FcitxMenuAddMenuItem(&lightui->mainMenu, menup->name, MENUTYPE_SUBMENU, menup); } FcitxMenuAddMenuItem(&lightui->mainMenu, NULL, MENUTYPE_DIVLINE, NULL); FcitxMenuAddMenuItem(&lightui->mainMenu, _("Configure"), MENUTYPE_SIMPLE, NULL); FcitxMenuAddMenuItem(&lightui->mainMenu, _("Exit"), MENUTYPE_SIMPLE, NULL); lightui->mainMenu.MenuAction = MainMenuAction; lightui->mainMenu.priv = lightui; lightui->mainMenu.mark = -1; lightui->inputWindow = CreateInputWindow(lightui); lightui->mainWindow = CreateMainWindow(lightui); lightui->trayWindow = CreateTrayWindow(lightui); lightui->mainMenuWindow = CreateMainMenuWindow(lightui); FcitxIMEventHook resethk; resethk.arg = lightui; resethk.func = LightUIInputReset; FcitxInstanceRegisterResetInputHook(instance, resethk); return lightui; }
void* FcitxUnikeyCreate(FcitxInstance* instance) { FcitxUnikey* unikey = (FcitxUnikey*) fcitx_utils_malloc0(sizeof(FcitxUnikey)); if (!LoadUnikeyConfig(&unikey->config)) { free(unikey); return NULL; } unikey->owner = instance; unikey->preeditstr = new std::string; union { short s; unsigned char b[2]; } endian; endian.s = 0x1234; if (endian.b[0] == 0x12) unikey->conv = iconv_open("utf-8", "ucs-4be"); else unikey->conv = iconv_open("utf-8", "ucs-4le"); FcitxIMIFace iface; memset(&iface, 0, sizeof(FcitxIMIFace)); iface.Init = FcitxUnikeyInit; iface.ResetIM = FcitxUnikeyReset; iface.DoInput = FcitxUnikeyDoInput; iface.ReloadConfig = ReloadConfigFcitxUnikey; iface.Save = FcitxUnikeySave; FcitxInstanceRegisterIMv2( instance, unikey, "unikey", _("Unikey"), "unikey", iface, 1, "vi" ); UnikeySetup(); InitializeBar(unikey); InitializeMenu(unikey); ConfigUnikey(unikey); FcitxIMEventHook hk; hk.arg = unikey; hk.func = FcitxUnikeyResetUI; FcitxInstanceRegisterResetInputHook(instance, hk); return unikey; }
void* PuncCreate(FcitxInstance* instance) { FcitxPuncState* puncState = fcitx_utils_malloc0(sizeof(FcitxPuncState)); FcitxAddon* puncaddon = FcitxAddonsGetAddonByName(FcitxInstanceGetAddons(instance), FCITX_PUNC_NAME); puncState->owner = instance; LoadPuncDict(puncState); FcitxKeyFilterHook hk; hk.arg = puncState; hk.func = ProcessPunc; FcitxInstanceRegisterPostInputFilter(instance, hk); hk.func = PuncPreFilter; FcitxInstanceRegisterPreInputFilter(instance, hk); puncState->cLastIsAutoConvert = '\0'; puncState->bLastIsNumber = false; FcitxHotkeyHook hotkey; hotkey.hotkey = FcitxInstanceGetGlobalConfig(instance)->hkPunc; hotkey.hotkeyhandle = TogglePuncStateWithHotkey; hotkey.arg = puncState; FcitxInstanceRegisterHotkeyFilter(instance, hotkey); FcitxIMEventHook hook; hook.arg = puncState; hook.func = ResetPunc; FcitxInstanceRegisterResetInputHook(instance, hook); hook.func = ResetPuncWhichStatus; FcitxInstanceRegisterInputUnFocusHook(instance, hook); FcitxInstanceWatchContext(instance, CONTEXT_IM_LANGUAGE, PuncLanguageChanged, puncState); FcitxProfile* profile = FcitxInstanceGetProfile(instance); FcitxUIRegisterStatus(instance, puncState, "punc", profile->bUseWidePunc ? _("Full width punct") : _("Latin punct"), _("Toggle Full Width Punctuation"), TogglePuncState, GetPuncState); puncState->slot = FcitxInstanceAllocDataForIC(instance, PuncWhichAlloc, PuncWhichCopy, PuncWhichFree, puncState); FcitxModuleAddFunction(puncaddon, PuncGetPunc); FcitxModuleAddFunction(puncaddon, PuncGetPunc2); return puncState; }
void* FcitxUnikeyCreate(FcitxInstance* instance) { FcitxUnikey* unikey = (FcitxUnikey*) fcitx_utils_malloc0(sizeof(FcitxUnikey)); if (!LoadUnikeyConfig(&unikey->config)) { free(unikey); return NULL; } unikey->owner = instance; unikey->preeditstr = new std::string; FcitxIMIFace iface; memset(&iface, 0, sizeof(FcitxIMIFace)); iface.Init = FcitxUnikeyInit; iface.ResetIM = FcitxUnikeyReset; iface.DoInput = FcitxUnikeyDoInput; iface.ReloadConfig = ReloadConfigFcitxUnikey; iface.Save = FcitxUnikeySave; FcitxInstanceRegisterIMv2( instance, unikey, "unikey", _("Unikey"), "unikey", iface, 1, "vi" ); UnikeySetup(); InitializeBar(unikey); InitializeMenu(unikey); ConfigUnikey(unikey); FcitxIMEventHook hk; hk.arg = unikey; hk.func = FcitxUnikeyResetUI; FcitxInstanceRegisterResetInputHook(instance, hk); return unikey; }
static void* FcitxKkcCreate(FcitxInstance *instance) { FcitxKkc *kkc = fcitx_utils_new(FcitxKkc); bindtextdomain("fcitx-kkc", LOCALEDIR); bind_textdomain_codeset("fcitx-kkc", "UTF-8"); kkc->owner = instance; if (!KkcLoadConfig(&kkc->config)) { free(kkc); return NULL; } #if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init(); #endif kkc_init(); KkcLanguageModel* model = kkc_language_model_load("sorted3", NULL); if (!model) { free(kkc); return NULL; } FcitxXDGMakeDirUser("kkc/rules"); FcitxXDGMakeDirUser("kkc/dictionary"); kkc->model = model; kkc->context = kkc_context_new(model); if (!FcitxKkcLoadDictionary(kkc) || !FcitxKkcLoadRule(kkc)) { g_object_unref(kkc->context); free(kkc); return NULL; } kkc_context_set_punctuation_style(kkc->context, KKC_PUNCTUATION_STYLE_JA_JA); kkc_context_set_input_mode(kkc->context, KKC_INPUT_MODE_HIRAGANA); kkc->tempMsg = FcitxMessagesNew(); FcitxKkcApplyConfig(kkc); FcitxIMIFace iface; memset(&iface, 0, sizeof(FcitxIMIFace)); iface.Init = FcitxKkcInit; iface.DoInput = FcitxKkcDoInput; iface.DoReleaseInput = FcitxKkcDoReleaseInput; iface.GetCandWords = FcitxKkcGetCandWords; iface.Save = FcitxKkcSave; iface.ResetIM = FcitxKkcResetIM; iface.OnClose = FcitxKkcOnClose; FcitxInstanceRegisterIMv2(instance, kkc, "kkc", _("Kana Kanji"), "kkc", iface, 1, "ja"); #define INIT_MENU(VARNAME, NAME, I18NNAME, STATUS_NAME, STATUS_ARRAY, SIZE) \ do { \ FcitxUIRegisterComplexStatus(instance, kkc, \ STATUS_NAME, \ I18NNAME, \ I18NNAME, \ NULL, \ FcitxKkcGet##NAME##IconName \ ); \ FcitxMenuInit(&VARNAME); \ VARNAME.name = strdup(I18NNAME); \ VARNAME.candStatusBind = strdup(STATUS_NAME); \ VARNAME.UpdateMenu = FcitxKkcUpdate##NAME##Menu; \ VARNAME.MenuAction = FcitxKkc##NAME##MenuAction; \ VARNAME.priv = kkc; \ VARNAME.isSubMenu = false; \ int i; \ for (i = 0; i < SIZE; i ++) \ FcitxMenuAddMenuItem(&VARNAME, _(STATUS_ARRAY[i].label), MENUTYPE_SIMPLE, NULL); \ FcitxUIRegisterMenu(instance, &VARNAME); \ FcitxUISetStatusVisable(instance, STATUS_NAME, false); \ } while(0) INIT_MENU(kkc->inputModeMenu, InputMode, _("Input Mode"), "kkc-input-mode", input_mode_status, KKC_INPUT_MODE_DIRECT); kkc->handler = g_signal_connect(kkc->context, "notify::input-mode", G_CALLBACK(_kkc_input_mode_changed_cb), kkc); FcitxKkcUpdateInputMode(kkc); kkc_context_set_input_mode(kkc->context, kkc->config.initialInputMode); FcitxIMEventHook hk; hk.arg = kkc; hk.func = FcitxKkcResetHook; FcitxInstanceRegisterResetInputHook(instance, hk); FcitxKkcAddFunctions(instance); return kkc; }
void* CloudPinyinCreate(FcitxInstance* instance) { FcitxCloudPinyin* cloudpinyin = fcitx_utils_malloc0(sizeof(FcitxCloudPinyin)); bindtextdomain("fcitx-cloudpinyin", LOCALEDIR); cloudpinyin->owner = instance; int pipe1[2]; int pipe2[2]; if (!LoadCloudPinyinConfig(&cloudpinyin->config)) { free(cloudpinyin); return NULL; } if (pipe(pipe1) < 0) { free(cloudpinyin); return NULL; } if (pipe(pipe2) < 0) { close(pipe1[0]); close(pipe1[1]); free(cloudpinyin); return NULL; } cloudpinyin->pipeRecv = pipe1[0]; cloudpinyin->pipeNotify = pipe2[1]; fcntl(pipe1[0], F_SETFL, O_NONBLOCK); fcntl(pipe1[1], F_SETFL, O_NONBLOCK); fcntl(pipe2[0], F_SETFL, O_NONBLOCK); fcntl(pipe2[1], F_SETFL, O_NONBLOCK); cloudpinyin->pendingQueue = fcitx_utils_malloc0(sizeof(CurlQueue)); cloudpinyin->finishQueue = fcitx_utils_malloc0(sizeof(CurlQueue)); pthread_mutex_init(&cloudpinyin->pendingQueueLock, NULL); pthread_mutex_init(&cloudpinyin->finishQueueLock, NULL); FcitxFetchThread* fetch = fcitx_utils_malloc0(sizeof(FcitxFetchThread)); cloudpinyin->fetch = fetch; fetch->owner = cloudpinyin; fetch->pipeRecv = pipe2[0]; fetch->pipeNotify = pipe1[1]; fetch->pendingQueueLock = &cloudpinyin->pendingQueueLock; fetch->finishQueueLock = &cloudpinyin->finishQueueLock; fetch->queue = fcitx_utils_malloc0(sizeof(CurlQueue)); FcitxIMEventHook hook; hook.arg = cloudpinyin; hook.func = CloudPinyinAddCandidateWord; FcitxInstanceRegisterUpdateCandidateWordHook(instance, hook); hook.arg = cloudpinyin; hook.func = CloudPinyinHookForNewRequest; FcitxInstanceRegisterResetInputHook(instance, hook); FcitxInstanceRegisterInputFocusHook(instance, hook); FcitxInstanceRegisterInputUnFocusHook(instance, hook); FcitxInstanceRegisterTriggerOnHook(instance, hook); pthread_create(&cloudpinyin->pid, NULL, FetchThread, fetch); CloudPinyinRequestKey(cloudpinyin); return cloudpinyin; }
static void* FcitxRimeCreate(FcitxInstance* instance) { FcitxRime* rime = (FcitxRime*) fcitx_utils_malloc0(sizeof(FcitxRime)); rime->owner = instance; rime->api = rime_get_api(); rime->firstRun = true; if (!rime->api) { free(rime); return NULL; } FcitxRimeStart(rime, false); FcitxIMIFace iface; memset(&iface, 0, sizeof(FcitxIMIFace)); iface.Init = FcitxRimeInit; iface.ResetIM = FcitxRimeReset; iface.DoInput = FcitxRimeDoInput; iface.DoReleaseInput = FcitxRimeDoReleaseInput; iface.GetCandWords = FcitxRimeGetCandWords; iface.ReloadConfig = FcitxRimeReloadConfig; FcitxInstanceRegisterIMv2( instance, rime, "rime", _("Rime"), "rime", iface, 10, "zh" ); FcitxUIRegisterComplexStatus( instance, rime, "rime-enzh", "", "", FcitxRimeToggleEnZh, FcitxRimeGetIMIcon); FcitxUIRegisterComplexStatus( instance, rime, "rime-deploy", _("Deploy"), _("Deploy"), FcitxRimeToggleDeploy, FcitxRimeGetDeployIcon); FcitxUIRegisterComplexStatus( instance, rime, "rime-sync", _("Synchronize"), _("Synchronize"), FcitxRimeToggleSync, FcitxRimeGetSyncIcon); FcitxUISetStatusVisable(instance, "rime-enzh", false); FcitxUISetStatusVisable(instance, "rime-sync", false); FcitxUISetStatusVisable(instance, "rime-deploy", false); FcitxIMEventHook hk; hk.arg = rime; hk.func = FcitxRimeResetUI; FcitxInstanceRegisterResetInputHook(instance, hk); FcitxMenuInit(&rime->schemamenu); rime->schemamenu.name = strdup(_("Schema List")); rime->schemamenu.candStatusBind = strdup("rime-enzh"); rime->schemamenu.MenuAction = FcitxRimeSchemaMenuAction; rime->schemamenu.UpdateMenu = FcitxRimeSchemaMenuUpdate; rime->schemamenu.priv = rime; rime->schemamenu.isSubMenu = false; FcitxUIRegisterMenu(rime->owner, &rime->schemamenu); return rime; }
void* ClassicUICreate(FcitxInstance* instance) { FcitxAddon* classicuiaddon = FcitxAddonsGetAddonByName(FcitxInstanceGetAddons(instance), FCITX_CLASSIC_UI_NAME); FcitxModuleFunctionArg arg; FcitxClassicUI* classicui = fcitx_utils_malloc0(sizeof(FcitxClassicUI)); classicui->owner = instance; if (!LoadClassicUIConfig(classicui)) { free(classicui); return NULL; } if (GetSkinDesc() == NULL) { free(classicui); return NULL; } classicui->dpy = InvokeFunction(instance, FCITX_X11, GETDISPLAY, arg); if (classicui->dpy == NULL) { free(classicui); return NULL; } if (LoadSkinConfig(&classicui->skin, &classicui->skinType)) { free(classicui); return NULL; } classicui->isfallback = FcitxUIIsFallback(instance, classicuiaddon); classicui->iScreen = DefaultScreen(classicui->dpy); classicui->protocolAtom = XInternAtom(classicui->dpy, "WM_PROTOCOLS", False); classicui->killAtom = XInternAtom(classicui->dpy, "WM_DELETE_WINDOW", False); InitSkinMenu(classicui); FcitxUIRegisterMenu(instance, &classicui->skinMenu); /* Main Menu Initial */ FcitxMenuInit(&classicui->mainMenu); FcitxMenuAddMenuItem(&classicui->mainMenu, _("About Fcitx"), MENUTYPE_SIMPLE, NULL); FcitxMenuAddMenuItem(&classicui->mainMenu, _("Online Help"), MENUTYPE_SIMPLE, NULL); FcitxMenuAddMenuItem(&classicui->mainMenu, NULL, MENUTYPE_DIVLINE, NULL); FcitxUIMenu **menupp; UT_array* uimenus = FcitxInstanceGetUIMenus(instance); for (menupp = (FcitxUIMenu **) utarray_front(uimenus); menupp != NULL; menupp = (FcitxUIMenu **) utarray_next(uimenus, menupp) ) { FcitxUIMenu * menup = *menupp; if (!menup->isSubMenu) FcitxMenuAddMenuItem(&classicui->mainMenu, menup->name, MENUTYPE_SUBMENU, menup); } FcitxMenuAddMenuItem(&classicui->mainMenu, NULL, MENUTYPE_DIVLINE, NULL); FcitxMenuAddMenuItem(&classicui->mainMenu, _("Configure"), MENUTYPE_SIMPLE, NULL); FcitxMenuAddMenuItem(&classicui->mainMenu, _("Exit"), MENUTYPE_SIMPLE, NULL); classicui->mainMenu.MenuAction = MainMenuAction; classicui->mainMenu.priv = classicui; classicui->mainMenu.mark = -1; classicui->inputWindow = CreateInputWindow(classicui); classicui->mainWindow = CreateMainWindow(classicui); classicui->trayWindow = CreateTrayWindow(classicui); classicui->aboutWindow = CreateAboutWindow(classicui); classicui->messageWindow = CreateMessageWindow(classicui); classicui->mainMenuWindow = CreateMainMenuWindow(classicui); FcitxIMEventHook resethk; resethk.arg = classicui; resethk.func = ClassicUIInputReset; FcitxInstanceRegisterResetInputHook(instance, resethk); DisplaySkin(classicui, classicui->skinType); /* ensure order ! */ AddFunction(classicuiaddon, ClassicUILoadImage); AddFunction(classicuiaddon, ClassicUIGetKeyBoardFontColor); AddFunction(classicuiaddon, ClassicUIGetFont); return classicui; }
void* IMSelectorCreate(FcitxInstance* instance) { IMSelector* imselector = fcitx_utils_malloc0(sizeof(IMSelector)); imselector->owner = instance; if (!LoadIMSelectorConfig(imselector)) { free(imselector); return NULL; } FcitxKeyFilterHook hk; hk.arg = imselector; hk.func = IMSelectorPreFilter; FcitxInstanceRegisterPreInputFilter(instance, hk); hk.arg = &imselector->triggered; hk.func = FcitxDummyReleaseInputHook; FcitxInstanceRegisterPreReleaseInputFilter(instance, hk); FcitxHotkeyHook hkhk; hkhk.arg = imselector; hkhk.hotkeyhandle = IMSelectorLocalTrigger; hkhk.hotkey = imselector->localKey; FcitxInstanceRegisterHotkeyFilter(instance, hkhk); hkhk.arg = imselector; hkhk.hotkeyhandle = IMSelectorGlobalTrigger; hkhk.hotkey = imselector->globalKey; FcitxInstanceRegisterHotkeyFilter(instance, hkhk); hkhk.arg = imselector; hkhk.hotkeyhandle = IMSelectorClearLocal; hkhk.hotkey = imselector->clearLocalKey; FcitxInstanceRegisterHotkeyFilter(instance, hkhk); /* this key is ignore the very first input method which is for inactive */ #define _ADD_HANDLE(X, ISGLOBAL) \ do { \ SelectorHandle* handle = &imselector->handle[ISGLOBAL][X - 1]; \ handle->global = ISGLOBAL; \ handle->idx = X; \ handle->imselector = imselector; \ hkhk.arg = handle; \ hkhk.hotkeyhandle = IMSelectorSelect; \ hkhk.hotkey = imselector->selectorKey[ISGLOBAL][X - 1]; \ FcitxInstanceRegisterHotkeyFilter(instance, hkhk); \ } while(0); _ADD_HANDLE(1, false); _ADD_HANDLE(2, false); _ADD_HANDLE(3, false); _ADD_HANDLE(4, false); _ADD_HANDLE(5, false); _ADD_HANDLE(6, false); _ADD_HANDLE(7, false); _ADD_HANDLE(8, false); _ADD_HANDLE(9, false); _ADD_HANDLE(1, true); _ADD_HANDLE(2, true); _ADD_HANDLE(3, true); _ADD_HANDLE(4, true); _ADD_HANDLE(5, true); _ADD_HANDLE(6, true); _ADD_HANDLE(7, true); _ADD_HANDLE(8, true); _ADD_HANDLE(9, true); FcitxIMEventHook resethk; resethk.arg = imselector; resethk.func = IMSelectorReset; FcitxInstanceRegisterResetInputHook(instance, resethk); return imselector; }
void* ClassicUICreate(FcitxInstance* instance) { FcitxAddon* classicuiaddon = FcitxAddonsGetAddonByName(FcitxInstanceGetAddons(instance), FCITX_CLASSIC_UI_NAME); FcitxClassicUI* classicui = fcitx_utils_malloc0(sizeof(FcitxClassicUI)); classicui->owner = instance; if (!LoadClassicUIConfig(classicui)) { free(classicui); return NULL; } if (GetSkinDesc() == NULL) { free(classicui); return NULL; } classicui->dpy = FcitxX11GetDisplay(instance); if (classicui->dpy == NULL) { free(classicui); return NULL; } FcitxX11GetDPI(instance, &classicui->dpi, NULL); if (classicui->dpi <= 0) classicui->dpi = 96; if (LoadSkinConfig(&classicui->skin, &classicui->skinType)) { free(classicui); return NULL; } classicui->isfallback = FcitxUIIsFallback(instance, classicuiaddon); classicui->iScreen = DefaultScreen(classicui->dpy); classicui->protocolAtom = XInternAtom(classicui->dpy, "WM_PROTOCOLS", False); classicui->killAtom = XInternAtom(classicui->dpy, "WM_DELETE_WINDOW", False); InitSkinMenu(classicui); FcitxUIRegisterMenu(instance, &classicui->skinMenu); /* Main Menu Initial */ FcitxMenuInit(&classicui->mainMenu); classicui->mainMenu.UpdateMenu = UpdateMainMenu; classicui->mainMenu.MenuAction = MainMenuAction; classicui->mainMenu.priv = classicui; classicui->mainMenu.mark = -1; classicui->inputWindow = CreateInputWindow(classicui); classicui->mainWindow = CreateMainWindow(classicui); classicui->trayWindow = CreateTrayWindow(classicui); classicui->messageWindow = CreateMessageWindow(classicui); classicui->mainMenuWindow = CreateMainMenuWindow(classicui); FcitxIMEventHook resethk; resethk.arg = classicui; resethk.func = ClassicUIInputReset; FcitxInstanceRegisterResetInputHook(instance, resethk); DisplaySkin(classicui, classicui->skinType); /* ensure order ! */ FcitxModuleAddFunction(classicuiaddon, ClassicUILoadImage); FcitxModuleAddFunction(classicuiaddon, ClassicUIGetKeyBoardFontColor); FcitxModuleAddFunction(classicuiaddon, ClassicUIGetFont); return classicui; }