Commit 09a258a2 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Task Manager] Consider parent PID for audio stream

For modern web browsers, the audio stream isn't owned by the same process as the window, making the mapping fail.
When no PID is found for a window, check the streams whether the PID in question might be actually the parent PID.

Differential Revision: https://phabricator.kde.org/D25874
parent 5ff5d1c3
......@@ -80,6 +80,7 @@ find_package(KRunnerAppDBusInterface CONFIG REQUIRED)
find_package(KSMServerDBusInterface CONFIG REQUIRED)
find_package(KF5ItemModels CONFIG REQUIRED)
find_package(KF5Emoticons CONFIG REQUIRED)
find_package(KF5 REQUIRED COMPONENTS SysGuard)
find_package(KF5Baloo ${KF5_MIN_VERSION})
set_package_properties(KF5Baloo PROPERTIES DESCRIPTION "File Searching"
......
......@@ -28,6 +28,7 @@ target_link_libraries(taskmanagerplugin
KF5::KIOWidgets
KF5::KIOFileWidgets # KFilePlacesModel
KF5::Plasma
KF5::ProcessCore
KF5::Service
KF5::WindowSystem
PW::LibNotificationManager)
......
......@@ -62,7 +62,23 @@ QtObject {
}
function streamsForPid(pid) {
return findStreams("pid", pid);
var streams = findStreams("pid", pid);
if (streams.length === 0) {
for (var i = 0, length = instantiator.count; i < length; ++i) {
var stream = instantiator.objectAt(i);
if (stream.parentPid === -1) {
stream.parentPid = backend.parentPid(stream.pid);
}
if (stream.parentPid === pid) {
streams.push(stream);
}
}
}
return streams;
}
// QtObject has no default property, hence adding the Instantiator to one explicitly.
......@@ -74,6 +90,8 @@ QtObject {
delegate: QtObject {
readonly property int pid: Client ? Client.properties["application.process.id"] : 0
// Determined on demand.
property int parentPid: -1
readonly property string appName: Client ? Client.properties["application.name"] : ""
readonly property bool muted: Muted
// whether there is nothing actually going on on that stream
......
......@@ -45,6 +45,9 @@
#include <KActivities/Stats/ResultSet>
#include <KActivities/Stats/Terms>
#include <processcore/process.h>
#include <processcore/processes.h>
namespace KAStats = KActivities::Stats;
using namespace KAStats;
......@@ -536,6 +539,19 @@ void Backend::cancelHighlightWindows()
updateWindowHighlight();
}
qint64 Backend::parentPid(qint64 pid) const
{
KSysGuard::Processes procs;
procs.updateOrAddProcess(pid);
KSysGuard::Process *proc = procs.getProcess(pid);
if (!proc) {
return -1;
}
return proc->parentPid();
}
void Backend::windowsHovered(const QVariant &_winIds, bool hovered)
{
m_windowsToHighlight.clear();
......
......@@ -89,6 +89,8 @@ class Backend : public QObject
Q_INVOKABLE void cancelHighlightWindows();
Q_INVOKABLE qint64 parentPid(qint64 pid) const;
static QUrl tryDecodeApplicationsUrl(const QUrl &launcherUrl);
public Q_SLOTS:
......
Markdown is supported
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