如何在Linux上运行的fltk程序中启用fcitx输入法?

时间:2018-11-24 10:24:20

标签: fltk fcitx

我试图在Linux上运行的fltk程序中输入一些中文字符,但失败了。我使用的是fcitx,特别是fcitx-googlepinyin作为中文输入法。

以下代码将产生一个包含单个输入框的窗口。

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>

int main(int argc, char **argv) {
    Fl::scheme("GTK+");

    Fl::background(35, 35, 35);
    Fl::background2(90, 90, 90);
    Fl::foreground(240, 240, 240);

    Fl_Window *window = new Fl_Window(640, 480);

    Fl_Input *input = new Fl_Input(20, 20, 200, 20);

    window->end();
    window->show(argc, argv);

    return Fl::run();
}

单击输入框时,无法通过在fltk程序中按ctrl + space来切换到中文输入法。但是在Firefox或Atom等其他GUI程序中,中文输入法效果很好。

我将一些变量设置如下:

export XIM="fcitx"
export XIM_PROGRAM="fcitx"
export XMODIFIERS="@im=fcitx"
export GTK_IM_MODULE="fcitx"
export QT_IM_MODULE="fcitx"

如何在fltk程序中启用fcitx输入法?

1 个答案:

答案 0 :(得分:0)

研究X输入法后,我发现这是fltk> = 1.3.4中的一个错误(fltk-1.3.3具有正确的实现)。

src/Fl_x.cxx的第673行上,正确的代码应为XSetLocaleModifiers("");而不是XSetLocaleModifiers("@im=");。 1329行也有同样的问题。

只需更正这两行代码并重新编译库,输入法即可再次正常工作。

我还在fltk网站上发布了bug report,请查看其更多信息。