Skip to content

fix(popups): delay focus grab to prevent immediate dismissal#82

Open
enhulsman wants to merge 1 commit intoAxenide:mainfrom
enhulsman:fix/focus-grab-delay
Open

fix(popups): delay focus grab to prevent immediate dismissal#82
enhulsman wants to merge 1 commit intoAxenide:mainfrom
enhulsman:fix/focus-grab-delay

Conversation

@enhulsman
Copy link

Problem

The overview never actually stayed open for me. Every time I hit my keybind it would either close immediately (seeing nothing) or flash briefly before disappearing. The presets popup had the same issue occasionally.

After looking into it, HyprlandFocusGrab is bound directly via active: overviewOpen (and active: presetsOpen), which activates the grab the instant the QML property changes. On Wayland, the PanelWindow surface may not yet be mapped by the compositor at that point, so Hyprland processes the grab request, finds no valid surface, and immediately fires onCleared, closing the popup before you can interact with it.

Essentially a race condition that depends on compositor timing.

Solution

Replace the direct active property binding with a 50ms Timer that starts when the popup opens. This gives the Wayland compositor time to map the surface before the focus grab is activated. On close, the timer is stopped and the grab is explicitly deactivated.

50ms is conservative since surface mapping typically completes within a single frame (~4-16ms), but it provides a safe margin without being perceptible.

Files Changed

  • modules/widgets/overview/OverviewPopup.qml: Timer-based grab activation, removed direct binding
  • modules/widgets/presets/PresetsPopup.qml: Same pattern

Testing

  1. Open/close overview rapidly (~10 times), should never self-dismiss
  2. Open/close presets popup rapidly, same expectation
  3. Click outside an open popup, should still dismiss correctly via onCleared
  4. Test on multi-monitor (each screen gets its own PanelWindow)

The HyprlandFocusGrab was activated immediately via `active: presetsOpen`
/ `active: overviewOpen`, which could fire before the PanelWindow surface
was fully mapped. This caused onCleared to trigger instantly, closing the
popup before the user could interact with it.

Fix: replace the direct property binding with a 50ms Timer that starts
when the popup opens. The grab is explicitly deactivated when the popup
closes, preventing stale grab state.

Affected popups: OverviewPopup, PresetsPopup.
@enhulsman enhulsman force-pushed the fix/focus-grab-delay branch from f294e5b to 8678573 Compare February 26, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant