diff options
author | Gary Martin <gary@garycmartin.com> | 2010-10-13 14:29:17 (GMT) |
---|---|---|
committer | Gary Martin <gary@garycmartin.com> | 2010-10-13 14:29:17 (GMT) |
commit | 2e2acd9b55e23010c93021b9690aebec744cd88a (patch) | |
tree | ffca8e4d19ec7c96fb795cc41d109d897a620a38 | |
parent | 5c972a0dd761226e3e83c85f00eaded79570e5c2 (diff) |
Fixed special case where switching to a Sugar desktop view did not trigger a low cpu idle.
-rw-r--r-- | activity.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activity.py b/activity.py index 477303d..e9e847a 100644 --- a/activity.py +++ b/activity.py @@ -45,6 +45,7 @@ class PhysicsActivity(olpcgames.PyGameActivity): super(PhysicsActivity, self).__init__(handle) self.metadata['mime_type'] = 'application/x-physics-activity' self.connect('visibility-notify-event', self._focus_event) + self.connect('window-state-event', self._window_event) def get_preview(self): """Custom preview code to get image from pygame. @@ -183,3 +184,10 @@ class PhysicsActivity(olpcgames.PyGameActivity): else: pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, action="focus_in")) + + def _window_event(self, window, event): + """Send focus out event to pygame when switching to a desktop view. + """ + if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED: + pygame.event.post(olpcgames.eventwrap.Event(pygame.USEREVENT, + action="focus_out")) |