diff --git a/quickshell/overview/WorkspacePreview.qml b/quickshell/overview/WorkspacePreview.qml index f05cb7e..c213522 100644 --- a/quickshell/overview/WorkspacePreview.qml +++ b/quickshell/overview/WorkspacePreview.qml @@ -98,6 +98,12 @@ Column { font.pixelSize: root.frameHeight * 0.38 font.weight: Font.DemiBold } + // Below the tiles, so their close buttons take clicks first. + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: root.chosen() + } // Keyed by address so title changes keep each live capture. Repeater { model: ScriptModel { @@ -155,12 +161,55 @@ Column { HoverHandler { id: tileHover } + // Middle-click closes, as in the bar's window list. + TapHandler { + acceptedButtons: Qt.MiddleButton + onTapped: HyprlandService.closeWindow(tile.win.address) + } + // Close without visiting the workspace; shown on hover. + Rectangle { + objectName: "workspacePreviewClose" + readonly property real size: Math.min(20, Math.min(tile.width, tile.height) - 8) + visible: size >= 12 + opacity: tileHover.hovered ? 1 : 0 + enabled: tileHover.hovered + anchors.top: parent.top + anchors.right: parent.right + anchors.margins: 4 + width: size + height: size + radius: size / 2 + color: closeHover.hovered ? Qt.alpha("#ff5f57", 0.85) : Qt.alpha(Theme.surface, 0.85) + border.width: 1 + border.color: Theme.hairline + Behavior on opacity { + NumberAnimation { + duration: Theme.duration / 2 + } + } + Behavior on color { + ColorAnimation { + duration: Theme.duration / 2 + } + } + Text { + anchors.centerIn: parent + text: Icons.available ? "󰅖" : "×" + font.family: Icons.available ? Icons.family : "" + font.pixelSize: Math.round(parent.size * 0.6) + color: Theme.text + } + HoverHandler { + id: closeHover + cursorShape: Qt.PointingHandCursor + } + TapHandler { + onTapped: HyprlandService.closeWindow(tile.win.address) + } + Accessible.role: Accessible.Button + Accessible.name: "Close " + (tile.win.title || tile.win.appId || "window") + } } } - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: root.chosen() - } } }