From baf9b5e6f3f85b8e97371316b50d8818713b52cc Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 30 Oct 2025 10:50:35 -0400 Subject: [PATCH] dwl: dont show empty tags --- Modules/DankBar/Widgets/WorkspaceSwitcher.qml | 11 ++-- Services/DwlService.qml | 59 ++++++++++--------- assets/danklogo.svg | 3 - 3 files changed, 39 insertions(+), 34 deletions(-) delete mode 100644 assets/danklogo.svg diff --git a/Modules/DankBar/Widgets/WorkspaceSwitcher.qml b/Modules/DankBar/Widgets/WorkspaceSwitcher.qml index b953cdb3..f15e0e23 100644 --- a/Modules/DankBar/Widgets/WorkspaceSwitcher.qml +++ b/Modules/DankBar/Widgets/WorkspaceSwitcher.qml @@ -510,22 +510,25 @@ Item { hoverEnabled: !isPlaceholder cursorShape: isPlaceholder ? Qt.ArrowCursor : Qt.PointingHandCursor enabled: !isPlaceholder + acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: mouse => { if (isPlaceholder) { return } + const isRightClick = mouse.button === Qt.RightButton + if (CompositorService.isNiri) { NiriService.switchToWorkspace(modelData - 1) } else if (CompositorService.isHyprland && modelData?.id) { Hyprland.dispatch(`workspace ${modelData.id}`) } else if (CompositorService.isDwl && modelData?.tag !== undefined) { - console.log("DWL tag clicked:", modelData.tag, "modifiers:", mouse.modifiers, "ctrl:", (mouse.modifiers & Qt.ControlModifier)) - if (mouse.modifiers & Qt.ControlModifier) { - console.log("Using toggleTag for tag", modelData.tag) + console.log("DWL click - tag:", modelData.tag, "rightClick:", isRightClick) + if (isRightClick) { + console.log("Calling toggleTag") DwlService.toggleTag(root.screenName, modelData.tag) } else { - console.log("Using switchToTag for tag", modelData.tag) + console.log("Calling switchToTag") DwlService.switchToTag(root.screenName, modelData.tag) } } else if (CompositorService.isSway && modelData?.num) { diff --git a/Services/DwlService.qml b/Services/DwlService.qml index bdfa842e..c4da034b 100644 --- a/Services/DwlService.qml +++ b/Services/DwlService.qml @@ -166,8 +166,31 @@ Singleton { } function toggleTag(outputName, tagIndex) { - const tagmask = 1 << tagIndex - setTags(outputName, tagmask, 1) + const output = getOutputState(outputName) + if (!output || !output.tags) { + console.log("toggleTag: no output or tags for", outputName) + return + } + + let currentMask = 0 + output.tags.forEach(tag => { + if (tag.state === 1) { + currentMask |= (1 << tag.tag) + } + }) + + const clickedMask = 1 << tagIndex + const newMask = currentMask ^ clickedMask + + console.log("toggleTag:", outputName, "tag:", tagIndex, "currentMask:", currentMask.toString(2), "clickedMask:", clickedMask.toString(2), "newMask:", newMask.toString(2)) + + if (newMask === 0) { + console.log("toggleTag: newMask is 0, switching to tag", tagIndex) + setTags(outputName, 1 << tagIndex, 0) + } else { + console.log("toggleTag: setting combined mask", newMask) + setTags(outputName, newMask, 0) + } } function quit() { @@ -223,32 +246,14 @@ Singleton { return [0] } - const activeTags = output.tags - .filter(tag => tag.state === 1) - .map(tag => tag.tag) + const visibleTags = new Set([0]) - const occupiedTags = output.tags - .filter(tag => tag.clients > 0) - .map(tag => tag.tag) + output.tags.forEach(tag => { + if (tag.state === 1 || tag.clients > 0) { + visibleTags.add(tag.tag) + } + }) - const combinedTags = [...new Set([...activeTags, ...occupiedTags])].sort((a, b) => a - b) - - if (combinedTags.length === 0) { - return [0] - } - - const minTag = combinedTags[0] - const maxTag = combinedTags[combinedTags.length - 1] - - const visibleTags = [] - for (let i = minTag; i <= maxTag; i++) { - visibleTags.push(i) - } - - if (maxTag + 1 < tagCount) { - visibleTags.push(maxTag + 1) - } - - return visibleTags + return Array.from(visibleTags).sort((a, b) => a - b) } } diff --git a/assets/danklogo.svg b/assets/danklogo.svg deleted file mode 100644 index f120b5d7..00000000 --- a/assets/danklogo.svg +++ /dev/null @@ -1,3 +0,0 @@ - - -