OSD: ram optimization

This commit is contained in:
ItsLemmy
2025-10-04 17:55:06 -04:00
parent d3616f7f26
commit 9672c55e7d
+14 -11
View File
@@ -10,7 +10,7 @@ import qs.Widgets
// Unified OSD component // Unified OSD component
// Loader activates only when showing OSD, deactivates when hidden to save resources // Loader activates only when showing OSD, deactivates when hidden to save resources
Variants { 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 { delegate: Loader {
id: root id: root
@@ -21,9 +21,6 @@ Variants {
// Access the notification model from the service // Access the notification model from the service
property ListModel notificationModel: NotificationService.activeList 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 // Loader is only active when actually showing something
active: false active: false
@@ -119,6 +116,14 @@ Variants {
return (base % 2 === 0) ? base : base + 1 return (base % 2 === 0) ? base : base + 1
})() })()
Component.onCompleted: {
connectBrightnessMonitors()
}
Component.onDestruction: {
disconnectBrightnessMonitors()
}
// Anchor selection based on location (window edges) // Anchor selection based on location (window edges)
anchors.top: isTop anchors.top: isTop
anchors.bottom: isBottom anchors.bottom: isBottom
@@ -484,8 +489,11 @@ Variants {
} }
} }
Component.onCompleted: { function disconnectBrightnessMonitors() {
connectBrightnessMonitors() for (var i = 0; i < BrightnessService.monitors.length; i++) {
let monitor = BrightnessService.monitors[i]
monitor.brightnessUpdated.disconnect(onBrightnessChanged)
}
} }
function connectBrightnessMonitors() { function connectBrightnessMonitors() {
@@ -506,11 +514,6 @@ Variants {
} }
function showOSD(type) { 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 // Update the current OSD type
currentOSDType = type currentOSDType = type