diff --git a/defaults/xdg/quickshell/moonarch/Niri.qml b/defaults/xdg/quickshell/moonarch/Niri.qml index 161c87a..2cddb27 100644 --- a/defaults/xdg/quickshell/moonarch/Niri.qml +++ b/defaults/xdg/quickshell/moonarch/Niri.qml @@ -131,4 +131,18 @@ Singleton { Process { id: focusProc } + + // Close a window by id rather than by focus: the click that asks for this + // and the moment niri acts on it are not the same instant, and the focus + // can move in between. + function closeWindow(id) { + if (id === null || id === undefined) + return; + closeProc.command = ["niri", "msg", "action", "close-window", "--id", String(id)]; + closeProc.running = true; + } + + Process { + id: closeProc + } } diff --git a/defaults/xdg/quickshell/moonarch/WindowTitle.qml b/defaults/xdg/quickshell/moonarch/WindowTitle.qml index 50b23ad..656bd38 100644 --- a/defaults/xdg/quickshell/moonarch/WindowTitle.qml +++ b/defaults/xdg/quickshell/moonarch/WindowTitle.qml @@ -64,6 +64,13 @@ Row { HoverHandler { id: hover } + + // Middle click closes the window the title belongs to. + TapHandler { + acceptedButtons: Qt.MiddleButton + enabled: root.win !== null + onTapped: Niri.closeWindow(root.win.id) + } Tooltip { anchorItem: root shown: hover.hovered