feat(quickshell): close the window on a middle click of its title
Closing goes through the window id rather than niri's focused-window default: the click and the moment niri acts on it are not the same instant, and the focus can move in between.
This commit is contained in:
1 parent
f5809b160f
commit
fac6d2bd7f
2 files changed
+21
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user