diff options
| author | Tuur Vanhoutte <4633209+zjeffer@users.noreply.github.com> | 2023-07-18 12:12:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-18 12:12:05 +0200 |
| commit | d2eb4fee76f8e8158f34c38647ced42fbe25ef0d (patch) | |
| tree | c3b7065c0da4b492f79cac96d6b07dbd046ace85 /src/Compositor.cpp | |
| parent | 45378600793c61356b557d5aa4bbb8ce351f9d41 (diff) | |
Avoid connected monitor reusing unavailable ID (#2731)
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 0929b7c1..520b4342 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -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++; } |
