From e44837cee6e7b233cce8fc50595a6bca3e594aea Mon Sep 17 00:00:00 2001 From: DeeJanuz <45082401+DeeJanuz@users.noreply.github.com> Date: Sat, 3 Oct 2026 09:28:02 -0600 Subject: [PATCH] Gaze: the hidden panel waits for a command instead of waking every 50 ms The calibration panel runs for as long as the gaze service does, hidden nearly all the time, and it woke 20 to 30 times a second to look at its socket and SteamVR's events: about 0.9% of a core, the main cost left with gaze idle. It now waits in poll() on its command socket: up to a second while hidden, and up to 10 ms while shown, as before (it still drains SteamVR's events each pass, so a quit is acknowledged within a second while hidden). A command wakes it at once, so "show" draws sooner than before. With --watch-stdin, its stdin closing wakes it as well, so stopping it doesn't wait. Co-Authored-By: Claude Opus 5.5 --- gaze/panel/ft-gazepanel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gaze/panel/ft-gazepanel.cpp b/gaze/panel/ft-gazepanel.cpp index f9b32dd..cbe888b 100644 --- a/gaze/panel/ft-gazepanel.cpp +++ b/gaze/panel/ft-gazepanel.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -524,7 +525,11 @@ int main(int argc, char **argv) { if (!shown) ov->ShowOverlay(h), shown = true; dirty = false; } - std::this_thread::sleep_for(std::chrono::milliseconds(visible ? 10 : 50)); + // Until a command comes, or 10 ms while shown (SteamVR's events). Hidden, it waits up to a + // second: it woke 20 to 30 times a second for nothing, the main cost left with gaze idle. + // A closed stdin (--watch-stdin) wakes it too, so quitting doesn't wait. + pollfd fds[2] = {{sock, POLLIN, 0}, {0, POLLIN, 0}}; + poll(fds, watchStdin ? 2 : 1, visible ? 10 : 1000); } ov->DestroyOverlay(h); buffers.Drop();