DBus activation with filemanager iface

In Dolphin on wayland currently, if you right clicks a file and create a
zip file from it, Dolphin makes a new window.
What we want to happen is Dolphin to focus the window we have with the
file selected.

This patches Dolphin's dbusinterface.cpp to call
KWindowSystem::setCurrentXdgActivationToken()
with the startupID
This commit is contained in:
Andrey Butirsky 2021-08-20 12:31:36 +03:00
parent e76bf5cb18
commit 5e84fffd6e
2 changed files with 5 additions and 5 deletions

View file

@ -9,6 +9,7 @@
#include "dolphin_generalsettings.h" #include "dolphin_generalsettings.h"
#include <KPropertiesDialog> #include <KPropertiesDialog>
#include <KWindowSystem>
#include <QApplication> #include <QApplication>
#include <QDBusConnection> #include <QDBusConnection>
@ -28,11 +29,11 @@ DBusInterface::DBusInterface() :
void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId) void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId)
{ {
Q_UNUSED(startUpId)
const QList<QUrl> urls = Dolphin::validateUris(uriList); const QList<QUrl> urls = Dolphin::validateUris(uriList);
if (urls.isEmpty()) { if (urls.isEmpty()) {
return; return;
} }
KWindowSystem::setCurrentXdgActivationToken(startUpId);
const auto serviceName = isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid()); const auto serviceName = isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
if(!Dolphin::attachToExistingInstance(urls, false, GeneralSettings::splitView(), serviceName)) { if(!Dolphin::attachToExistingInstance(urls, false, GeneralSettings::splitView(), serviceName)) {
Dolphin::openNewWindow(urls); Dolphin::openNewWindow(urls);
@ -41,11 +42,11 @@ void DBusInterface::ShowFolders(const QStringList& uriList, const QString& start
void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId) void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUpId)
{ {
Q_UNUSED(startUpId)
const QList<QUrl> urls = Dolphin::validateUris(uriList); const QList<QUrl> urls = Dolphin::validateUris(uriList);
if (urls.isEmpty()) { if (urls.isEmpty()) {
return; return;
} }
KWindowSystem::setCurrentXdgActivationToken(startUpId);
const auto serviceName = isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid()); const auto serviceName = isDaemon() ? QString() : QStringLiteral("org.kde.dolphin-%1").arg(QCoreApplication::applicationPid());
if(!Dolphin::attachToExistingInstance(urls, true, GeneralSettings::splitView(), serviceName)) { if(!Dolphin::attachToExistingInstance(urls, true, GeneralSettings::splitView(), serviceName)) {
Dolphin::openNewWindow(urls, nullptr, Dolphin::OpenNewWindowFlag::Select); Dolphin::openNewWindow(urls, nullptr, Dolphin::OpenNewWindowFlag::Select);
@ -54,9 +55,9 @@ void DBusInterface::ShowItems(const QStringList& uriList, const QString& startUp
void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId) void DBusInterface::ShowItemProperties(const QStringList& uriList, const QString& startUpId)
{ {
Q_UNUSED(startUpId)
const QList<QUrl> urls = Dolphin::validateUris(uriList); const QList<QUrl> urls = Dolphin::validateUris(uriList);
if (!urls.isEmpty()) { if (!urls.isEmpty()) {
KWindowSystem::setCurrentXdgActivationToken(startUpId);
KPropertiesDialog::showDialog(urls); KPropertiesDialog::showDialog(urls);
} }
} }

View file

@ -62,8 +62,7 @@ bool Dolphin::attachToExistingInstance(const QList<QUrl>& inputUrls, bool openFi
{ {
bool attached = false; bool attached = false;
// TODO: once Wayland clients can raise or activate themselves remove check from conditional if (inputUrls.isEmpty() || !GeneralSettings::openExternallyCalledFolderInNewTab()) {
if (KWindowSystem::isPlatformWayland() || inputUrls.isEmpty() || !GeneralSettings::openExternallyCalledFolderInNewTab()) {
return false; return false;
} }