pragma ComponentBehavior: Bound import QtQuick import Quickshell import Quickshell.Wayland import "../components" import "../services" import "../theme" // One desktop widget: its own layer surface on the desktop (Bottom) layer, // sized and placed from its item (or the live draft while it is edited). // Right-click opens the widget editor with this widget selected. // qmllint disable uncreatable-type PanelWindow { id: root required property string modelData readonly property string widgetId: modelData readonly property var item: WidgetState.item(widgetId) readonly property var type: item ? WidgetRegistry.type(item.type) : null readonly property var geometry: WidgetState.rect(widgetId) readonly property bool transparentFace: !!item && WidgetRegistry.transparent(item.type, item.variant) // Kept separate from `screen`, which Quickshell itself assigns on show // (reading it in `visible` would loop). readonly property var output: item ? Quickshell.screens.find(s => s.name === item.monitor) || null : null screen: output readonly property bool desktopShown: WidgetState.editing || !output || !HyprlandService.coveredMonitors.includes(output.name) visible: !!item && !!type && !!output anchors { top: true left: true } // Margins is present at runtime but unresolved in 0.3.1 qmltypes. // qmllint disable unqualified unresolved-type margins { left: Math.round(root.geometry.x) top: Math.round(root.geometry.y) } // qmllint enable unqualified unresolved-type implicitWidth: Math.max(1, Math.round(geometry.w)) implicitHeight: Math.max(1, Math.round(geometry.h)) color: Theme.transparent exclusionMode: ExclusionMode.Ignore WlrLayershell.layer: WlrLayer.Bottom WlrLayershell.namespace: "glassMxrph-widget-" + (item ? item.type : "unknown") WlrLayershell.keyboardFocus: type && type.keyboard ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None Component.onCompleted: WidgetState.surfaces[widgetId] = content Component.onDestruction: delete WidgetState.surfaces[widgetId] Item { id: content anchors.fill: parent opacity: root.item ? root.item.opacity : 1 GlassPanel { anchors.fill: parent visible: !root.transparentFace } Loader { id: face anchors.fill: parent active: !!root.item && !!root.type source: root.item ? WidgetRegistry.source(root.item.type) : "" onLoaded: { item.widgetId = Qt.binding(() => root.widgetId); item.kind = Qt.binding(() => root.item ? root.item.type : ""); item.variant = Qt.binding(() => root.item ? root.item.variant : ""); item.options = Qt.binding(() => root.item && root.item.options ? root.item.options : ({})); item.desktopVisible = Qt.binding(() => root.desktopShown); } } MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton onClicked: WidgetState.edit(root.widgetId) } } }