Fixing Black/Reversed X11 Windows on Mouse Movement on M1/M2 Macs

For some strange reason, with the new ARM based Macs with X11 xquartz from either the official download, or from Mac Ports, when a remote java (of course it’s a problem with java), when the mouse moves, the colors of the window(s) will invert, making them very difficult to see/read. Fortunately, there are a couple of simple solutions.

One option is to disable render extensions on the Mac’s X11 server with the terminal command (not using sudo). This may have implications with other X11 apps; I am not sure:

defaults write org.xquartz.X11 enable_render_extension 0  

If that does not work, or you prefer to only change the option for the broken java, you can set the option on the execution of the java command on the client side. I have read that for some Gnome applications, you need both the defaults command on the X11 server, and the _JAVA_OPTIONS option on the client. On the host where you are executing the X11 application (most likely over ssh), add the following to your shell’s profile (this assume bourne shell syntax; i.e. sh, bash, zsh):

export _JAVA_OPTIONS='-Dsun.java2d.xrender=false'

If you are rendering over a slow connection, adding a second option has been reported to help, but may slow things down on a fast connection. You will have to experiment to see what works best for your application:

export _JAVA_OPTIONS='-Dsun.java2d.xrender=false -Dsun.java2d.pmoffscreen=false'

The first option gets rid of the reversing, and the second should improve performance. Once again, the problem is java. It’s always java.

Leave a Comment