diff options
Diffstat (limited to 'window.py')
| -rw-r--r-- | window.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -27,6 +27,8 @@ class PixDisplay: self.tex = None self.text_next = None + self._force_redraw = False + @property def max_framerate(self): return self._max_fps @@ -76,9 +78,10 @@ class PixDisplay: # Draw static image except during a transition if self.image_time < self.image_duration: - # Avoid redraw unless window size has changed - if self.win_w != old_win_w or self.win_h != old_win_h: + # Avoid unforced-redraw unless window size has changed + if self._force_redraw or self.win_w != old_win_w or self.win_h != old_win_h: self.renderer.draw_static(self.tex, self.win_w, self.win_h, 1.0) + self._force_redraw = False return # Start drawing transition once image_time >= image_duration @@ -110,6 +113,11 @@ class PixDisplay: elif key == GLUT_KEY_RIGHT: self.skip(1) + def handle_visibility_change(self, state): + if state == GLUT_VISIBLE: + self._force_redraw = True + glutPostRedisplay() + # Initialization and main loop def main(self, glut_args): # Initialize the window @@ -137,6 +145,7 @@ class PixDisplay: # Run display glutDisplayFunc(self.display) glutTimerFunc(self.frame_time, self.timer, 0) + glutVisibilityFunc(self.handle_visibility_change) # Redraw in case framebuffer gets destroyed when window is obscured glutSpecialFunc(self.handle_special_key) glutMainLoop() |
