hyprland/ipc: reduce impact of racing workspace queries

This commit is contained in:
outfoxxed 2025-01-27 21:13:53 -08:00
parent 9506c1bb62
commit d3b1a65911
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 42 additions and 21 deletions

View file

@ -35,18 +35,21 @@ void HyprlandWorkspace::updateInitial(qint32 id, QString name) {
}
void HyprlandWorkspace::updateFromObject(QVariantMap object) {
auto id = object.value("id").value<qint32>();
auto name = object.value("name").value<QString>();
auto monitorId = object.value("monitorID").value<qint32>();
auto monitorName = object.value("monitor").value<QString>();
if (id != this->mId) {
this->mId = id;
auto initial = this->mId = -1;
// ID cannot be updated after creation
if (initial) {
this->mId = object.value("id").value<qint32>();
emit this->idChanged();
}
if (name != this->mName) {
this->mName = std::move(name);
// No events we currently handle give a workspace id but not a name,
// so we shouldn't set this if it isn't an initial query
if (initial) {
this->mName = object.value("name").value<QString>();
emit this->nameChanged();
}