mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
lockeys-service: added a component registration system to avoid polling when not necessary
This commit is contained in:
@@ -298,6 +298,20 @@ Variants {
|
||||
}
|
||||
}
|
||||
|
||||
// Register/unregister LockKeysService polling based on whether LockKey OSD is enabled
|
||||
onLockKeyOSDEnabledChanged: {
|
||||
if (lockKeyOSDEnabled) {
|
||||
LockKeysService.registerComponent("osd:" + (modelData?.name || "unknown"));
|
||||
} else {
|
||||
LockKeysService.unregisterComponent("osd:" + (modelData?.name || "unknown"));
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (lockKeyOSDEnabled) {
|
||||
LockKeysService.registerComponent("osd:" + (modelData?.name || "unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
// LockKeys monitoring with a cleaner approach
|
||||
// Only connect when LockKey OSD is enabled to avoid starting the service unnecessarily
|
||||
Connections {
|
||||
@@ -331,6 +345,7 @@ Variants {
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
LockKeysService.unregisterComponent("osd:" + (modelData?.name || "unknown"));
|
||||
if (typeof BrightnessService !== "undefined" && BrightnessService.monitors) {
|
||||
for (var i = 0; i < BrightnessService.monitors.length; i++) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user