Skip to content

Commit 23f1bd7

Browse files
authored
Merge pull request #5158 from Textualize/faster-screens
Remove `-screen-suspended` class
2 parents 3d65f2b + ea22e83 commit 23f1bd7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/textual/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ class MyApp(App[None]):
487487
INLINE_PADDING: ClassVar[int] = 1
488488
"""Number of blank lines above an inline app."""
489489

490+
SUSPENDED_SCREEN_CLASS: ClassVar[str] = ""
491+
"""Class to apply to suspended screens, or empty string for no class."""
492+
490493
_PSEUDO_CLASSES: ClassVar[dict[str, Callable[[App], bool]]] = {
491494
"focus": lambda app: app.app_focus,
492495
"blur": lambda app: not app.app_focus,

src/textual/screen.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,8 @@ def _screen_resized(self, size: Size):
12101210

12111211
def _on_screen_resume(self) -> None:
12121212
"""Screen has resumed."""
1213-
self.remove_class("-screen-suspended")
1213+
if self.app.SUSPENDED_SCREEN_CLASS:
1214+
self.remove_class(self.app.SUSPENDED_SCREEN_CLASS)
12141215
self.stack_updates += 1
12151216
self.app._refresh_notifications()
12161217
size = self.app.size
@@ -1230,7 +1231,8 @@ def _on_screen_resume(self) -> None:
12301231

12311232
def _on_screen_suspend(self) -> None:
12321233
"""Screen has suspended."""
1233-
self.add_class("-screen-suspended")
1234+
if self.app.SUSPENDED_SCREEN_CLASS:
1235+
self.add_class(self.app.SUSPENDED_SCREEN_CLASS)
12341236
self.app._set_mouse_over(None)
12351237
self._clear_tooltip()
12361238
self.stack_updates += 1

tests/snapshot_tests/test_snapshots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,6 +1960,7 @@ def test_ansi_command_palette(snap_compare):
19601960
"""Test command palette on top of ANSI colors."""
19611961

19621962
class CommandPaletteApp(App[None]):
1963+
SUSPENDED_SCREEN_CLASS = "-screen-suspended"
19631964
CSS = """
19641965
Label {
19651966
width: 1fr;

0 commit comments

Comments
 (0)