1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-06 05:28:29 -04:00

refactor(compositor): reduce unnecessary UI updates

- Defer updates when window state hasn't actually changed
- Cache frame-blocked state per screen instead of recalculating constantly
- keep popouts cache so reopening them is instant & clean up otherwise
This commit is contained in:
purian23
2026-07-02 21:42:20 -04:00
parent 8b79d1dad3
commit 0c99e4b8d1
6 changed files with 218 additions and 77 deletions
+32 -24
View File
@@ -435,26 +435,31 @@ Singleton {
function handleWindowFocusChanged(data) {
const focusedWindowId = data.id;
// Only clone windows whose focus flag changes; skip reassignment if nothing changed.
let focusedWindow = null;
const updatedWindows = [];
let changed = false;
const updatedWindows = new Array(windows.length);
for (var i = 0; i < windows.length; i++) {
const w = windows[i];
const updatedWindow = {};
for (let prop in w) {
updatedWindow[prop] = w[prop];
const isFocused = w.id === focusedWindowId;
if (!!w.is_focused === isFocused) {
updatedWindows[i] = w;
if (isFocused)
focusedWindow = w;
continue;
}
updatedWindow.is_focused = (w.id === focusedWindowId);
if (updatedWindow.is_focused) {
const updatedWindow = Object.assign({}, w, {
"is_focused": isFocused
});
if (isFocused)
focusedWindow = updatedWindow;
}
updatedWindows.push(updatedWindow);
updatedWindows[i] = updatedWindow;
changed = true;
}
windows = updatedWindows;
if (changed)
windows = updatedWindows;
if (focusedWindow) {
const ws = root.workspaces[focusedWindow.workspace_id];
@@ -490,26 +495,29 @@ Singleton {
setWorkspaces(updatedWorkspaces);
}
const updatedWindows = [];
let changed = false;
const updatedWindows = new Array(windows.length);
for (var i = 0; i < windows.length; i++) {
const w = windows[i];
const updatedWindow = {};
for (let prop in w) {
updatedWindow[prop] = w[prop];
}
let isFocused;
if (data.active_window_id !== null && data.active_window_id !== undefined) {
updatedWindow.is_focused = (w.id == data.active_window_id);
isFocused = (w.id == data.active_window_id);
} else {
updatedWindow.is_focused = w.workspace_id == data.workspace_id ? false : w.is_focused;
isFocused = w.workspace_id == data.workspace_id ? false : !!w.is_focused;
}
updatedWindows.push(updatedWindow);
if (!!w.is_focused === isFocused) {
updatedWindows[i] = w;
continue;
}
updatedWindows[i] = Object.assign({}, w, {
"is_focused": isFocused
});
changed = true;
}
windows = updatedWindows;
if (changed)
windows = updatedWindows;
}
function handleWindowsChanged(data) {