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