core/command: filter instance selection by current display

This commit is contained in:
outfoxxed 2025-10-12 17:33:21 -07:00
parent 1e8cc2e78d
commit 00858812f2
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
9 changed files with 50 additions and 9 deletions

View file

@ -3,12 +3,14 @@
#include <qdatastream.h>
QDataStream& operator<<(QDataStream& stream, const InstanceInfo& info) {
stream << info.instanceId << info.configPath << info.shellId << info.launchTime << info.pid;
stream << info.instanceId << info.configPath << info.shellId << info.launchTime << info.pid
<< info.display;
return stream;
}
QDataStream& operator>>(QDataStream& stream, InstanceInfo& info) {
stream >> info.instanceId >> info.configPath >> info.shellId >> info.launchTime >> info.pid;
stream >> info.instanceId >> info.configPath >> info.shellId >> info.launchTime >> info.pid
>> info.display;
return stream;
}

View file

@ -11,6 +11,7 @@ struct InstanceInfo {
QString shellId;
QDateTime launchTime;
pid_t pid = -1;
QString display;
static InstanceInfo CURRENT; // NOLINT
};

View file

@ -411,7 +411,7 @@ bool QsPaths::checkLock(const QString& path, InstanceLockInfo* info, bool allowD
}
QPair<QVector<InstanceLockInfo>, QVector<InstanceLockInfo>>
QsPaths::collectInstances(const QString& path) {
QsPaths::collectInstances(const QString& path, const QString& display) {
qCDebug(logPaths) << "Collecting instances from" << path;
auto liveInstances = QVector<InstanceLockInfo>();
auto deadInstances = QVector<InstanceLockInfo>();
@ -425,6 +425,11 @@ QsPaths::collectInstances(const QString& path) {
qCDebug(logPaths).nospace() << "Found instance " << info.instance.instanceId << " (pid "
<< info.pid << ") at " << path;
if (!display.isEmpty() && info.instance.display != display) {
qCDebug(logPaths) << "Skipped instance with mismatched display at" << path;
continue;
}
if (info.pid == -1) {
deadInstances.push_back(info);
} else {

View file

@ -30,7 +30,7 @@ public:
static bool
checkLock(const QString& path, InstanceLockInfo* info = nullptr, bool allowDead = false);
static QPair<QVector<InstanceLockInfo>, QVector<InstanceLockInfo>>
collectInstances(const QString& path);
collectInstances(const QString& path, const QString& display);
QDir* baseRunDir();
QDir* shellRunDir();