From 27299d1405f6d26f6fa62b3337ab23e0924c1604 Mon Sep 17 00:00:00 2001 From: David Redondo Date: Mon, 19 Apr 2021 12:07:03 +0200 Subject: [PATCH] ContainmentInterface: Set transient parent of submenues The actions added by plugins or applets can contain actions that are menues. This causes a problem for the panel because it doesn't take focus when right clicked. Since the menues had no transientParent, they were created as new toplevels. BUG:417378 --- .../qml/plasmoid/containmentinterface.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index d9d564218..0cb1c60da 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -992,6 +992,17 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event) KAcceleratorManager::manage(desktopMenu); + for (auto action : desktopMenu->actions()) { + if (action->menu()) { + connect(action->menu(), &QMenu::aboutToShow, desktopMenu, [action, desktopMenu] { + if (action->menu()->windowHandle()) { + // Need to add the transient parent otherwise Qt will create a new toplevel + action->menu()->windowHandle()->setTransientParent(desktopMenu->windowHandle()); + } + }); + } + } + desktopMenu->popup(pos); event->setAccepted(true); }