diff --git a/settings/hyprland.nix b/settings/hyprland.nix index f7eb026..b0cfdd6 100644 --- a/settings/hyprland.nix +++ b/settings/hyprland.nix @@ -461,16 +461,18 @@ in property var activeDropdown: null function closeAllDropdowns() { if (activeDropdown && activeDropdown.visible) { - activeDropdown.visible = false; + activeDropdown.animateClose(); } activeDropdown = null; } function toggleDropdown(dd, setupFn) { - if (dd.visible) { - dd.visible = false; + if (dd.visible && !dd.closing) { + dd.animateClose(); activeDropdown = null; - } else { - closeAllDropdowns(); + } else if (!dd.visible) { + if (activeDropdown && activeDropdown !== dd && activeDropdown.visible) { + activeDropdown.animateClose(); + } if (setupFn) setupFn(); dd.visible = true; activeDropdown = dd; @@ -835,12 +837,21 @@ in component BarDropdown: PopupWindow { id: dropdown property bool open: false + property bool closing: false property real dropdownX: 0 property real fullWidth: 200 property real fullHeight: 200 property int autoCloseMs: 3000 default property alias content: dropdownContent.data + function animateClose() { + if (!visible || closing) return; + closing = true; + open = false; + _autoClose.stop(); + _closeDelay.start(); + } + anchor.window: bar anchor.rect.x: dropdownX - (fullWidth + 16) / 2 anchor.rect.y: bar.height @@ -854,10 +865,12 @@ in onVisibleChanged: { if (visible) { + closing = false; open = true; _autoClose.restart(); } else { open = false; + closing = false; _autoClose.stop(); } } @@ -865,7 +878,13 @@ in Timer { id: _autoClose interval: dropdown.autoCloseMs - onTriggered: bar.closeAllDropdowns() + onTriggered: dropdown.animateClose() + } + + Timer { + id: _closeDelay + interval: 230 + onTriggered: { dropdown.visible = false; dropdown.closing = false; } } MouseArea {