diff --git a/quickshell/modules/topbar/TopLeftBar.qml b/quickshell/modules/topbar/TopLeftBar.qml index 82fce9f..8d59401 100644 --- a/quickshell/modules/topbar/TopLeftBar.qml +++ b/quickshell/modules/topbar/TopLeftBar.qml @@ -73,7 +73,7 @@ GlassPanel { property int wsNumber: index + 1 property bool isActive: WorkspaceService.activeWorkspace === wsNumber - Layout.preferredWidth: wsText.implicitWidth + 14 + Layout.preferredWidth: Math.max(26, wsText.implicitWidth + 14) Layout.preferredHeight: 22 radius: 5 color: "transparent" @@ -86,7 +86,7 @@ GlassPanel { text: modelData color: wsItem.isActive ? Theme.accent : Theme.fg font.pixelSize: 11 - font.weight: wsItem.isActive ? Font.Bold : Font.Medium + font.weight: Font.DemiBold } MouseArea { diff --git a/quickshell/services/WorkspaceService.qml b/quickshell/services/WorkspaceService.qml index dad8420..8d168f3 100644 --- a/quickshell/services/WorkspaceService.qml +++ b/quickshell/services/WorkspaceService.qml @@ -12,10 +12,22 @@ Item { property var workspaces: [] property var workspaceNames: [] + property bool isManualSwitching: false + + Timer { + id: manualSwitchGuardTimer + interval: 500 + repeat: false + onTriggered: { + root.isManualSwitching = false + } + } + function switchTo(index) { if (index <= 0) return; - // Optimistic UI update for zero visual latency + root.isManualSwitching = true root.activeWorkspace = index + manualSwitchGuardTimer.restart() Quickshell.execDetached(["python3", Quickshell.env("HOME") + "/.config/quickshell/services/python/workspace_service.py", "switch", index.toString()]) } @@ -29,7 +41,12 @@ Item { let parsed = JSON.parse(data.trim()) if (parsed && typeof parsed === "object") { root.hasWorkspaces = parsed.hasWorkspaces === true && parsed.totalWorkspaces > 0 - root.activeWorkspace = parsed.activeWorkspace || 1 + if (!root.isManualSwitching || parsed.activeWorkspace === root.activeWorkspace) { + root.activeWorkspace = parsed.activeWorkspace || 1 + if (parsed.activeWorkspace === root.activeWorkspace) { + root.isManualSwitching = false + } + } root.totalWorkspaces = parsed.totalWorkspaces || 0 root.workspaces = parsed.workspaces || []