[plasma/plasma-workspace] shell: ShellCorona: Fix kickoff activation when active screen doesn't have one

Nate Graham <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 436a5c5c29f11f41f2687a875f3beb0c31a2e1fb by Nate Graham, on behalf of Marco Martin.
Committed on 21/07/2026 at 13:45.
Pushed by ngraham into branch 'master'.

ShellCorona: Fix kickoff activation when active screen doesn't have one

Fix a fallout of uint porting: when we press meta and the
active screen doesn't have a kickoff anywhere, remove the recursive call, but simply
try to activate the first kickoff found after failing to trigger it in the current screen

M  +24   -25   shell/shellcorona.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/436a5c5c29f11f41f2687a875f3beb0c31a2e1fb

diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp
index 9ad41bb7b8..867c787cc4 100644
--- a/shell/shellcorona.cpp
+++ b/shell/shellcorona.cpp
@@ -2943,38 +2943,37 @@ void ShellCorona::activateLauncherMenu(const QString &screenName)
         return false;
     };
 
-    uint screenId = m_screenPool->idForName(screenName);
+    const int rawId = m_screenPool->idForName(screenName);
+    const uint screenId = rawId >= 0 ? uint(rawId) : 0;
 
-    for (auto *cont : containments()) {
-        if (cont->screen() == screenId
-            && (cont->containmentType() == Plasma::Containment::Panel || cont->containmentType() == Plasma::Containment::CustomPanel)) {
-            const auto applets = cont->applets();
-            for (auto applet : applets) {
-                if (activateLauncher(applet)) {
-                    return;
-                }
-            }
-            if (activateLauncher(cont)) {
-                return;
-            }
+    QList<Plasma::Containment *> conts = containments();
+
+    // Sort in a way that containments with the "proper" screen are before the others,
+    // and panels go before desktops
+    std::sort(conts.begin(), conts.end(), [screenId](Plasma::Containment *conta, Plasma::Containment *contb) {
+        if (conta->screen() == screenId && contb->screen() != screenId) {
+            return true;
         }
-    }
 
-    for (auto *cont : containments()) {
-        if (cont->screen() == screenId && cont->containmentType() == Plasma::Containment::Desktop) {
-            const auto applets = cont->applets();
-            for (auto applet : applets) {
-                if (activateLauncher(applet)) {
-                    return;
-                }
-            }
-            if (activateLauncher(cont)) {
+        if ((conta->containmentType() == Plasma::Containment::Panel || conta->containmentType() == Plasma::Containment::CustomPanel)
+            && (contb->containmentType() != Plasma::Containment::Panel && contb->containmentType() != Plasma::Containment::CustomPanel)) {
+            return true;
+        }
+        // Make it stable
+        return conta->id() < contb->id();
+    });
+
+    for (auto *cont : std::as_const(conts)) {
+        const auto applets = cont->applets();
+        for (auto applet : applets) {
+            if (activateLauncher(applet)) {
                 return;
             }
         }
+        if (activateLauncher(cont)) {
+            return;
+        }
     }
-
-    activateLauncherMenu(QString());
 }
 
 QString ShellCorona::defaultShell()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.