summaryrefslogtreecommitdiff
path: root/modules/bar/components/workspaces/Workspaces.qml
diff options
context:
space:
mode:
Diffstat (limited to 'modules/bar/components/workspaces/Workspaces.qml')
-rw-r--r--modules/bar/components/workspaces/Workspaces.qml73
1 files changed, 29 insertions, 44 deletions
diff --git a/modules/bar/components/workspaces/Workspaces.qml b/modules/bar/components/workspaces/Workspaces.qml
index 68e9ac1..1acc111 100644
--- a/modules/bar/components/workspaces/Workspaces.qml
+++ b/modules/bar/components/workspaces/Workspaces.qml
@@ -13,76 +13,61 @@ StyledRect {
required property ShellScreen screen
readonly property int activeWsId: Config.bar.workspaces.perMonitorWorkspaces ? (Hyprland.monitorFor(screen).activeWorkspace?.id ?? 1) : Hyprland.activeWsId
- readonly property list<Workspace> workspaces: layout.children.filter(c => c.isWorkspace).sort((w1, w2) => w1.ws - w2.ws)
+
readonly property var occupied: Hyprland.workspaces.values.reduce((acc, curr) => {
acc[curr.id] = curr.lastIpcObject.windows > 0;
return acc;
}, {})
readonly property int groupOffset: Math.floor((activeWsId - 1) / Config.bar.workspaces.shown) * Config.bar.workspaces.shown
- implicitWidth: layout.implicitWidth + Appearance.padding.small * 2
implicitHeight: layout.implicitHeight + Appearance.padding.small * 2
+ implicitWidth: Config.bar.sizes.innerWidth
+
color: Colours.tPalette.m3surfaceContainer
radius: Appearance.rounding.full
- Item {
- id: inner
+ Loader {
+ active: Config.bar.workspaces.occupiedBg
+ asynchronous: true
anchors.fill: parent
anchors.margins: Appearance.padding.small
- ColumnLayout {
- id: layout
-
- spacing: 0
-
- Repeater {
- model: Config.bar.workspaces.shown
-
- Workspace {
- activeWsId: root.activeWsId
- occupied: root.occupied
- groupOffset: root.groupOffset
- }
- }
+ sourceComponent: OccupiedBg {
+ workspaces: workspaces
+ occupied: root.occupied
+ groupOffset: root.groupOffset
}
+ }
- Loader {
- active: Config.bar.workspaces.occupiedBg
- asynchronous: true
+ ColumnLayout {
+ id: layout
- z: -1
- anchors.fill: parent
+ anchors.centerIn: parent
+ spacing: Math.floor(Appearance.spacing.small / 2)
- sourceComponent: OccupiedBg {
- workspaces: root.workspaces
- occupied: root.occupied
- groupOffset: root.groupOffset
- }
- }
+ Repeater {
+ id: workspaces
- Loader {
- active: Config.bar.workspaces.activeIndicator
- asynchronous: true
+ model: Config.bar.workspaces.shown
- sourceComponent: ActiveIndicator {
+ Workspace {
activeWsId: root.activeWsId
- workspaces: root.workspaces
- mask: layout
- maskWidth: inner.width
- maskHeight: inner.height
+ occupied: root.occupied
groupOffset: root.groupOffset
}
}
+ }
- MouseArea {
- anchors.fill: parent
+ Loader {
+ anchors.horizontalCenter: parent.horizontalCenter
+ active: Config.bar.workspaces.activeIndicator
+ asynchronous: true
- onPressed: event => {
- const ws = layout.childAt(event.x, event.y).index + root.groupOffset + 1;
- if (Hyprland.activeWsId !== ws)
- Hyprland.dispatch(`workspace ${ws}`);
- }
+ sourceComponent: ActiveIndicator {
+ activeWsId: root.activeWsId
+ workspaces: workspaces
+ mask: layout
}
}
}