~dandrader/qtmir/surfaceDrawn

« back to all changes in this revision

Viewing changes to src/modules/Unity/Application/session.cpp

  • Committer: CI Train Bot
  • Author(s): Daniel d'Andrada
  • Date: 2016-05-11 09:08:25 UTC
  • mfrom: (484.1.2 promptBeforeSurfaceDraws)
  • Revision ID: ci-train-bot@canonical.com-20160511090825-fazlyfjv76mzsj0r
Session: Add a blank surface to the public list if it already has child prompt surfaces

A prompt session may come in too early, before its parent session got a chance
to draw its surface's first frame.

Normally that wouldn't be a problem and we could withhold that parent surface until
it's finally drawn to. But unfortunately the application process might be blocked,
unable to draw anything, until its child prompt session gets dismissed.

Because of that we have no option but to expose this blank surface to shell so that
it can display it along with the prompt surface on top of it, so that the user can
interact with it right away and finally unblock the application. Fixes: #1578665
Approved by: Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
    if (newSurface->isFirstFrameDrawn()) {
200
200
        prependSurface(newSurface);
201
201
    } else {
202
 
        connect(newSurface, &MirSurfaceInterface::firstFrameDrawn,
203
 
                this, [this, newSurface]() { this->prependSurface(newSurface); });
 
202
        m_blankSurfaces.append(newSurface);
 
203
        connect(newSurface, &QObject::destroyed, this, [this, newSurface]()
 
204
            {
 
205
                this->m_blankSurfaces.removeAll(newSurface);
 
206
            });
 
207
        connect(newSurface, &MirSurfaceInterface::firstFrameDrawn, this, [this, newSurface]()
 
208
            {
 
209
                this->m_blankSurfaces.removeAll(newSurface);
 
210
                newSurface->disconnect(this);
 
211
                this->prependSurface(newSurface);
 
212
            });
204
213
    }
205
214
}
206
215
 
389
398
        // we assume that the top-most surface is the one that caused the prompt session to show up.
390
399
        auto promptSurfaceList = static_cast<MirSurfaceListModel*>(m_surfaceList.get(0)->promptSurfaceList());
391
400
        promptSurfaceList->addSurfaceList(session->surfaceList());
 
401
    } else if (m_blankSurfaces.count() > 0) {
 
402
        // Prompt session came in too early.
 
403
        // Parent session might be blocked until the prompt session is dismissed.
 
404
        // So we cannot wait anymore and must put that blank surface on the surface list so that the
 
405
        // user can see the prompt surface on top of that it and interact.
 
406
        auto blankSurface = m_blankSurfaces.takeFirst();
 
407
 
 
408
        auto promptSurfaceList = static_cast<MirSurfaceListModel*>(blankSurface->promptSurfaceList());
 
409
        promptSurfaceList->addSurfaceList(session->surfaceList());
 
410
 
 
411
        blankSurface->disconnect(this);
 
412
        prependSurface(blankSurface);
392
413
    }
393
414
}
394
415