From 46578fde73cb8882eab403137937d6e78aba2542 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Wed, 25 Jun 2025 12:20:12 -0400 Subject: [PATCH] singletons: Initialize singletons in shell desktop, not panel We have some singletons (ex. for notification popups, volume, dbus) that need to be initialized somewhere in plasmashell. Currently they are done from the panel containment, which is a bit of a strange location. There isn't really any offical way it seems to do this, so move it to the shell package which feels more central. --- .../qml/popups/PopupProviderLoader.qml | 12 ++++++++--- .../panel/package/contents/ui/main.qml | 9 -------- shell/contents/views/Desktop.qml | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/components/mobileshell/qml/popups/PopupProviderLoader.qml b/components/mobileshell/qml/popups/PopupProviderLoader.qml index 07d83ba9..8390360b 100644 --- a/components/mobileshell/qml/popups/PopupProviderLoader.qml +++ b/components/mobileshell/qml/popups/PopupProviderLoader.qml @@ -20,9 +20,15 @@ Item { // WARNING: only call this load from within the plasmashell process, because // multiple bindings of the shortcut may break it entirely (hardware volume keys) function load() { - volumeOSD.active = true; - notifications.active = true; - actionButtons.active = true; + if (!volumeOSD.active) { + volumeOSD.active = true; + } + if (!notifications.active) { + notifications.active = true; + } + if (!actionButtons.active) { + actionButtons.active = true; + } } Loader { diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index ed55ba37..cf84d1dc 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -136,15 +136,6 @@ ContainmentItem { Component.onCompleted: { root.setWindowProperties(); - - // register dbus - MobileShellState.ShellDBusObject.registerObject(); - - // HACK: we need to initialize the DBus server somewhere, it might as well be here... - // Initialize the volume osd, and volume keys. - // Initialize notification popups. - // Initialize action popup buttons. - MobileShell.PopupProviderLoader.load(); } MobileShell.StartupFeedbackPanelFill { diff --git a/shell/contents/views/Desktop.qml b/shell/contents/views/Desktop.qml index a389f2db..2f2de370 100644 --- a/shell/contents/views/Desktop.qml +++ b/shell/contents/views/Desktop.qml @@ -13,6 +13,9 @@ import org.kde.plasma.shell 2.0 as Shell import org.kde.kquickcontrolsaddons 2.0 import org.kde.kirigami 2.20 as Kirigami +import org.kde.plasma.private.mobileshell as MobileShell +import org.kde.plasma.private.mobileshell.state as MobileShellState + Rectangle { id: root @@ -20,6 +23,24 @@ Rectangle { color: (containment && containment.backgroundHints == PlasmaCore.Types.NoBackground) ? "transparent" : Kirigami.Theme.textColor + Component.onCompleted: { + initializeShellSingletons(); + } + + function initializeShellSingletons() { + console.log('Initializing DBus objects and popup providers...'); + // Note: The calls here must be idempotent (support being called multiple times) + // - this is called every time there is a new desktop containment + + // HACK: we need to initialize the DBus server somewhere in plasmashell, it might as well be here... + MobileShellState.ShellDBusObject.registerObject(); + + // Initialize the volume osd, and volume keys. + // Initialize notification popups. + // Initialize action popup buttons. + MobileShell.PopupProviderLoader.load(); + } + function toggleWidgetExplorer(containment) { console.log("Widget Explorer toggled"); if (widgetExplorerStack.source != "") {