def do_pause(self): # should go to app pause mode. from kivy.app import App app = App.get_running_app() if not app: Logger.info('WindowSDL: No running App found, exit.') stopTouchApp() return if not app.dispatch('on_pause'): Logger.info('WindowSDL: App doesn\'t support pause mode, stop.') stopTouchApp() return # XXX FIXME wait for sdl resume while True: event = sdl.poll() if event is False: continue if event is None: continue action, args = event[0], event[1:] if action == 'quit': EventLoop.quit = True self.close() break elif action == 'windowrestored': break app.dispatch('on_resume')
def do_pause(self): # should go to app pause mode. from kivy.app import App from kivy.base import stopTouchApp app = App.get_running_app() if not app: Logger.info("WindowSDL: No running App found, exit.") stopTouchApp() return if not app.dispatch("on_pause"): Logger.info("WindowSDL: App doesn't support pause mode, stop.") stopTouchApp() return # XXX FIXME wait for sdl resume while True: event = sdl.poll() if event is False: continue if event is None: continue # print 'sdl received', event action, args = event[0], event[1:] if action == "quit": EventLoop.quit = True self.close() break elif action == "windowrestored": # print 'app goes live again!' break # print 'dispatch app on_resume' app.dispatch("on_resume")
def _mainloop(self): EventLoop.idle() while True: event = sdl.poll() if event is False: break if event is None: continue action, args = event[0], event[1:] if action == 'quit': EventLoop.quit = True self.close() break elif action in ('fingermotion', 'fingerdown', 'fingerup'): # for finger, pass the raw event to SDL motion event provider SDLMotionEventProvider.q.appendleft(event) if action == 'mousemotion': x, y = args self.dispatch('on_mouse_move', x, y, self.modifiers) elif action in ('mousebuttondown', 'mousebuttonup'): x, y, button = args btn = 'left' if button == 3: btn = 'right' elif button == 2: btn = 'middle' eventname = 'on_mouse_down' if action == 'mousebuttonup': eventname = 'on_mouse_up' self.dispatch(eventname, x, y, btn, self.modifiers) # video resize elif action == 'windowresized': self._size = args # don't use trigger here, we want to delay the resize event cb = self._do_resize Clock.unschedule(cb) Clock.schedule_once(cb, .1) elif action == 'windowresized': self.canvas.ask_update() elif action == 'windowminimized': self.do_pause() elif action == 'windowrestored': pass elif action in ('keydown', 'keyup'): mod, key, scancode, str = args # XXX ios keyboard suck, when backspace is hit, the delete # keycode is sent. fix it. if key == 127: key = 8 self._pygame_update_modifiers(mod) if action == 'keyup': self.dispatch('on_key_up', key, scancode) continue # don't dispatch more key if down event is accepted if self.dispatch('on_key_down', key, scancode, str, self.modifiers): continue self.dispatch('on_keyboard', key, scancode, str, self.modifiers) elif action == 'textinput': key = args[0][0] # XXX on IOS, keydown/up don't send unicode anymore. # With latest sdl, the text is sent over textinput # Right now, redo keydown/up, but we need to seperate both call # too. (and adapt on_key_* API.) self.dispatch('on_key_down', key, None, args[0], self.modifiers) self.dispatch('on_keyboard', None, None, args[0], self.modifiers) self.dispatch('on_key_up', key, None, args[0], self.modifiers)
def _mainloop(self): EventLoop.idle() while True: event = sdl.poll() if event is False: break if event is None: continue #print 'sdl received', event action, args = event[0], event[1:] if action == 'quit': EventLoop.quit = True self.close() break elif action in ('fingermotion', 'fingerdown', 'fingerup'): # for finger, pass the raw event to SDL motion event provider SDLMotionEventProvider.q.appendleft(event) if action == 'mousemotion': x, y = args self.dispatch('on_mouse_move', x, y, self.modifiers) elif action in ('mousebuttondown', 'mousebuttonup'): x, y, button = args btn = 'left' if button == 3: btn = 'right' elif button == 2: btn = 'middle' eventname = 'on_mouse_down' if action == 'mousebuttonup': eventname = 'on_mouse_up' self.dispatch(eventname, x, y, btn, self.modifiers) # video resize elif action == 'windowresized': self._size = args # don't use trigger here, we want to delay the resize event cb = self._do_resize Clock.unschedule(cb) Clock.schedule_once(cb, .1) elif action == 'windowresized': self.canvas.ask_update() elif action == 'windowminimized': self.do_pause() elif action == 'windowrestored': pass elif action in ('keydown', 'keyup'): mod, key, scancode, unicode = args # XXX ios keyboard suck, when backspace is hit, the delete # keycode is sent. fix it. if key == 127: key = 8 self._pygame_update_modifiers(mod) if action == 'keyup': self.dispatch('on_key_up', key, scancode) continue # don't dispatch more key if down event is accepted if self.dispatch('on_key_down', key, scancode, unicode, self.modifiers): continue self.dispatch('on_keyboard', key, scancode, unicode, self.modifiers) elif action == 'textinput': key = args[0][0] # XXX on IOS, keydown/up don't send unicode anymore. # With latest sdl, the text is sent over textinput # Right now, redo keydown/up, but we need to seperate both call # too. (and adapt on_key_* API.) self.dispatch('on_key_down', key, None, args[0], self.modifiers) self.dispatch('on_keyboard', None, None, args[0], self.modifiers) self.dispatch('on_key_up', key, None, args[0], self.modifiers)