Fixing a disappearing mouse pointer in OVITO on WSL2
Problem: On Windows with WSL2, launching the OVITO GUI from a WSL terminal opened the window fine, but the mouse pointer kept disappearing inside it.
Diagnosis
XDG_SESSION_TYPEwas empty whileDISPLAY=:0andWAYLAND_DISPLAY=wayland-0were set, which pointed to WSLg.uname -rconfirmed it (...microsoft-standard-WSL2).- WSL (2.6.3) and WSLg (1.0.71) were already up to date.
- The problem is in WSLg’s cursor handling (its RDP-based display layer), not in OVITO itself.
What didn’t help
QT_QPA_PLATFORM=xcb(OVITO’s bundled Qt already uses xcb; it has no Wayland plugin)- Setting a cursor theme (
XCURSOR_THEME=Adwaita XCURSOR_SIZE=24) - Forcing software OpenGL (
LIBGL_ALWAYS_SOFTWARE=1)
Fix: bypass WSLg with VcXsrv
- Install VcXsrv on Windows (
winget install marha.VcXsrv). - Start XLaunch with Multiple windows, Start no client, Disable access control checked, and Native opengl unchecked.
- Allow WSL to reach the X server. In NAT networking mode the WSL network counts as Public, so add a firewall rule restricted to the WSL subnet (admin Command Prompt):
(Check your mode withnetsh advfirewall firewall add rule name="VcXsrv WSL" dir=in action=allow program="C:\Program Files\VcXsrv\vcxsrv.exe" enable=yes profile=any remoteip=192.168.128.0/20wslinfo --networking-mode; inmirroredmode useDISPLAY=127.0.0.1:0instead.) - Add a shell function to
~/.bashrcso only OVITO uses VcXsrv and other apps stay on WSLg:ovito-x() { DISPLAY=$(ip route | awk '/default/ {print $3}'):0 WAYLAND_DISPLAY= LIBGL_ALWAYS_SOFTWARE=1 ovito "$@"; } - Start VcXsrv, then run
ovito-x. The pointer now behaves normally.
Prompts I used (with Claude)
- “mouse pointer not showing sometimes on ovito when using from terminal”
- “this shows blank” (output of
echo $XDG_SESSION_TYPE) - Output of
echo "DISPLAY=$DISPLAY WAYLAND=$WAYLAND_DISPLAY" - Error from
QT_QPA_PLATFORM=wayland ovito - “this does not show the cursor” / “not working” (xcb and cursor-theme attempts)
- Output of
uname -r - “lets stick to fixing the WSL”
- “is not showing the mouse pointer” (software OpenGL attempt)
- OVITO’s terminal output (portal and Vulkan warnings)
- Output of
wsl.exe --version - “its stuck without opening the ovito window” (first VcXsrv attempt)
- “its back but no mouse pointer” (after reverting
DISPLAY) - “nat” (output of
wslinfo --networking-mode) - Firewall rule error, then the
netshrule returningOk. - “works!!”