def stop(self): """Call once from the main thread to stop the thread. After this returns no callback will be called anymore. """ # wait until we fail or the observer tells us that the loop has started self._event.wait() # failed to create a tap, nothing to stop if self._tap is None: return # remove the runloop source Quartz.CFRunLoopRemoveSource( self._loop, self._runLoopSource, Quartz.kCFRunLoopDefaultMode ) self._runLoopSource = None # remove observer Quartz.CFRunLoopRemoveObserver( self._loop, self._observ, Quartz.kCFRunLoopCommonModes) self._observ = None # stop the loop Quartz.CFRunLoopStop(self._loop) self._loop = None # Disable the tap Quartz.CGEventTapEnable(self._tap, False) self._tap = None
def _close(self): try: Qz.CGEventTapEnable(self._tap, False) except Exception: pass try: if Qz.CFRunLoopContainsSource(self._device_loop,self._loop_source,self._loop_mode) is True: Qz.CFRunLoopRemoveSource(self._device_loop,self._loop_source,self._loop_mode) finally: self._loop_source=None self._tap=None self._device_loop=None self._loop_mode=None ioHubKeyboardDevice._close(self)
def _close(self): try: self._nativeSetSystemCursorVisibility(True) except Exception: pass try: Qz.CGEventTapEnable(self._tap, False) except Exception: pass try: if Qz.CFRunLoopContainsSource(self._device_loop,self._loop_source,self._loop_mode) is True: Qz.CFRunLoopRemoveSource(self._device_loop,self._loop_source,self._loop_mode) finally: self._loop_source=None self._tap=None self._device_loop=None self._loop_mode=None MouseDevice._close(self)