From dc7854d10b1cbf3780d15dbfa31c4a6423ab426c Mon Sep 17 00:00:00 2001 From: saphid <4596216+saphid@users.noreply.github.com> Date: Thu, 1 Oct 2026 20:52:41 +1000 Subject: [PATCH] Touch: a bare release no longer clears the stale-focus notice before the page has seen it The page leaves the panel off releases, so a release says nothing about focus. Found in review of the stale-latch fix. Co-Authored-By: Claude Sonnet 5.5 --- tests/test_touch.py | 8 ++++++++ ui/frame_touch.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_touch.py b/tests/test_touch.py index 2319589..213aa32 100644 --- a/tests/test_touch.py +++ b/tests/test_touch.py @@ -147,6 +147,14 @@ class Apply(unittest.TestCase): self.assertFalse(self.t.STALE[0]) self.assertEqual(self.said[-1][1].get("stale"), None) + def test_stale_survives_a_bare_release(self): + gs = FakeGamescope() + panel = self.t.apply(gs, {"button": "left", "down": True, "window": 99, "display": ":1"}, None) + self.assertTrue(self.t.STALE[0]) + self.t.apply(gs, {"button": "left", "down": False}, panel) # the page's release names no panel + self.assertTrue(self.t.STALE[0]) + self.assertEqual(self.said[-1][1].get("stale"), True) + def test_same_window_id_on_the_other_display_is_another_panel(self): gs = FakeGamescope() self.t.apply(gs, {"fx": 0.5, "fy": 0.5, "window": 7, "display": ":0"}, None) diff --git a/ui/frame_touch.py b/ui/frame_touch.py index 867f492..3d464b9 100644 --- a/ui/frame_touch.py +++ b/ui/frame_touch.py @@ -369,8 +369,10 @@ def apply(gs, event, panel): say("ready", focus=panel.get("window"), display=panel.get("display"), stale=True) # the page re-syncs STALE[0] = True return panel - if STALE[0] and not stale: + release = event.get("down") is False and ("button" in event or "key" in event) + if STALE[0] and not stale and not (release and "window" not in event): # Anything that goes through (a trackpad move names no panel) means caught up: stop re-syncing. + # A bare release doesn't: the page leaves the panel off releases, so it says nothing about focus. STALE[0] = False say("ready", focus=(panel or {}).get("window"), display=(panel or {}).get("display")) if "fx" in event and panel and panel.get("window"):