BUG解决之路-1 Linux下fcitx输入法候选框在IDEA等JetBrains系列IDE中不跟随光标(JetBrains Runtime版本:11.0.7)

施旭东
2023-12-01

中文输入法不跟随光标

BUG解决之路-1 Linux下fcitx输入法候选框在IDEA等JetBrains系列IDE中不跟随光标(JetBrains Runtime版本:11.0.7)

解决方案

手动编译JetBrainsRuntime + OpenJFX,修复该bug,以及正常预览Markdown文件(依赖JavaFX)

环境配置

系统:Ubuntu 18.04 LTS

内存:4GB物理内存 + 4GB虚拟内存(swap)

Java版本:OpenJDK 11.0.8

gcc版本:gcc 7.5.0

解决步骤

编译OpenJFX

1、安装依赖

sudo apt install ksh bison flex gperf build-essential libasound2-dev libgl1-mesa-dev \
    libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libjpeg-dev \
    libpng-dev libx11-dev libxml2-dev libxslt1-dev libxt-dev \
    libxxf86vm-dev pkg-config x11proto-core-dev \
    x11proto-xf86vidmode-dev libavcodec-dev mercurial \
    libgtk2.0-dev libgtk-3-dev \
    libxtst-dev libudev-dev libavformat-dev ant

sudo apt install cmake ruby

2、安装OpenJDK11,配置环境变量(编译需要)

sudo apt install openjdk-11-jdk

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JDK_HOME=$JAVA_HOME

3、获取OpenJFX源码

sudo apt install mercurial
hg clone http://hg.openjdk.java.net/openjfx/11-dev/rt

4、编译

cd rt
chmod a+x gradlew
./gradlew -PCOMPILE_WEBKIT=true #注意一定要编译Webkit,不然Markdown一样无法预览

5、已知问题解决方案
1)virtual memory exhausted: Cannot allocate memory
内存不够,分配虚拟内存后重新编译

mkdir /usr/img
dd if=/dev/zero of=/usr/img/swap bs=1024 count=4096000
mkswap /usr/img/swap
swapon /usr/img/swap

./gradlew -PCOMPILE_WEBKIT=true #重新编译

编译JetBrainsRuntime

1、获取JetBrainsRuntime源码

git clone https://github.com/JetBrains/JetBrainsRuntime.git

2、下载并应用patch

cd JetBrainsRuntime
git checkout cfc3e87f2ac27a0b8c78c729c113aa52535feff6
wget https://raw.githubusercontent.com/prehonor/myJetBrainsRuntime/master/idea.patch
git apply idea.patch

3、安装依赖

sudo apt install autoconf make build-essential libx11-dev \ 
libxext-dev libxrender-dev libxtst-dev libxt-dev \
libxrandr-dev libcups2-dev libfontconfig1-dev \
libasound2-dev 

4、编译并整合OpenJFX

sh ./configure --disable-warnings-as-errors \
--with-import-modules=_path_to_jfx-dev_/rt/build/modular-sdk 
#_path_to_jfx-dev_是第一步获取的OpenJFX源码即rt文件夹的绝对路径, 下面path_to_JetBrainsRuntime同理
make images

安装JetBrainsRuntime

1、重命名jdk为jbr

cd path_to_JetBrainsRuntime/JetBrainsRuntime/build/linux-x86_64-normal-server-release/images
mv jdk jbr

2、IDE安装Choose Runtime插件

3、安装编译得到的JBR
IDE里按 CTRL+SHIFT+A,输入choose runtime,选择jbr的路径,点击install,IDE自动重启,安装完毕

解决效果

已在Intellij IDEA 2020.1,WebStorm 2020.2以及PyCharm 2020.2上自测通过

 类似资料: