Introduction
If you've recently upgraded to the latest WSL2 setup for Ubuntu 24.04 and encountered a frustratingly huge mouse cursor while using graphical Linux applications, you're not alone. This has been reported by multiple users, and in many cases, the mouse cursor stalls or freezes up to four times. In this article, we'll explain the root cause of this issue and guide you through the steps to fix it.
Understanding the Problem
When using graphical Linux applications in WSL2, a portion of the rendering process occurs on the Windows host, while the rest runs within the WSL2 environment. Due to a mismatch in DPI (dots per inch) handling, the Windows host isn't correctly scaling the Linux mouse cursor. If your Windows system is set at a high DPI (like a 4K display), the resulting mouse cursor appears gigantic.
Why Does the Mouse Cursor Stall or Freeze?
The mouse cursor may stall or freeze during rendering as the host and WSL2 environment exchange information regarding cursor visibility. This issue can reduce productivity and overall user experience.
Solving the Problem
Although there isn't yet an official fix (as of April 2024) from Microsoft or the WSL2 team, there's a workaround that leverages the WSL2 X server and the Windows X mouse cursor. This solution offers the correct size, appearance, and performance for your Linux mouse cursor.
Step-by-Step Instructions
To begin, ensure you've installed a functioning X server within your WSL2 environment.
sudo apt install xorg openbox
Now, install the Windows X mouse cursor package inside your Linux environment. We'll use the VCXsrv X server as our Windows host for this tutorial.
sudo apt install xmouse
Next, you'll need to launch the X server on your Windows host using VCXsrv.
vcxsrv - Multi-platform X server
Upon launching VCXsrv, there's an additional step to ensure the correct mouse cursor is used in WSL2 Ubuntu. In the VCXsrv options, choose the "Extra Settings" tab.
[X0] Font Directory: [fixed]
[X0] UseCoreFonts: [no]
[X0] MitShm: [yes]
[X0] NativeOpenGL: [yes]
[X0] ExtensionShadow: [yes]
[X0] RemoteDesktopSize: [8192x8192]
[X1] Font Directory: [fixed]
[X1] UseCoreFonts: [no]
[X1] MitShm: [yes]
[X1] NativeOpenGL: [yes]
[X1] ExtensionShadow: [yes]
[X1] RemoteDesktopSize: [8192x8192]
[Virtual desktop] WSLg: [yes]
[Virtual desktop] Multimon: [yes]
[Virtual desktop] DisableAC: [0]
[Virtual desktop] redir_pipe: [\\.\pipe\wslg]
[Virtual desktop] Stdio: [FDs:4,5]
[Virtual desktop] Audio: [FDs:6,7]
[Virtual desktop] Video: [FDs:8,9]
[Virtual desktop] RedirectIO: [yes]
[Virtual desktop] RedirectClipboard: [yes]
[Virtual desktop] ServerLayout X0 - core
[Virtual desktop] auth_info AuthorizedClients
Now, scroll down until you see "Virtual desktop" and make the following modifications.
[Virtual desktop] WSLg: [yes]
[Virtual desktop] Multimon: [yes]
[Virtual desktop] DisableAC: [1]
[Virtual desktop] redir_pipe: [\\.\pipe\wslg]
[Virtual desktop] Stdio: [FDs:4,5]
[Virtual desktop] Audio: [FDs:6,7]
[Virtual desktop] Video: [FDs:8,9]
[Virtual desktop] RedirectIO: [yes]
[Virtual desktop] RedirectClipboard: [yes]
[Virtual desktop] ServerLayout X0 - core
[Virtual desktop] auth_info AuthorizedClients
Finally, save your altered settings and restart the VCXsrv X server for the changes to take effect.
Fixing the colossal mouse cursor issue in WSL2 Ubuntu 24.04 requires using the WSL2 X server and the Windows X mouse cursor. By modifying the VCXsrv settings and enabling the WSLg desktop in VCXsrv, you can maintain a standard-sized and efficient Linux mouse cursor in your graphical applications.