perf(launcher): reduce background resource usage

Make the custom cursor event-driven, pause CSS, theme video, and Lottie work
while the launcher is hidden or unfocused, and reduce presence polling while
osu is running.
This commit is contained in:
HorizonCode committed 2026-11-04 17:00:16 +01:00
1 parent 687ab26752
commit c2fd265b49
8 files changed
+171 -31

No files matched your search

+32
View File
@@ -71,6 +71,37 @@
let { children } = $props();
function appActivity(node: HTMLElement) {
let focused = true;
const sync = () => {
node.classList.toggle('app-inactive', document.hidden || !focused);
};
const onBlur = () => {
focused = false;
sync();
};
const onFocus = () => {
focused = true;
sync();
};
const onVisibilityChange = () => sync();
window.addEventListener('blur', onBlur);
window.addEventListener('focus', onFocus);
document.addEventListener('visibilitychange', onVisibilityChange);
sync();
return {
destroy() {
window.removeEventListener('blur', onBlur);
window.removeEventListener('focus', onFocus);
document.removeEventListener('visibilitychange', onVisibilityChange);
node.classList.remove('app-inactive');
},
};
}
let unlistenEditorState: (() => void) | undefined;
let unlistenRequestEditorData: (() => void) | undefined;
let unlistenPresenceEditorState: (() => void) | undefined;
@@ -552,6 +583,7 @@
</AlertDialog.Root>
<main
use:appActivity
use:themeMediaSuspension
use:themeParallax={{
enabled: $active_custom_theme?.definition?.parallax?.enabled === true,