Odd problem with event taps when job is killed
Odd problem with event taps when job is killed
- Subject: Odd problem with event taps when job is killed
- From: George Nachman <email@hidden>
- Date: Mon, 22 Nov 2010 14:14:01 -0800
Hi cocoa-dev,
I recently added an event tap to my program. Since doing that, there is a
strange behavior: when I kill my job (usually by making a change in Xcode
and pressing cmd-Enter, being prompted to kill the job, and selecting OK),
it will repeat back the last 10-20 keypresses as or after it dies. For
example, if I do this:
1. Start my program
2. Switch back to Xcode and type "foo" in some source file.
3. Cmd-enter in Xcode
4. A dialog asks if I want to kill the job, say yes.
5. A ghost types "foo" in whatever window the cursor happens to be in.
This is on 10.6.4 and Xcode 3.2.3. I register the event tap like this:
machPortRef = CGEventTapCreate(kCGHIDEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionListenOnly,
CGEventMaskBit(kCGEventKeyDown),
(CGEventTapCallBack)OnTappedEvent,
self);
if (machPortRef) {
CFRunLoopSourceRef eventSrc;
eventSrc = CFMachPortCreateRunLoopSource(NULL, machPortRef, 0);
if (eventSrc == NULL) {
DebugLog(@"CFMachPortCreateRunLoopSource failed.");
} else {
// Get the CFRunLoop primitive for the Carbon Main Event
Loop, and add the new event souce
CFRunLoopAddSource(CFRunLoopGetCurrent(), eventSrc,
kCFRunLoopDefaultMode);
CFRelease(eventSrc);
}
}
Even if my handler does nothing, it still exhibits this behavior:
static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type,
CGEventRef event, void *refcon)
{
return event;
}
I couldn't find reports of anyone else having this problem, which usually
means I did something wrong :). Any ideas on what could cause this?
Thanks,
George
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden