X11 periodically losing focus

ssh: wrong culprit

I have this loss of focus on a variable frequency on XQuartz without any ssh command.

On the other hand I found a heavy relationship between this XQuartz loss of focus and the launch of:

Google Software Update (com.google.Keystone.Agent)

Analysis of this bug

2 tools help during this investigation:

  1. watch activations Python script →

    [...]
    2014-07-22 17:06:04.622 Python[95279:1307] activated Google Software Update (com.google.Keystone.Agent)
    2014-07-22 17:06:08.410 Python[95279:1307] activated loginwindow (com.apple.loginwindow)
    [...]
    
  2. lastcomm | head -10 immediatly after the event →

    [...]
    diskmanage -S      root     __         0.00 secs Tue Jul 22 17:06 (0:00:18.03)
    GoogleSoft -S      root     __         0.11 secs Tue Jul 22 17:06 (0:00:30.03)
    [...]
    

I found this link: http://xquartz.macosforge.org/trac/ticket/133, which suggests that ARDAgent is the offending app, and that unchecking System Preferences -> Sharing -> Remote Management solves the problem.

I didn't have Remote Management switched on, but I did have File Sharing and Remote Login ticked. Switching off both (finally!) solved the problem of losing focus.

I haven't tested which of the two was causing the trouble.