diff options
| author | Tim Keller <tjkeller.xyz> | 2025-05-10 18:31:02 -0500 |
|---|---|---|
| committer | Tim Keller <tjkeller.xyz> | 2025-05-10 18:31:02 -0500 |
| commit | fc570fc38b450b90a2c8da05e5619f19ba8e983d (patch) | |
| tree | cc06d37d11fcf0e45b775ce8e1b02ac0fde04c2a | |
| parent | 9a785dfddad4215672c41396b8554477c18b4066 (diff) | |
| download | immich-frame-fc570fc38b450b90a2c8da05e5619f19ba8e983d.tar.xz immich-frame-fc570fc38b450b90a2c8da05e5619f19ba8e983d.zip | |
add force redraw flag and redraw whenever visibility is restored in case framebuffer is destroyed
| -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() |
