Enable click-through in X11


Issue: Clicking on an unfocused X11 window (if you have not enabled “focus follows mouse”), or clicking on an X11 window when X11 is in the background, will only focus the X11 window in the case of a left click. However, any additional action implied by a click (e.g., using a middle click to paste text selected in another X11 window – if focus follows mouse is not enabled – or selected and copied in a non-X11 window) will not be performed and the click will not activate the window.


Solution: Issue the following command in an xterm (X11) window and then restart X11:

defaults write com.apple.x11 wm_click_through -bool true

Starting with Leopard 10.5.5 (which upgraded X11 to 2.1.5), this is changed to:

defaults write org.x.X11 wm_click_through -bool true

This feature allows the action implied by the click to be passed through to the application. Repeat with true replaced by false to turn it off. The file modified by defaults in this case is ~/Library/Preferences/com.apple.x11.plist   ~/Library/Preferences/org.x.X11.plist.

Note that starting with Snow Leopard (and, with a little extra work, Leopard) this configuration can also be accomplished from the X11 application Preferences menu – see Copy and paste between X11 and OS X.

Note that focusing or activation of the X11 window will only happen if the click would normally have focused or activated the window. For example, a left-click (or equivalent) will normally activate an X11 xterm window, whereas a middle click (or equivalent) will not. However, with click-through enabled, a middle click on an unfocused or backgrounded (i.e., inactive) X11 xterm window will perform the expected action of pasting whatever is in the copy buffer into the xterm window, but will not activate it (i.e., will neither focus the xterm window nor bring X11 to the foreground).

The following odd behavior with click-through in X11 appears to be fixed as of Leopard 10.5.5 with X11 2.1.5

Some confusing click-through behavior found in Leopard 10.5.4 with (Apple standard) X11 2.1.1: A click-through event cannot constitute the very first command issued into an xterm window whose instantiation started X11. You must at least once manually click to activate the xterm window (or any other X11 window currently running) before click-through will subsequently be enabled. For example, if you type “xterm” in a Terminal window to start X11 and instantiate an xterm window, then immediately click back onto the Terminal window, highlight the text “xterm” using the left mouse button (or equivalent), then try to click-through paste it into the xterm window using the middle mouse button (or equivalent), then nothing will happen. However, if after starting X11 and the xterm window, you click on a non-X11 window (like a Terminal window) to put X11 in the background, then click on the xterm window to put X11 in the foreground, then again click to a non-X11 window (like a Terminal window) to put X11 in the background, then any subsequent click-through paste will transfer the contents of the copy buffer into the xterm window command line as expected.

OS Version Compatibility: Lion, Snow Leopard, Leopard, Tiger

Update Status: 25 February 2010