Files
glassMxrph/quickshell/bar/BarPopout.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

279 lines
11 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import Quickshell.Wayland
import Quickshell.Widgets
import "../components"
import "../core"
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: PopoutState.payload || ToplevelManager.activeToplevel
// 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
readonly property point anchorPoint: placementItem && anchorWindow ? placementItem.mapToItem(anchorWindow.contentItem, 0, 0) : Qt.point(0, 0)
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 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
}
}
}
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
}
}