Source code for spacr.qt.widgets.popup_state
"""Whether a menu or a tooltip is currently on screen.
WHY THIS EXISTS. Opening the spaCR menu cost a burst of ~105 widget
repaints over the live GL backdrop -- 68 QLabel, 25 QWidget, 12 AppTile
-- and a tooltip did the same. That burst is the compositor re-composing
a popup over a native GL child, and it is what the user sees as the dock
and the header flickering.
The backdrop cannot stop the popup from compositing, but it can stop
being a moving target while it happens. Holding the animation still for
the moment a popup is up takes the menu from 238 painted widgets to 5,
and a tooltip from 90 to 0.
WHY IT IS A POLL AND NOT AN EVENT FILTER. The obvious implementation is
an application-wide event filter watching for Show and Hide on popup
windows. That was written, measured, and thrown away: it ran Python for
every event in the application -- 13,646 calls per second while a module
opens -- and it cost 130 ms on the very GUI-thread block that opening a
module had just been fixed to shorten (1380-1424 ms became 1473-1606).
Qt already knows the answer and will give it for two C++ calls, so the
animation asks once per frame instead. At sixty frames a second that is
120 calls, against thirteen thousand.
"""
from __future__ import annotations