bar: fix workspaces interactions

Fix clicking on workspaces not switching to them
This commit is contained in:
2 * r + 2 * t 2025-06-07 15:13:09 +10:00
parent 7c3f82f951
commit 5948d581fd
2 changed files with 15 additions and 10 deletions

View file

@ -80,7 +80,7 @@ Item {
anchors.topMargin: Appearance.padding.large
}
StyledClippingRect {
StyledRect {
id: workspaces
anchors.horizontalCenter: parent.horizontalCenter
@ -93,6 +93,20 @@ Item {
implicitWidth: workspacesInner.implicitWidth + Appearance.padding.small * 2
implicitHeight: workspacesInner.implicitHeight + Appearance.padding.small * 2
MouseArea {
anchors.fill: parent
anchors.leftMargin: -BorderConfig.thickness
anchors.rightMargin: -BorderConfig.thickness
onWheel: event => {
const activeWs = Hyprland.activeClient?.workspace?.name;
if (activeWs?.startsWith("special:"))
Hyprland.dispatch(`togglespecialworkspace ${activeWs.slice(8)}`);
else if (event.angleDelta.y < 0 || Hyprland.activeWsId > 1)
Hyprland.dispatch(`workspace r${event.angleDelta.y > 0 ? "-" : "+"}1`);
}
}
Workspaces {
id: workspacesInner

View file

@ -65,20 +65,11 @@ Item {
MouseArea {
anchors.fill: parent
anchors.leftMargin: -(Appearance.padding.small + BorderConfig.thickness)
anchors.rightMargin: -(Appearance.padding.small + BorderConfig.thickness)
onPressed: event => {
const ws = layout.childAt(event.x, event.y).index + root.groupOffset + 1;
if (Hyprland.activeWsId !== ws)
Hyprland.dispatch(`workspace ${ws}`);
}
onWheel: event => {
const activeWs = Hyprland.activeClient?.workspace?.name;
if (activeWs?.startsWith("special:"))
Hyprland.dispatch(`togglespecialworkspace ${activeWs.slice(8)}`);
else if (event.angleDelta.y < 0 || Hyprland.activeWsId > 1)
Hyprland.dispatch(`workspace r${event.angleDelta.y > 0 ? "-" : "+"}1`);
}
}
}