I'm developing a Cocoa application that shows a list of opened windows and highlights the current focused one. My problem is that I can't find a system notification to inform my app that the main (aka "focused" or "foreground") window has changed. I tried with:
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(wsNotificationHook:) name:NSWorkspaceDidActivateApplicationNotification object:nil];
but it monitors APPLICATION change: it isn't get fired when a change of window is executed INSIDE the same application (for example, if I pass between two Firefox windows using exposè). Is there a system-wide event that I can monitor to track a change of the main window?
Thank you in advance!
The closest you'll get will probably be the accessibility APIs. See here and here for similar questions with (partial) solutions.