mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 16:45:59 +01:00
Avoid connected monitor reusing unavailable ID (#2731)
This commit is contained in:
parent
4537860079
commit
d2eb4fee76
2 changed files with 5 additions and 5 deletions
|
@ -1707,17 +1707,17 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
int CCompositor::getNextAvailableMonitorID(std::string const& name) {
|
||||
// reuse ID if it's already in the map
|
||||
if (m_mMonitorIDMap.contains(name))
|
||||
// reuse ID if it's already in the map, and the monitor with that ID is not being used by another monitor
|
||||
if (m_mMonitorIDMap.contains(name) && !std::any_of(m_vRealMonitors.begin(), m_vRealMonitors.end(), [&](auto m) { return m->ID == m_mMonitorIDMap[name]; }))
|
||||
return m_mMonitorIDMap[name];
|
||||
|
||||
// otherwise, find minimum available ID that is not in the map
|
||||
std::unordered_set<int> usedIDs;
|
||||
std::unordered_set<uint64_t> usedIDs;
|
||||
for (auto const& monitor : m_vRealMonitors) {
|
||||
usedIDs.insert(monitor->ID);
|
||||
}
|
||||
|
||||
int nextID = 0;
|
||||
uint64_t nextID = 0;
|
||||
while (usedIDs.count(nextID) > 0) {
|
||||
nextID++;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class CCompositor {
|
|||
std::vector<CWindow*> m_vWindowsFadingOut;
|
||||
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
|
||||
|
||||
std::unordered_map<std::string, int64_t> m_mMonitorIDMap;
|
||||
std::unordered_map<std::string, uint64_t> m_mMonitorIDMap;
|
||||
|
||||
void initServer();
|
||||
void startCompositor();
|
||||
|
|
Loading…
Reference in a new issue