I'm trying to add an observer to the active window (could be any program, not just mine) so that it tells me if it's moving. Here's how I added the observer to the run loop:
AXObserverAddNotification(m_observer, (AXUIElementRef)activeWindow, kAXMovedNotification, (__bridge void*)self);
CFRunLoopAddSource( [[NSRunLoop currentRunLoop] getCFRunLoop], AXObserverGetRunLoopSource(m_observer),kCFRunLoopDefaultMode );
The callback that is associated to the observer currently just prints something to the output window. What I observe is that nothing is output when I'm dragging around the active window (again, this could be any app's window) but as soon as I stop, multiples of the printf results are output. Seems like the calls to the callback are queued until there's some idle time for it to execute all at once.
Is there a way to get the callback executed without waiting for idle time? Maybe a CFRunLoopMode that would do that?