Re: unexpected error
Eric Le Lay <[email protected]> Wed, 8 Oct 2014 17:16:41 +0200
| Newsgroups | gmane.comp.python.pyobjc.devel |
|---|---|
| Message-ID | <[email protected]> |
Le Wed, 8 Oct 2014 08:56:29 -0500, Ken Thomases <[email protected]> a écrit : > On Oct 8, 2014, at 5:48 AM, Eric Le Lay > <[email protected]> wrote: > > > tap = Quartz.CGEventTapCreate( > > Quartz.kCGSessionEventTap, > > Quartz.kCGHeadInsertEventTap, > > Quartz.kCGEventTapOptionDefault, > > # NSSystemDefined for media keys > > Quartz.CGEventMaskBit(NSSystemDefined), > > self.eventTap, > > None > > ) > > port = > > NSMachPort.alloc().initWithMachPort_options_(CFMachPortGetPort(tap), > > NSMachPortDeallocateNone) loop = NSRunLoop.currentRunLoop() > > loop.addPort_forMode_(port, NSDefaultRunLoopMode) > > Why are you not doing what the docs for CGEventTapCreate() suggest: > pass the CFMachPortRef returned from it to > CFMachPortCreateRunLoopSource() and then add the resulting source to > the run loop using CFRunLoopAddSource()? > Ken, thank you for your answer. The actual code is part of a gtk application. It used to do as you suggest: tap = Quartz.CGEventTapCreate(...) runLoopSource = Quartz.CFMachPortCreateRunLoopSource(None, tap, 0) Quartz.CFRunLoopAddSource( Quartz.CFRunLoopGetCurrent(), runLoopSource, Quartz.kCFRunLoopDefaultMode ) Quartz.CGEventTapEnable(tap, True) The event was not processed until the main window got focus and then the eventtap was disabled because it had not answered in time. I stumbled upon the macrumors post about the same problem and tried that code. It seemed to make sense and did work in objective-c so I thought it would work just as well in python. Now, the objective-c has the same problem + can't close the main window or it freezes the computer. I can live with the event not being delivered until the main window shows up. I then re-enable the tap as I receive the disabled event. Thanks again for your time, Eric ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Pyobjc-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyobjc-dev