Commit cad5ddba authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Merge Service
Browse files

xdg_activation_v1: Do not bounce icon if the desktop file was not found

It's annoying and doesn't buy us much.
Additionally, take X-KDE-StartupNotify into account as we are meant to.

BUG: 453940
Tested-by: Merge Service <!2415>
Part-of: <!2415>
parent 221f114d
Pipeline #180390 passed with stage
in 45 minutes and 13 seconds
......@@ -3298,12 +3298,23 @@ void Window::setDesktopFileName(QByteArray name)
Q_EMIT desktopFileNameChanged();
}
QString Window::iconFromDesktopFile(const QString &desktopFileName)
{
const QString absolutePath = findDesktopFile(desktopFileName);
if (absolutePath.isEmpty()) {
return {};
}
KDesktopFile df(absolutePath);
return df.readIcon();
}
QString Window::iconFromDesktopFile() const
{
return iconFromDesktopFile(QFile::decodeName(m_desktopFileName));
}
QString Window::iconFromDesktopFile(const QString &desktopFileName)
QString Window::findDesktopFile(const QString &desktopFileName)
{
if (desktopFileName.isEmpty()) {
return {};
......@@ -3328,12 +3339,7 @@ QString Window::iconFromDesktopFile(const QString &desktopFileName)
desktopFilePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
desktopFileName);
}
if (desktopFilePath.isEmpty()) {
return {};
}
KDesktopFile df(desktopFilePath);
return df.readIcon();
return desktopFilePath;
}
bool Window::hasApplicationMenu() const
......
......@@ -1391,6 +1391,8 @@ public:
*/
static QString iconFromDesktopFile(const QString &fileName);
static QString findDesktopFile(const QString &fileName);
/**
* Sets the last user usage serial of the surface as @p serial
*/
......
......@@ -17,6 +17,7 @@
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KDesktopFile>
using namespace KWaylandServer;
......@@ -73,8 +74,15 @@ QString XdgActivationV1Integration::requestToken(bool isPrivileged, SurfaceInter
clear();
}
QSharedPointer<PlasmaWindowActivationInterface> pwActivation(waylandServer()->plasmaActivationFeedback()->createActivation(appId));
m_currentActivationToken.reset(new ActivationToken{newToken, isPrivileged, surface, serial, seat, appId, pwActivation});
if (!appId.isEmpty()) {
bool showNotify = false;
QIcon icon;
if (const QString desktopFilePath = Window::findDesktopFile(appId); !desktopFilePath.isEmpty()) {
KDesktopFile df(desktopFilePath);
showNotify |= df.desktopGroup().readEntry("StartupNotify", true) || df.desktopGroup().readEntry("X-KDE-StartupNotify", true);
icon = QIcon::fromTheme(df.readIcon(), QIcon::fromTheme(QStringLiteral("system-run")));
}
m_currentActivationToken.reset(new ActivationToken{newToken, isPrivileged, surface, serial, seat, appId, showNotify, pwActivation});
if (showNotify) {
const auto icon = QIcon::fromTheme(Window::iconFromDesktopFile(appId), QIcon::fromTheme(QStringLiteral("system-run")));
Q_EMIT effects->startupAdded(m_currentActivationToken->token, icon);
}
......@@ -111,7 +119,7 @@ void XdgActivationV1Integration::activateSurface(SurfaceInterface *surface, cons
void XdgActivationV1Integration::clear()
{
Q_ASSERT(m_currentActivationToken);
if (!m_currentActivationToken->applicationId.isEmpty()) {
if (m_currentActivationToken->showNotify) {
Q_EMIT effects->startupRemoved(m_currentActivationToken->token);
}
m_currentActivationToken.reset();
......
......@@ -37,11 +37,12 @@ public:
const QString token;
const bool isPrivileged;
QPointer<const KWaylandServer::SurfaceInterface> surface;
const QPointer<const KWaylandServer::SurfaceInterface> surface;
const uint serial;
const KWaylandServer::SeatInterface *seat;
QString applicationId;
QSharedPointer<KWaylandServer::PlasmaWindowActivationInterface> activation;
const QString applicationId;
const bool showNotify;
const QSharedPointer<KWaylandServer::PlasmaWindowActivationInterface> activation;
};
QString requestPrivilegedToken(KWaylandServer::SurfaceInterface *surface, uint serial, KWaylandServer::SeatInterface *seat, const QString &appId)
......
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