XQuartz windows sometimes lose focus while in use. Behavior is intermittent, but a Python script (see below) used to watch activations seems to show focus loss coincides with activity by AirPlayUIAgent:
2016-09-21 16:19:23.998 Python[809:36557] activated AirPlayUIAgent (com.apple.AirPlayUIAgent)
We apparently have several Apple TVs in our department, and when one is in use it leads to these activations. I do not connect with these Apple TVs myself, and do not seem to have them enabled in my displays prefs, but these AirPlayUIAgent activations happen anyway.
Steps to reproduce: Open Terminal, connect via SSH to our Linux computer, start up Emacs, begin editing. Keep working until AirPlayUIAgent activation occurs.
Actual results: Emacs window loses focus. No other window comes to foreground or gains focus.
Expected results: Emacs window continues to have focus.
OS version: Mac OS X 10.11.6
Below is the Python script used to discover the connection with AirPlayUIAgent:
def signal_handler(signal, frame):
from AppKit import *
def appActivated_(self, notification):
app = notification.userInfo()["NSWorkspaceApplicationKey"]
NSLog(u"activated %@ (%@)", app.localizedName(), app.bundleIdentifier())
ws = NSWorkspace.sharedWorkspace()
nc = ws.notificationCenter()
ob = MyObserver.new()
nc.addObserver_selector_name_object_(ob, "appActivated:", NSWorkspaceDidActivateApplicationNotification, ws)
Please file a bug report at http://bugreport.apple.com about the loss of focus. It will be duped to a radar that has existed for a while, but more noise and "me too"s are useful.