From 9672c55e7d8bd7e05f38c19d4e08e46f749f203d Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Sat, 4 Oct 2025 17:55:06 -0400 Subject: [PATCH] OSD: ram optimization --- Modules/OSD/OSD.qml | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Modules/OSD/OSD.qml b/Modules/OSD/OSD.qml index 605aea37..91c551a8 100644 --- a/Modules/OSD/OSD.qml +++ b/Modules/OSD/OSD.qml @@ -10,7 +10,7 @@ import qs.Widgets // Unified OSD component // Loader activates only when showing OSD, deactivates when hidden to save resources Variants { - model: Quickshell.screens + model: Quickshell.screens.filter(screen => (Settings.data.osd.monitors.includes(screen.name) || (Settings.data.osd.monitors.length === 0)) && Settings.data.osd.enabled) delegate: Loader { id: root @@ -21,9 +21,6 @@ Variants { // Access the notification model from the service property ListModel notificationModel: NotificationService.activeList - // If no notification display activated in settings, then show them all - property bool canShowOnThisScreen: modelData && (Settings.data.osd.monitors.includes(modelData.name) || (Settings.data.osd.monitors.length === 0)) - // Loader is only active when actually showing something active: false @@ -119,6 +116,14 @@ Variants { return (base % 2 === 0) ? base : base + 1 })() + Component.onCompleted: { + connectBrightnessMonitors() + } + + Component.onDestruction: { + disconnectBrightnessMonitors() + } + // Anchor selection based on location (window edges) anchors.top: isTop anchors.bottom: isBottom @@ -484,8 +489,11 @@ Variants { } } - Component.onCompleted: { - connectBrightnessMonitors() + function disconnectBrightnessMonitors() { + for (var i = 0; i < BrightnessService.monitors.length; i++) { + let monitor = BrightnessService.monitors[i] + monitor.brightnessUpdated.disconnect(onBrightnessChanged) + } } function connectBrightnessMonitors() { @@ -506,11 +514,6 @@ Variants { } function showOSD(type) { - // Check if OSD is enabled in settings and can show on this screen - if (!Settings.data.osd.enabled || !canShowOnThisScreen) { - return - } - // Update the current OSD type currentOSDType = type