I have created a CGEventTap like this:
GetCurrentProcess(psn);
var mask = 1 << kCGEventLeftMouseDown | // CGEventMaskBit(kCGEventLeftMouseDown)
1 << kCGEventLeftMouseUp |
1 << kCGEventRightMouseDown |
1 << kCGEventRightMouseUp |
1 << kCGEventOtherMouseDown |
1 << kCGEventOtherMouseUp |
1 << kCGEventScrollWheel;
mouseEventTap = CGEventTapCreateForPSN(&psn, kCGHeadInsertEventTap, kCGEventTapOptionDefault, mask, null);
if (!mouseEventTap.isNull()) {
aRLS = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, mouseEventTap, 0);
CFRelease(mouseEventTap);
if (!aRLS.isNull()) {
aLoop = CFRunLoopGetCurrent();
CFRunLoopAddSource(aLoop, aRLS, kCFRunLoopCommonModes);
CFRelease(aRLS);
CFRelease(aLoop);
rez = CFRunLoopRunInMode(ostypes.CONST.kCFRunLoopCommonModes, 10, false); // figure out how to make this run indefinitely
// rez is 1 :(
}
}
My CFRunLoopRun
is exiting immediately, instead of running for 10seconds. And it says code is 1 which means no sources are in that mode. But I clearly did a CFRunLoopAddSource
to the common modes option kCFRunLoopRunFinished. The run loop mode mode has no sources or timers.
. Anyone know whats up? This is on not-main thread.