fix(workspace): add manualSwitchGuardTimer and normalize pill text width to eliminate layout and state jiggling
This commit is contained in:
parent
ca7793e3b2
commit
0c9600da45
@ -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 {
|
||||
|
||||
@ -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 || []
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user