~dandrader/qtmir/fixSurfaceFocus-lp1491034

« back to all changes in this revision

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

  • Committer: Daniel d'Andrada
  • Date: 2015-09-14 22:38:27 UTC
  • Revision ID: daniel.dandrada@canonical.com-20150914223827-ra1bkhqoocdkuw0w
Update surface focus when a surface enters or leaves a MirSurfaceItem

+ Refactor MirSurfaceItem so that it talks to a MirSurfaceInterface
  instead of the concrete MirSurface class
+ Make MirSurface::setFocus() more robust

Show diffs side-by-side

added added

removed removed

Lines of Context:
222
222
    }
223
223
}
224
224
 
225
 
SessionInterface* MirSurface::session() const
226
 
{
227
 
    return m_session.data();
228
 
}
229
 
 
230
225
Mir::Type MirSurface::type() const
231
226
{
232
227
    switch (m_surface->type()) {
358
353
 
359
354
void MirSurface::setFocus(bool focus)
360
355
{
 
356
    if (!m_session) {
 
357
        return;
 
358
    }
 
359
 
361
360
    // Temporary hotfix for http://pad.lv/1483752
362
 
    if (session() && session()->childSessions()->rowCount() > 0) {
 
361
    if (m_session->childSessions()->rowCount() > 0) {
363
362
        // has child trusted session, ignore any focus change attempts
 
363
        qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << appId() << "]::setFocus(" << (focus ? "true" : "false")
 
364
            << ") - has child trusted session, ignore any focus change attempts";
364
365
        return;
365
366
    }
366
367
 
 
368
    qCDebug(QTMIR_SURFACES).nospace() << "MirSurface[" << appId() << "]::setFocus(" << (focus ? "true" : "false") << ")";
 
369
 
367
370
    if (focus) {
368
371
        m_shell->set_surface_attribute(m_session->session(), m_surface, mir_surface_attrib_focus, mir_surface_focused);
369
372
    } else {
635
638
{
636
639
    Q_EMIT sizeChanged(m_size);
637
640
}
 
641
 
 
642
QString MirSurface::appId() const
 
643
{
 
644
    QString appId;
 
645
 
 
646
    if (m_session && m_session->application()) {
 
647
        appId = m_session->application()->appId();
 
648
    } else {
 
649
        appId.append("-");
 
650
    }
 
651
    return appId;
 
652
}