forked from quickshell/quickshell
		
	hyprland/ipc: match by name in refreshMonitors instead of id
Was causing ghost/duplicate monitors from usages where the id was not known.
This commit is contained in:
		
							parent
							
								
									ef1a4134f0
								
							
						
					
					
						commit
						bc349998df
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -509,15 +509,15 @@ void HyprlandIpc::refreshMonitors(bool canCreate, bool tryAgain) {
 | 
				
			||||||
		    auto json = QJsonDocument::fromJson(resp).array();
 | 
							    auto json = QJsonDocument::fromJson(resp).array();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		    const auto& mList = this->mMonitors.valueList();
 | 
							    const auto& mList = this->mMonitors.valueList();
 | 
				
			||||||
		    auto ids = QVector<qint32>();
 | 
							    auto names = QVector<QString>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		    for (auto entry: json) {
 | 
							    for (auto entry: json) {
 | 
				
			||||||
			    auto object = entry.toObject().toVariantMap();
 | 
								    auto object = entry.toObject().toVariantMap();
 | 
				
			||||||
			    auto id = object.value("id").toInt();
 | 
								    auto name = object.value("name").toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			    auto monitorIter =
 | 
								    auto monitorIter =
 | 
				
			||||||
			        std::find_if(mList.begin(), mList.end(), [id](const HyprlandMonitor* m) {
 | 
								        std::find_if(mList.begin(), mList.end(), [name](const HyprlandMonitor* m) {
 | 
				
			||||||
				        return m->id() == id;
 | 
									        return m->name() == name;
 | 
				
			||||||
			        });
 | 
								        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			    auto* monitor = monitorIter == mList.end() ? nullptr : *monitorIter;
 | 
								    auto* monitor = monitorIter == mList.end() ? nullptr : *monitorIter;
 | 
				
			||||||
| 
						 | 
					@ -534,13 +534,13 @@ void HyprlandIpc::refreshMonitors(bool canCreate, bool tryAgain) {
 | 
				
			||||||
				    this->mMonitors.insertObject(monitor);
 | 
									    this->mMonitors.insertObject(monitor);
 | 
				
			||||||
			    }
 | 
								    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			    ids.push_back(id);
 | 
								    names.push_back(name);
 | 
				
			||||||
		    }
 | 
							    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		    auto removedMonitors = QVector<HyprlandMonitor*>();
 | 
							    auto removedMonitors = QVector<HyprlandMonitor*>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		    for (auto* monitor: mList) {
 | 
							    for (auto* monitor: mList) {
 | 
				
			||||||
			    if (!ids.contains(monitor->id())) {
 | 
								    if (!names.contains(monitor->name())) {
 | 
				
			||||||
				    removedMonitors.push_back(monitor);
 | 
									    removedMonitors.push_back(monitor);
 | 
				
			||||||
			    }
 | 
								    }
 | 
				
			||||||
		    }
 | 
							    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue