summaryrefslogtreecommitdiff
path: root/window.py
diff options
context:
space:
mode:
authorTim Keller <tjkeller.xyz>2025-05-10 18:31:02 -0500
committerTim Keller <tjkeller.xyz>2025-05-10 18:31:02 -0500
commitfc570fc38b450b90a2c8da05e5619f19ba8e983d (patch)
treecc06d37d11fcf0e45b775ce8e1b02ac0fde04c2a /window.py
parent9a785dfddad4215672c41396b8554477c18b4066 (diff)
downloadimmich-frame-fc570fc38b450b90a2c8da05e5619f19ba8e983d.tar.xz
immich-frame-fc570fc38b450b90a2c8da05e5619f19ba8e983d.zip
add force redraw flag and redraw whenever visibility is restored in case framebuffer is destroyed
Diffstat (limited to 'window.py')
-rw-r--r--window.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/window.py b/window.py
index 8b34989..8e04225 100644
--- a/window.py
+++ b/window.py
@@ -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()