bar: better handling for named workspaces

Fixes #448
This commit is contained in:
2 * r + 2 * t 2025-08-24 15:46:15 +10:00
parent a41b954216
commit 92efbc61f7
4 changed files with 18 additions and 5 deletions

View file

@ -11,7 +11,12 @@ StyledRect {
required property Repeater workspaces
required property Item mask
readonly property int currentWsIdx: (activeWsId - 1) % Config.bar.workspaces.shown
readonly property int currentWsIdx: {
let i = activeWsId - 1;
while (i < 0)
i += Config.bar.workspaces.shown;
return i % Config.bar.workspaces.shown;
}
property real leading: workspaces.itemAt(currentWsIdx)?.y ?? 0
property real trailing: workspaces.itemAt(currentWsIdx)?.y ?? 0

View file

@ -48,8 +48,15 @@ Item {
required property var modelData
readonly property Workspace start: root.workspaces.itemAt((modelData.start - 1) % Config.bar.workspaces.shown) ?? null
readonly property Workspace end: root.workspaces.itemAt((modelData.end - 1) % Config.bar.workspaces.shown) ?? null
readonly property Workspace start: root.workspaces.itemAt(getWsIdx(modelData.start)) ?? null
readonly property Workspace end: root.workspaces.itemAt(getWsIdx(modelData.end)) ?? null
function getWsIdx(ws: int): int {
let i = ws - 1;
while (i < 0)
i += Config.bar.workspaces.shown;
return i % Config.bar.workspaces.shown;
}
anchors.horizontalCenter: root.horizontalCenter

View file

@ -35,7 +35,8 @@ ColumnLayout {
animate: true
text: {
const label = Config.bar.workspaces.label || root.ws;
const ws = Hypr.workspaces.values.find(w => w.id === root.ws);
const label = Config.bar.workspaces.label || (!ws || ws.name == root.ws ? root.ws : ws.name[0].toUpperCase());
const occupiedLabel = Config.bar.workspaces.occupiedLabel || label;
const activeLabel = Config.bar.workspaces.activeLabel || (root.isOccupied ? occupiedLabel : label);
return root.activeWsId === root.ws ? activeLabel : root.isOccupied ? occupiedLabel : label;

View file

@ -90,7 +90,7 @@ StyledClippingRect {
MouseArea {
anchors.fill: layout
onClicked: event => {
const ws = layout.childAt(event.x, event.y).index + root.groupOffset + 1;
const ws = layout.childAt(event.x, event.y).ws;
if (Hypr.activeWsId !== ws)
Hypr.dispatch(`workspace ${ws}`);
else