Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ def __init__(
)
"""The signal that is published when the screen's layout is refreshed."""

self._bindings_updated = False
"""Indicates that a binding update was requested."""
self.bindings_updated_signal: Signal[Screen] = Signal(self, "bindings_updated")
"""A signal published when the bindings have been updated"""

Expand Down Expand Up @@ -315,8 +313,7 @@ def _watch_stack_updates(self):

def refresh_bindings(self) -> None:
"""Call to request a refresh of bindings."""
self._bindings_updated = True
self.check_idle()
self.bindings_updated_signal.publish(self)

def _watch_maximized(
self, previously_maximized: Widget | None, maximized: Widget | None
Expand Down Expand Up @@ -941,31 +938,22 @@ def _on_mount(self, event: events.Mount) -> None:
self, self._maybe_clear_tooltip, immediate=True
)
self.refresh_bindings()
# Send this signal so we don't get an initial frame with no bindings in the footer
self.bindings_updated_signal.publish(self)

async def _on_idle(self, event: events.Idle) -> None:
# Check for any widgets marked as 'dirty' (needs a repaint)
event.prevent_default()
if not self.app._batch_count and self.is_current:
if (
self._layout_required
or self._scroll_required
or self._repaint_required
or self._recompose_required
or self._dirty_widgets
):
self._update_timer.resume()
return

try:
if not self.app._batch_count and self.is_current:
if (
self._layout_required
or self._scroll_required
or self._repaint_required
or self._recompose_required
or self._dirty_widgets
):
self._update_timer.resume()
return

await self._invoke_and_clear_callbacks()
finally:
if self._bindings_updated:
self._bindings_updated = False
if self.is_attached and not self.app._exit:
self.app.call_later(self.bindings_updated_signal.publish, self)
await self._invoke_and_clear_callbacks()

def _compositor_refresh(self) -> None:
"""Perform a compositor refresh."""
Expand Down
4 changes: 3 additions & 1 deletion src/textual/widgets/_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ async def bindings_changed(self, screen: Screen) -> None:

def on_mount(self) -> None:
self.call_next(self.bindings_changed, self.screen)
self.screen.bindings_updated_signal.subscribe(self, self.bindings_changed)
self.screen.bindings_updated_signal.subscribe(
self, self.bindings_changed, immediate=True
)

def on_unmount(self) -> None:
self.screen.bindings_updated_signal.unsubscribe(self)
Expand Down
Loading