import QtQuick import Quickshell import Quickshell.Wayland PanelWindow { id: root required property bool shellOpen required property Compositor compositor required property Theme theme signal requestClose signal requestGoto visible: root.shellOpen color: "transparent" implicitWidth: root.theme.barWidth implicitHeight: root.theme.barHeight exclusionMode: ExclusionMode.Ignore WlrLayershell.namespace: "quickshell:workspace-manager" WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None // No anchors: the layer surface is then centered on the screen. onVisibleChanged: { if (!root.visible) return; root.compositor.refresh(); nameField.text = root.compositor.currentName; Qt.callLater(() => { nameField.forceActiveFocus(); nameField.selectAll(); }); } Connections { target: root.compositor function onRefreshed(): void { if (root.visible) { nameField.text = root.compositor.currentName; nameField.selectAll(); } } } function accept(): void { root.compositor.apply(nameField.text); root.requestClose(); } function isGotoKey(event): bool { const mods = event.modifiers; const ctrl = (mods & Qt.ControlModifier) && !(mods & Qt.AltModifier) && !(mods & Qt.MetaModifier); return event.key === Qt.Key_G && ctrl; } Rectangle { anchors.fill: parent radius: root.theme.cornerRadius color: root.theme.barBg border.color: root.theme.barBorder border.width: 1 Row { anchors.fill: parent anchors.margins: root.theme.barPadding spacing: root.theme.barSpacing Image { width: root.theme.logoSize height: root.theme.logoSize anchors.verticalCenter: parent.verticalCenter source: root.compositor.logoSource visible: root.compositor.logoSource !== "" sourceSize.width: root.theme.logoSize * 2 sourceSize.height: root.theme.logoSize * 2 fillMode: Image.PreserveAspectFit smooth: true // Raster source, so filter the downscale. mipmap: true } Text { id: label anchors.verticalCenter: parent.verticalCenter text: "Workspace Name: " color: root.theme.labelColor font.pixelSize: root.theme.fontSize } Rectangle { id: field anchors.verticalCenter: parent.verticalCenter width: parent.width - label.width - okButton.width - root.theme.logoSize - root.theme.barSpacing * 3 height: root.theme.barHeight - root.theme.barPadding * 2 radius: root.theme.cornerRadius / 2 color: root.theme.fieldBg border.color: nameField.activeFocus ? root.theme.fieldBorder : root.theme.barBorder border.width: 1 TextInput { id: nameField anchors.fill: parent anchors.leftMargin: root.theme.fieldPadding anchors.rightMargin: root.theme.fieldPadding verticalAlignment: TextInput.AlignVCenter color: root.theme.textColor font.pixelSize: root.theme.fontSize selectByMouse: true selectionColor: root.theme.fieldBorder selectedTextColor: root.theme.buttonText clip: true focus: root.visible onAccepted: root.accept() Keys.onEscapePressed: event => { root.requestClose(); event.accepted = true; } // Ctrl+G opens the carousel. A plain G still types into the name. // Other keys must be rejected, or the field would swallow them. Keys.onShortcutOverride: event => { if (root.isGotoKey(event)) event.accepted = true; } Keys.onPressed: event => { if (!root.isGotoKey(event)) { event.accepted = false; return; } root.requestGoto(); event.accepted = true; } } } Rectangle { id: okButton anchors.verticalCenter: parent.verticalCenter width: root.theme.buttonWidth height: root.theme.barHeight - root.theme.barPadding * 2 radius: root.theme.cornerRadius / 2 color: okArea.pressed ? Qt.darker(root.theme.buttonBg, 1.2) : root.theme.buttonBg Text { anchors.centerIn: parent text: "OK" color: root.theme.buttonText font.pixelSize: root.theme.fontSize font.bold: true } MouseArea { id: okArea anchors.fill: parent onClicked: root.accept() } } } } }