From bc349998dfcd155951cde962cb09dae0548b8508 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 6 Jun 2024 00:58:10 -0700 Subject: [PATCH] hyprland/ipc: match by name in refreshMonitors instead of id Was causing ghost/duplicate monitors from usages where the id was not known. --- src/wayland/hyprland/ipc/connection.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wayland/hyprland/ipc/connection.cpp b/src/wayland/hyprland/ipc/connection.cpp index dcb57654..6dcba3ea 100644 --- a/src/wayland/hyprland/ipc/connection.cpp +++ b/src/wayland/hyprland/ipc/connection.cpp @@ -509,15 +509,15 @@ void HyprlandIpc::refreshMonitors(bool canCreate, bool tryAgain) { auto json = QJsonDocument::fromJson(resp).array(); const auto& mList = this->mMonitors.valueList(); - auto ids = QVector(); + auto names = QVector(); for (auto entry: json) { auto object = entry.toObject().toVariantMap(); - auto id = object.value("id").toInt(); + auto name = object.value("name").toString(); auto monitorIter = - std::find_if(mList.begin(), mList.end(), [id](const HyprlandMonitor* m) { - return m->id() == id; + std::find_if(mList.begin(), mList.end(), [name](const HyprlandMonitor* m) { + return m->name() == name; }); auto* monitor = monitorIter == mList.end() ? nullptr : *monitorIter; @@ -534,13 +534,13 @@ void HyprlandIpc::refreshMonitors(bool canCreate, bool tryAgain) { this->mMonitors.insertObject(monitor); } - ids.push_back(id); + names.push_back(name); } auto removedMonitors = QVector(); for (auto* monitor: mList) { - if (!ids.contains(monitor->id())) { + if (!names.contains(monitor->name())) { removedMonitors.push_back(monitor); } }