def _timer_proc(self, timer, data, in_events=True): allow_polling = True for window in windows: # Check for live resizing if window._resizing is not None: allow_polling = False old_width, old_height = window._resizing rect = types.Rect() carbon.GetWindowBounds(window._window, constants.kWindowContentRgn, ctypes.byref(rect)) width = rect.right - rect.left height = rect.bottom - rect.top if width != old_width or height != old_height: window._resizing = width, height window.switch_to() window.dispatch_event('on_resize', width, height) # Check for live dragging if window._dragging: allow_polling = False # Check for deferred recreate if window._recreate_deferred: if in_events: # Break out of ReceiveNextEvent so it can be processed # in next iteration. carbon.QuitEventLoop(self._event_loop) self._force_idle = True else: # Do it now. window._recreate_immediate() sleep_time = self.idle() if sleep_time is None: sleep_time = constants.kEventDurationForever elif sleep_time < 0.01 and allow_polling and self._allow_polling: # Switch event loop to polling. if in_events: carbon.QuitEventLoop(self._event_loop) self._force_idle = True sleep_time = constants.kEventDurationForever carbon.SetEventLoopTimerNextFireTime(timer, ctypes.c_double(sleep_time))
def _enter_blocking(self): carbon.SetEventLoopTimerNextFireTime(self._timer, ctypes.c_double(0.0)) self._allow_polling = False
def _stop_polling(self): carbon.SetEventLoopTimerNextFireTime(self._timer, ctypes.c_double(0.0))