Skip to content

Commit 279e55f

Browse files
authored
Always request a draw on a resize & bump patch version (#188)
1 parent 4d14985 commit 279e55f

6 files changed

Lines changed: 12 additions & 8 deletions

File tree

rendercanvas/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# This is the base version number, to be bumped before each release.
2424
# The build system detects this definition when building a distribution.
25-
__version__ = "2.6.1"
25+
__version__ = "2.6.2"
2626

2727
# Set this to your library name
2828
project_name = "rendercanvas"

rendercanvas/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ def _set_visible(self, visible: bool):
640640
This is meant for the backend to automatically enable/disable
641641
the rendering when the canvas is e.g. minimized or otherwise invisible.
642642
If not visible, frames are not rendered, but events are still processed.
643+
644+
Setting the visibility implicitly requests a new draw.
643645
"""
644646
if self.__scheduler is not None:
645647
self.__scheduler.set_enabled(visible)

rendercanvas/core/scheduler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ async def __scheduler_task(self):
164164
if (canvas := self.get_canvas()) is None:
165165
break
166166

167+
# A resize should always draw.
168+
if not do_draw:
169+
do_draw = canvas._size_info["changed"]
170+
167171
if do_draw:
168172
# We do a draw and wait for the full draw to complete, including
169173
# the presentation (i.e. the 'consumption' of the frame), using

rendercanvas/glfw.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,9 @@ def _on_pixelratio_change(self, *args):
390390
self._determine_size()
391391
finally:
392392
self._changing_pixel_ratio = False
393-
self.request_draw()
394393

395394
def _on_size_change(self, *args):
396395
self._determine_size()
397-
self.request_draw()
398396
# During a resize, the glfw.poll_events() function blocks, so
399397
# our event-loop is on pause. However, glfw still sends resize
400398
# events, and we can use these to draw, to get a smoother

rendercanvas/jupyter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def handle_event(self, event):
115115
pwidth = int(logical_size[0] * pixel_ratio)
116116
pheight = int(logical_size[1] * pixel_ratio)
117117
self._size_info.set_physical_size(pwidth, pheight, pixel_ratio)
118-
self.request_draw()
119118
return
120119

121120
# Only submit events that rendercanvas knows. Otherwise, if new events are added

rendercanvas/stub.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ class StubRenderCanvas(BaseRenderCanvas):
6868
Backends must call ``self._final_canvas_init()`` at the end of its
6969
``__init__()``. This will set the canvas' logical size and title.
7070
71-
Backends must call ``self._size_info.set_physical_size(width, height, native_pixel_ratio)``,
72-
whenever the size or pixel ratio changes. It must be called when the actual
73-
viewport has changed, so typically not in ``_rc_set_logical_size()``, but
74-
e.g. when the underlying GUI layer fires a resize event.
71+
Backends must call ``self._size_info.set_physical_size(width, height,
72+
native_pixel_ratio)``, whenever the size or pixel ratio changes. It must be
73+
called when the actual viewport has changed, so typically not in
74+
``_rc_set_logical_size()``, but e.g. when the underlying GUI layer fires a
75+
resize event. Setting the size implicitly requests a new draw.
7576
7677
Backends must also call ``self.submit_event()``, if applicable, to produce
7778
events for mouse and keyboard. Backends must *not* submit a "resize" event;

0 commit comments

Comments
 (0)