Commit 40d6e18b authored by David Redondo's avatar David Redondo 🏎 Committed by Nate Graham
Browse files

Take active screen in account and remove shortcut requirement for activating launcher

With the information about the active screen we can make an educated
guess about where the attention of the user is and where they could
expect the launcher to open. If on the screen no launcher could be
activated, look at all launchers. Also remove the requirement for
launchers to have a shortcut. This is needed to make this feature
work reliably and should reduce the instances of "Meta key stopped working"
happening in general.
CCBUG:447962
BUG:391322
BUG:444343
BUG:437979
parent 2bb96781
Pipeline #212840 passed with stage
in 14 minutes and 54 seconds
......@@ -2244,34 +2244,54 @@ void ShellCorona::configurationChanged(const QString &path)
}
void ShellCorona::activateLauncherMenu()
{
auto message = QDBusMessage::createMethodCall("org.kde.KWin", "/KWin", "org.kde.KWin", "activeOutputName");
auto watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(message));
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher] {
watcher->deleteLater();
QDBusReply<QString> reply = *watcher;
if (reply.isValid()) {
activateLauncherMenu(reply.value());
}
});
}
void ShellCorona::activateLauncherMenu(const QString &screenName)
{
auto activateLauncher = [](Plasma::Applet *applet) -> bool {
const auto provides = applet->pluginMetaData().value(QStringLiteral("X-Plasma-Provides"), QStringList());
if (provides.contains(QLatin1String("org.kde.plasma.launchermenu"))) {
if (!applet->globalShortcut().isEmpty()) {
Q_EMIT applet->activated();
return true;
}
Q_EMIT applet->activated();
return true;
}
return false;
};
for (auto it = m_panelViews.constBegin(), end = m_panelViews.constEnd(); it != end; ++it) {
const auto applets = it.key()->applets();
auto screen = m_screenPool->screenForConnector(screenName);
const auto panels = screen ? panelsForScreen(screen) : m_panelViews.values();
for (const auto panel : panels) {
const auto applets = panel->containment()->applets();
for (auto applet : applets) {
if (activateLauncher(applet)) {
return;
}
}
if (activateLauncher((*it)->containment())) {
if (activateLauncher(panel->containment())) {
return;
}
}
for (auto it = m_desktopViewForScreen.constBegin(), itEnd = m_desktopViewForScreen.constEnd(); it != itEnd; ++it) {
if (activateLauncher((*it)->containment())) {
const auto desktops = screen ? QList{m_desktopViewForScreen.value(screen)} : m_desktopViewForScreen.values();
for (const auto desktop : desktops) {
if (activateLauncher(desktop->containment())) {
return;
}
}
if (screen) {
activateLauncherMenu(QString());
}
}
void ShellCorona::activateTaskManagerEntry(int index)
......
......@@ -245,6 +245,7 @@ private:
void setupWaylandIntegration();
void executeSetupPlasmoidScript(Plasma::Containment *containment, Plasma::Applet *applet);
void checkAllDesktopsUiReady(bool ready);
void activateLauncherMenu(const QString &screenName);
#ifndef NDEBUG
void screenInvariants() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment