fix(workspace): add manualSwitchGuardTimer and normalize pill text width to eliminate layout and state jiggling

This commit is contained in:
Sho 2026-08-02 16:45:20 +09:00
parent ca7793e3b2
commit 0c9600da45
2 changed files with 21 additions and 4 deletions

View File

@ -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 {

View File

@ -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
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 || []