问题描述
在WSL中打开一些GUI应用其显示窗口可能会超出屏幕, 比如IDEA 中的 setting
解决办法
可以通过 sudo apt install xdotool
安装 xdotool 解决
安装后再打开一个 shell, 输入 xdotool selectwindow windowmove 50 50
此时鼠标变成一个小圆点,通过点击选择超出屏幕的窗口, 就可以让窗口回到屏幕内
如果希望不用每次都点击,还可以在 ~/.bashrc
中加入一个函数
function resetwindow {
for pid in $(xdotool search -name --onlyvisible --maxdepth 2 .); do
read -r x y < <(xwininfo -id "$pid" | grep Absolute | awk '{print $4}' | xargs)
if [[ "$x" -lt 1 ]] || [[ "$y" -lt 1 ]]; then
xdotool windowmove "$pid" 150 150
fi
done
}
之后每次遇到显示不全, 只需要在 shell 中输入 resetwindow
就可以让全部窗口显示变得正常