@@ -40,7 +40,6 @@ namespace unityapi = unity::shell::application;
4040
4141TopLevelWindowModel::TopLevelWindowModel()
4242 : m_nullWindow(createNullWindow()),
43− m_maxWindowId(std::numeric_limits<int>::max()),
4443 m_surfaceManagerBusy(false)
4544{
4645 connect(m_nullWindow, &Window::focusedChanged, this, [this] {
@@ -351,7 +350,7 @@ void TopLevelWindowModel::onSurfaceDestroyed(unityapi::MirSurfaceInterface *surf
351350
352351Window *TopLevelWindowModel::createWindow(unityapi::MirSurfaceInterface *surface)
353352{
354− int id = generateId();
353+ int id = m_nextId.fetchAndAddAcquire(1);
355354 return createWindowWithId(surface, id);
356355}
357356
@@ -526,32 +525,6 @@ int TopLevelWindowModel::findIndexOf(const unityapi::MirSurfaceInterface *surfac
526525 return -1;
527526}
528527
529−// Finds a unique integer identifier not greater than maxWindowId.
530−int TopLevelWindowModel::generateId()
531−{
532− int candidateId = m_nextId.fetchAndAddAcquire(1);
533−
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;
539− candidateId = 1;
540−
541− while (indexForId(candidateId) != -1) {
542− candidateId += 1;
543−
544− if (candidateId == originalCandidateId) {
545− // The user has maxWindowId windows open somehow.
546− qFatal("TopLevelWindowModel: Ran out of window IDs!");
547− }
548− }
549−
550− m_nextId.fetchAndStoreAcquire(candidateId + 1);
551− }
552− return candidateId;
553−}
554−
555528QString TopLevelWindowModel::toString()
556529{
557530 QString str;
@@ -795,20 +768,6 @@ void TopLevelWindowModel::setRootFocus(bool focus)
795768 }
796769}
797770
798−void TopLevelWindowModel::setMaxWindowId(int newMaxWindowId)
799−{
800− DEBUG_MSG << "(" << newMaxWindowId << ")";
801− if (m_maxWindowId != newMaxWindowId) {
802− m_maxWindowId = newMaxWindowId;
803− Q_EMIT maxWindowIdChanged();
804− }
805−}
806−
807−int TopLevelWindowModel::getMaxWindowId()
808−{
809− return m_maxWindowId;
810−}
811−
812771// Pending Activation will block refocus of previous focused window
813772// this is needed since surface activation with miral is async,
814773// and activation of placeholder is sync. This causes a race condition