~mir-team/qtmir/mir-0.16-rebuild

« back to all changes in this revision

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

  • Committer: CI bot
  • Author(s): Daniel d'Andrada
  • Date: 2014-08-25 07:45:19 UTC
  • mfrom: (228.1.10 lifecycle)
  • Revision ID: ps-jenkins@lists.canonical.com-20140825074519-tk0lgkzfmt94uar8
Revamp screenshotting to use an image provider again, removing screenshot-related methods on Application

Implementing sourceSize support to scale down images if needed to save memory Fixes: 1359819, 1359821
Approved by: Michał Sawicz, Gerry Boland, Michael Zanetti

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
                return QVariant::fromValue((int)application->state());
246
246
            case RoleFocused:
247
247
                return QVariant::fromValue(application->focused());
248
 
            case RoleScreenshot:
249
 
                return QVariant::fromValue(application->screenshot());
250
248
            case RoleSurface:
251
249
                return QVariant::fromValue(application->surface());
252
250
            case RoleFullscreen:
545
543
    return result;
546
544
}
547
545
 
548
 
bool ApplicationManager::updateScreenshot(const QString &appId)
549
 
{
550
 
    Application *application = findApplication(appId);
551
 
    if (!application) {
552
 
        qWarning() << "ApplicationManager::updateScreenshot - No such running application with appId=" << appId;
553
 
        return false;
554
 
    }
555
 
 
556
 
    application->updateScreenshot();
557
 
    QModelIndex appIndex = findIndex(application);
558
 
    Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);
559
 
    return true;
560
 
}
561
 
 
562
546
void ApplicationManager::onProcessFailed(const QString &appId, const bool duringStartup)
563
547
{
564
548
    /* Applications fail if they fail to launch, crash or are killed. If failed to start, must
654
638
    }
655
639
}
656
640
 
657
 
void ApplicationManager::screenshotUpdated()
658
 
{
659
 
    if (sender()) {
660
 
        Application *application = static_cast<Application*>(sender());
661
 
        QModelIndex appIndex = findIndex(application);
662
 
        Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);
663
 
 
664
 
        qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::screenshotUpdated: Received new screenshot for", application->appId();
665
 
    } else {
666
 
        qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::screenshotUpdated: Received screenshotUpdated signal but application has disappeard.";
667
 
    }
668
 
}
669
 
 
670
641
void ApplicationManager::authorizeSession(const quint64 pid, bool &authorized)
671
642
{
672
643
    authorized = false; //to be proven wrong
910
881
    Q_ASSERT(application != nullptr);
911
882
    qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::add - appId=" << application->appId();
912
883
 
913
 
    connect(application, &Application::screenshotChanged, this, &ApplicationManager::screenshotUpdated);
914
 
 
915
884
    beginInsertRows(QModelIndex(), m_applications.count(), m_applications.count());
916
885
    m_applications.append(application);
917
886
    endInsertRows();