pragma ComponentBehavior: Bound import QtQuick import Quickshell 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. // qmllint disable uncreatable-type PanelWindow { // qmllint enable uncreatable-type id: root readonly property Item anchorItem: PopoutState.anchor 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: 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 readonly property Item placementItem: anchorObject ? (anchorObject.placement || anchorObject) : null // Window-relative, plus the window's screen offset for centred layers (the notch). readonly property real windowOffsetX: anchorWindow && anchorWindow.screenOffsetX !== undefined ? anchorWindow.screenOffsetX : 0 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 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 property real animX: targetX property real animW: targetWidth property real animH: targetHeight Behavior on animX { enabled: root.morph NumberAnimation { duration: Theme.duration * 1.4 easing.type: Easing.BezierSpline easing.bezierCurve: [0.2, 0, 0, 1, 1, 1] } } Behavior on animW { enabled: root.morph NumberAnimation { duration: Theme.duration * 1.4 easing.type: Easing.BezierSpline easing.bezierCurve: [0.2, 0, 0, 1, 1, 1] } } Behavior on animH { enabled: root.morph NumberAnimation { duration: Theme.duration * 1.4 easing.type: Easing.BezierSpline easing.bezierCurve: [0.2, 0, 0, 1, 1, 1] } } screen: anchorWindow ? anchorWindow.screen : null anchors { top: true left: true } // The layer starts at the screen top so the bar join is inside its box. // Quickshell 0.3.1 qmllint cannot resolve the exported Margins value type. // qmllint disable unqualified unresolved-type margins.left: Math.round(animX) // qmllint enable unqualified unresolved-type implicitWidth: Math.max(40, Math.round(drawer.width)) implicitHeight: Math.max(30, Math.round(BarDrawers.bottom + animH)) mask: Region { item: drawer.body } exclusionMode: ExclusionMode.Ignore color: Theme.transparent readonly property bool active: PopoutState.open || drawer.shown visible: active WlrLayershell.namespace: "glassMxrph-popout" WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.keyboardFocus: WlrKeyboardFocus.None Component.onCompleted: PopoutState.window = root Component.onDestruction: if (PopoutState.window === root) PopoutState.window = null BarDrawer { id: drawer objectName: "barPopoutSurface" y: BarDrawers.bottom open: PopoutState.open contentWidth: Math.round(root.animW) contentHeight: Math.round(root.animH) drawerId: "popout" screenName: root.screen ? root.screen.name : "" screenX: root.animX onHoveredChanged: PopoutState.setPopoutHovered(hovered) Text { id: tip anchors.centerIn: parent padding: 10 leftPadding: 14 rightPadding: 14 text: PopoutState.text color: Theme.text font.pixelSize: 12 opacity: root.kind === "tooltip" ? 1 : 0 visible: opacity > 0 Behavior on opacity { NumberAnimation { duration: Theme.duration / 2 } } } // 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" anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top padding: 12 spacing: 10 opacity: (root.kind === "window" ? 1 : 0) * contentFade visible: opacity > 0 Behavior on opacity { NumberAnimation { duration: Theme.duration / 2 } } Connections { target: root function onToplevelChanged() { if (root.kind === "window" && Theme.duration > 0) swap.restart(); } } NumberAnimation { id: swap target: windowCard property: "contentFade" from: 0.35 to: 1 duration: Theme.duration easing.type: Easing.OutCubic } property real contentFade: 1 readonly property var entry: root.toplevel && root.toplevel.appId ? DesktopEntries.heuristicLookup(root.toplevel.appId) : null // Fixed size: hovering between windows swaps the content, not the pane. readonly property real previewWidth: 480 Row { spacing: 10 width: windowCard.previewWidth IconImage { id: appIcon anchors.verticalCenter: parent.verticalCenter implicitSize: 32 source: windowCard.entry && windowCard.entry.icon ? Quickshell.iconPath(windowCard.entry.icon, true) : "" visible: source.toString() !== "" // Synchronous on purpose: Quickshell's icon provider loads QPixmaps, // which crash when built off the GUI thread (Quickshell 0.3.1). } Column { anchors.verticalCenter: parent.verticalCenter width: parent.width - (appIcon.visible ? appIcon.width + parent.spacing : 0) - actions.width - parent.spacing Text { width: parent.width text: root.toplevel ? root.toplevel.title || "Untitled" : "" color: Theme.text font.pixelSize: 13 font.weight: Font.DemiBold elide: Text.ElideRight } Text { width: parent.width text: windowCard.entry && windowCard.entry.name ? windowCard.entry.name + " · " + root.toplevel.appId : root.toplevel ? root.toplevel.appId : "" color: Theme.textSecondary font.pixelSize: 11 elide: Text.ElideRight } } Row { id: actions anchors.verticalCenter: parent.verticalCenter spacing: 4 WindowAction { objectName: "previewMaximize" glyph: root.toplevel && root.toplevel.maximized ? "󰘕" : "󰘖" fallback: "□" label: "Maximize" onActivated: root.toplevel.maximized = !root.toplevel.maximized } WindowAction { objectName: "previewFullscreen" glyph: "󰊓" fallback: "⤢" label: "Fullscreen" onActivated: root.toplevel.fullscreen = !root.toplevel.fullscreen } WindowAction { objectName: "previewClose" glyph: "󰅖" fallback: "×" label: "Close window" danger: true onActivated: { PopoutState.close(); root.toplevel.close(); } } } } ClippingRectangle { id: frame width: windowCard.previewWidth height: 270 radius: Math.max(8, Theme.radius * 0.55) color: Theme.surfaceVariant border.width: 1 border.color: Theme.hairline ScreencopyView { id: preview // Letterboxed into the fixed frame, keeping the window's aspect. readonly property real aspect: sourceSize.width > 0 && sourceSize.height > 0 ? sourceSize.width / sourceSize.height : 16 / 9 anchors.centerIn: parent width: Math.min(parent.width, parent.height * aspect) height: width / aspect captureSource: root.kind === "window" && root.active && root.toplevel ? root.toplevel : null live: root.active && root.kind === "window" constraintSize: Qt.size(windowCard.previewWidth * 2, 540) opacity: hasContent ? 1 : 0 Behavior on opacity { NumberAnimation { duration: Theme.duration } } } Text { anchors.centerIn: parent visible: !preview.hasContent text: "Preview unavailable" color: Theme.textSecondary font.pixelSize: 12 } } } } component WindowAction: Rectangle { id: action property string glyph property string fallback property string label property bool danger: false signal activated implicitWidth: 26 implicitHeight: 26 radius: 13 color: hover.hovered ? (danger ? Qt.alpha("#ff5f57", 0.85) : Theme.hover) : Theme.surfaceVariant border.width: 1 border.color: Theme.hairline Behavior on color { ColorAnimation { duration: Theme.duration / 2 } } Text { anchors.centerIn: parent text: Icons.available ? action.glyph : action.fallback font.family: Icons.available ? Icons.family : "" font.pixelSize: 13 color: Theme.text } HoverHandler { id: hover cursorShape: Qt.PointingHandCursor } TapHandler { onTapped: if (root.toplevel) action.activated() } Accessible.role: Accessible.Button Accessible.name: label } }