@@ -40,7 +40,6 @@ namespace unityapi = unity::shell::application;
41TopLevelWindowModel::TopLevelWindowModel()
41TopLevelWindowModel::TopLevelWindowModel()
42 : m_nullWindow(createNullWindow()),
42 : m_nullWindow(createNullWindow()),
43− m_maxWindowId(std::numeric_limits<int>::max()),
44 m_surfaceManagerBusy(false)
43 m_surfaceManagerBusy(false)
46 connect(m_nullWindow, &Window::focusedChanged, this, [this] {
45 connect(m_nullWindow, &Window::focusedChanged, this, [this] {
@@ -351,7 +350,7 @@ void TopLevelWindowModel::onSurfaceDestroyed(unityapi::MirSurfaceInterface *surf
352Window *TopLevelWindowModel::createWindow(unityapi::MirSurfaceInterface *surface)
351Window *TopLevelWindowModel::createWindow(unityapi::MirSurfaceInterface *surface)
354− int id = generateId();
353+ int id = m_nextId.fetchAndAddAcquire(1);
355 return createWindowWithId(surface, id);
354 return createWindowWithId(surface, id);
@@ -526,32 +525,6 @@ int TopLevelWindowModel::findIndexOf(const unityapi::MirSurfaceInterface *surfac
526 return -1;
525 return -1;
529−// Finds a unique integer identifier not greater than maxWindowId.
530−int TopLevelWindowModel::generateId()
532− int candidateId = m_nextId.fetchAndAddAcquire(1);
534− // If the user opens two windows at the exact same time after opening
535− // maxWindowId windows, it is potentially possible that we issue the same
536− // ID for both. This is a risk we can accept.
537− if (candidateId > getMaxWindowId()) {
538− int originalCandidateId = candidateId;
541− while (indexForId(candidateId) != -1) {
544− if (candidateId == originalCandidateId) {
545− // The user has maxWindowId windows open somehow.
546− qFatal("TopLevelWindowModel: Ran out of window IDs!");
550− m_nextId.fetchAndStoreAcquire(candidateId + 1);
555QString TopLevelWindowModel::toString()
528QString TopLevelWindowModel::toString()
557 QString str;
530 QString str;
@@ -795,20 +768,6 @@ void TopLevelWindowModel::setRootFocus(bool focus)
798−void TopLevelWindowModel::setMaxWindowId(int newMaxWindowId)
800− DEBUG_MSG << "(" << newMaxWindowId << ")";
801− if (m_maxWindowId != newMaxWindowId) {
802− m_maxWindowId = newMaxWindowId;
803− Q_EMIT maxWindowIdChanged();
807−int TopLevelWindowModel::getMaxWindowId()
809− return m_maxWindowId;
812// Pending Activation will block refocus of previous focused window
771// Pending Activation will block refocus of previous focused window
813// this is needed since surface activation with miral is async,
772// this is needed since surface activation with miral is async,
814// and activation of placeholder is sync. This causes a race condition
773// and activation of placeholder is sync. This causes a race condition