mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-09 23:18:31 -04:00
worksapces: attempt to fix hyprland workspace stability in ScriptModel
related #2754
This commit is contained in:
@@ -111,6 +111,7 @@ Item {
|
|||||||
target: CompositorService
|
target: CompositorService
|
||||||
function onCompositorChanged() {
|
function onCompositorChanged() {
|
||||||
root._placeholderPool = [];
|
root._placeholderPool = [];
|
||||||
|
root._hyprSlotPool = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +153,7 @@ Item {
|
|||||||
baseList = getNiriWorkspaces();
|
baseList = getNiriWorkspaces();
|
||||||
break;
|
break;
|
||||||
case "hyprland":
|
case "hyprland":
|
||||||
baseList = getHyprlandWorkspaces();
|
return hyprlandSlotList(getHyprlandWorkspaces());
|
||||||
break;
|
|
||||||
case "mango":
|
case "mango":
|
||||||
if (root.mangoOverviewActive)
|
if (root.mangoOverviewActive)
|
||||||
return [];
|
return [];
|
||||||
@@ -464,6 +464,42 @@ Item {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hyprland creates/destroys workspaces on empty enter/leave; slots keyed by id keep delegate identity so pills animate instead of popping
|
||||||
|
property var _hyprSlotPool: ({})
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: hyprSlotComponent
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
property var ws: null
|
||||||
|
readonly property var id: ws ? ws.id : -1
|
||||||
|
readonly property string name: ws?.name ?? ""
|
||||||
|
readonly property bool urgent: ws?.urgent ?? false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _hyprSlot(key, ws) {
|
||||||
|
let slot = _hyprSlotPool[key];
|
||||||
|
if (!slot) {
|
||||||
|
slot = hyprSlotComponent.createObject(root);
|
||||||
|
_hyprSlotPool[key] = slot;
|
||||||
|
}
|
||||||
|
if (slot.ws !== ws)
|
||||||
|
slot.ws = ws;
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hyprlandSlotList(raw) {
|
||||||
|
const slots = raw.map(ws => _hyprSlot(ws.id > 0 ? ws.id : "name:" + (ws.name ?? ""), ws));
|
||||||
|
if (!SettingsData.showWorkspacePadding)
|
||||||
|
return slots;
|
||||||
|
// pad past the highest real id so a placeholder becomes that workspace's slot once created
|
||||||
|
let nextId = raw.reduce((max, ws) => Math.max(max, ws.id ?? 0), 0);
|
||||||
|
while (slots.length < 3)
|
||||||
|
slots.push(_hyprSlot(++nextId, null));
|
||||||
|
return slots;
|
||||||
|
}
|
||||||
|
|
||||||
// Stable placeholder instances so ScriptModel (identity-diffed) reuses padding delegates instead of recreating them on workspace churn
|
// Stable placeholder instances so ScriptModel (identity-diffed) reuses padding delegates instead of recreating them on workspace churn
|
||||||
property var _placeholderPool: []
|
property var _placeholderPool: []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user