Files
mxandClaude Opus 5.5 6ad9c0b17e Close panels on a click outside them
Panels relied on Hyprland sending every click to a layer with exclusive
keyboard focus; it does not, so clicking another window or monitor left
the Control Center, Dashboard, notch, Overview, Settings, wallpaper
picker, launcher and plugin panels open. A shared OutsideClick holds a
Hyprland focus grab while a panel is open and closes it when the grab is
cleared. The bars count as inside, so a bar button still toggles its
panel. The old catchers stay as a fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 00:49:19 +01:00

46 lines
1.4 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Hyprland
import "../services"
// Closes an overlay when you click anywhere outside it. Hyprland does not
// route clicks outside a layer to it, even with exclusive keyboard focus, so
// a focus grab does it: clicking another window, the desktop or another
// monitor clears the grab. The bars count as inside, so the bar button that
// opened a panel still toggles it instead of reopening it.
//
// The grab starts once the overlay holds the keyboard; started together with
// the focus change, Hyprland clears it at once.
Item {
id: root
required property var window
property bool active: false
// More windows that count as inside (e.g. the bar a popup hangs from).
property var extraWindows: []
signal outside
property bool grabbing: false
function sync() {
grabbing = false;
if (active)
start.restart();
else
start.stop();
}
onActiveChanged: sync()
Component.onCompleted: sync()
Timer {
id: start
interval: 150
onTriggered: root.grabbing = root.active
}
HyprlandFocusGrab {
windows: [root.window].concat(TrayService.barWindows, root.extraWindows).filter((w, i, all) => !!w && all.indexOf(w) === i)
active: root.grabbing
onCleared: if (root.grabbing) {
root.grabbing = false;
root.outside();
}
}
}