Something went wrong. Try again.
Something went wrong. Try again.
6.3 kB · 181 lines
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182pragma ComponentBehavior: Bound
import ".."import "../services"import "../services/WorkspaceWindowOrder.js" as WindowOrderimport QtQuickimport QtQuick.Effectsimport Quickshellimport Quickshell.Hyprland
Rectangle { id: root
required property var workspace property var barWindow: null property int horizontalPadding: 20 property int minimumWidth: 54 property int iconSize: 18 property int iconSpacing: 3 readonly property list<var> spatialWindows: WindowOrder.spatialOrder(Hyprland.toplevels.values.filter(toplevel => workspace && toplevel.workspace && toplevel.workspace.id === workspace.id)) property list<var> windows: []
// Geometry/title refreshes should not rebuild icon delegates unless the // membership or spatial order actually changed. onSpatialWindowsChanged: syncWindowOrder()
function syncWindowOrder() { if (windows.length !== spatialWindows.length || spatialWindows.some((window, index) => window !== windows[index])) windows = spatialWindows; } readonly property bool occupied: windows.length > 0 readonly property var desktopEntries: DesktopEntries.applications.values
signal clicked(int button)
Component.onCompleted: { syncWindowOrder(); WorkspaceWindowOrder.registerPill(root); } Component.onDestruction: WorkspaceWindowOrder.unregisterPill(root)
function appClass(toplevel) { if (!toplevel) return "";
if (toplevel.wayland && toplevel.wayland.appId) return toplevel.wayland.appId;
if (toplevel.lastIpcObject) { if (toplevel.lastIpcObject.class) return toplevel.lastIpcObject.class;
if (toplevel.lastIpcObject.initialClass) return toplevel.lastIpcObject.initialClass; }
return ""; }
function desktopIcon(toplevel) { if (!toplevel) return "";
const app = appClass(toplevel); if (!app) return "";
// The built-in lookup does not match short window IDs to reverse-DNS // desktop IDs. Also match desktop metadata, reacting when entries load. const entries = root.desktopEntries; const key = app.toLowerCase().replace(/\.desktop$/, ""); const entry = DesktopEntries.heuristicLookup(app) || entries.find(candidate => candidate.startupClass.toLowerCase() === key) || entries.find(candidate => candidate.name.toLowerCase() === key) || entries.find(candidate => candidate.id.toLowerCase().endsWith("." + key)); const icon = entry && entry.icon ? Quickshell.iconPath(entry.icon, true) : ""; return icon || Quickshell.iconPath(app, true); }
width: Math.max(minimumWidth, icons.implicitWidth + horizontalPadding) implicitWidth: Math.max(minimumWidth, icons.implicitWidth + horizontalPadding) implicitHeight: 34 radius: 8 color: mouse.containsMouse ? theme.surface2 : (workspace && workspace.active ? theme.surface2 : (occupied ? theme.alpha(theme.surface0, 0.8) : theme.alpha(theme.surface0, 0.2))) border.color: occupied ? theme.alpha(theme.text, 0.1) : "transparent" border.width: 1
Theme { id: theme }
WorkspaceIconMap { id: iconMap }
Row { id: icons
anchors.centerIn: parent spacing: root.iconSpacing
Repeater { model: root.windows
Item { id: windowIcon
required property var modelData readonly property bool urgent: modelData ? modelData.urgent : false readonly property string glyph: iconMap.iconFor(modelData) readonly property string iconSource: root.desktopIcon(modelData)
width: root.iconSize height: root.iconSize
SequentialAnimation on opacity { running: windowIcon.visible && windowIcon.urgent loops: Animation.Infinite onRunningChanged: { if (!running) windowIcon.opacity = 1; }
NumberAnimation { from: 1 to: 0.2 duration: 1000 easing.type: Easing.InOutSine }
NumberAnimation { from: 0.2 to: 1 duration: 1000 easing.type: Easing.InOutSine } }
Image { anchors.fill: parent source: parent.iconSource asynchronous: true fillMode: Image.PreserveAspectFit mipmap: true visible: parent.glyph.length === 0 && parent.iconSource.length > 0 layer.enabled: windowIcon.urgent layer.effect: MultiEffect { colorization: 1 colorizationColor: theme.red } }
Text { anchors.centerIn: parent text: parent.glyph color: windowIcon.urgent ? theme.red : theme.text font.family: theme.fontFamily font.pixelSize: theme.barFontPixelSize textFormat: Text.PlainText visible: parent.glyph.length > 0 }
Text { anchors.centerIn: parent text: "?" color: windowIcon.urgent ? theme.red : theme.text font.family: theme.fontFamily font.pixelSize: theme.barFontPixelSize textFormat: Text.PlainText visible: parent.glyph.length === 0 && parent.iconSource.length === 0 } } } }
MouseArea { id: mouse
anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton hoverEnabled: true onClicked: mouse => root.clicked(mouse.button) }}