Preview a workspace live when hovering it in the bar

The bar popout shows the hovered workspace as on its monitor: the
wallpaper and a live capture of each window where it sits. A click on it
switches there. The focused workspace is not previewed. Settings -> Bar
-> Preview on hover turns it off (bar.workspaces.preview).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-11-26 00:01:44 +01:00
1 parent 84c2385cfa
commit eb81d51c07
9 files changed
+231 -8

No files matched your search

+26 -3
View File
@@ -5,6 +5,8 @@ import Quickshell.Wayland
import Quickshell.Widgets
import "../components"
import "../core"
import "../overview"
import "../services"
import "../theme"
// Bar hover popout. HyprGlass shapes glass from the layer box, so the surface is
// sized to the card and its geometry animates to morph between anchors.
@@ -16,7 +18,7 @@ PanelWindow {
readonly property var anchorWindow: anchorItem ? anchorItem.QsWindow.window : null
readonly property string kind: PopoutState.kind
// The hovered window's Wayland toplevel; falls back to the focused one.
readonly property var toplevel: PopoutState.payload || ToplevelManager.activeToplevel
readonly property var toplevel: kind === "window" ? PopoutState.payload || ToplevelManager.activeToplevel : null
// Anchors may name a wider placement item (the tray pill, the window list)
// so the drawer stays put while the pointer moves between its entries.
readonly property var anchorObject: anchorItem
@@ -26,8 +28,9 @@ PanelWindow {
readonly property point windowPoint: placementItem && anchorWindow ? placementItem.mapToItem(anchorWindow.contentItem, 0, 0) : Qt.point(0, 0)
readonly property point anchorPoint: Qt.point(windowPoint.x + windowOffsetX, windowPoint.y)
readonly property real availableWidth: screen ? screen.width : 1280
readonly property real targetWidth: Math.ceil(root.kind === "window" ? windowCard.implicitWidth : tip.implicitWidth)
readonly property real targetHeight: Math.ceil(root.kind === "window" ? windowCard.implicitHeight : tip.implicitHeight)
readonly property Item card: kind === "window" ? windowCard : kind === "workspace" ? workspaceCard : tip
readonly property real targetWidth: Math.ceil(card.implicitWidth)
readonly property real targetHeight: Math.ceil(card.implicitHeight)
readonly property real targetX: BarDrawers.clampX(anchorPoint.x + (placementItem ? placementItem.width / 2 : 0), targetWidth + 2 * BarDrawers.ear, availableWidth)
// Morph only while the drawer is out; a cold open grows in place.
readonly property bool morph: drawer.progress > 0.05 && Theme.duration > 0
@@ -111,6 +114,26 @@ PanelWindow {
}
}
}
// A hovered workspace in the bar, live.
WorkspacePreview {
id: workspaceCard
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
workspaceId: root.kind === "workspace" ? PopoutState.payload || 0 : 0
live: root.active && root.kind === "workspace"
opacity: root.kind === "workspace" ? 1 : 0
visible: opacity > 0
Behavior on opacity {
NumberAnimation {
duration: Theme.duration / 2
}
}
onChosen: {
const id = workspaceId;
PopoutState.close();
HyprlandService.focusWorkspace(id);
}
}
Column {
id: windowCard
objectName: "windowPreview"
+26 -1
View File
@@ -19,6 +19,10 @@ GlassPill {
// Workspaces shown on other monitors get a faint outline.
readonly property var visibleIds: Hyprland.monitors.values.map(m => m.activeWorkspace ? m.activeWorkspace.id : 0).filter(id => id > 0 && id !== activeId)
readonly property int count: ConfigService.data.bar.workspaces.count
// Hovering a workspace shows it live in the bar popout (off for copies,
// like the one in Settings).
property bool hoverPreview: true
readonly property bool previews: hoverPreview && ConfigService.data.bar.workspaces.preview !== false
readonly property string notchStyle: entry && entry.notch && ConfigService.data.notch ? ConfigService.data.notch.workspaceStyle : "bar"
readonly property string style: notchStyle && notchStyle !== "bar" ? notchStyle : ConfigService.data.bar.workspaces.style || "numbers"
readonly property bool textual: style === "numbers" || style === "roman" || style === "kanji"
@@ -205,12 +209,33 @@ GlassPill {
}
}
}
// The focused workspace is already on screen; the rest preview.
HoverHandler {
enabled: root.previews
onHoveredChanged: {
if (hovered)
PopoutState.hover(slot, slot.active ? "" : "workspace", "", slot.index + 1);
else
PopoutState.unhover(slot);
}
}
Connections {
target: slot
function onActiveChanged() {
if (slot.active && PopoutState.anchor === slot)
PopoutState.close();
}
}
MouseArea {
id: pelletArea
anchors.fill: parent
hoverEnabled: root.pacman
cursorShape: Qt.PointingHandCursor
onClicked: Hyprland.dispatch("hl.dsp.focus({ workspace = '" + (slot.index + 1) + "' })")
onClicked: {
if (PopoutState.anchor === slot)
PopoutState.close();
Hyprland.dispatch("hl.dsp.focus({ workspace = '" + (slot.index + 1) + "' })");
}
}
}
}