Ejemplo n.º 1
0
KScreen::ConfigPtr Generator::idealConfig(const KScreen::ConfigPtr &currentConfig)
{
    Q_ASSERT(currentConfig);

//     KDebug::Block idealBlock("Ideal Config");
    KScreen::ConfigPtr config = currentConfig->clone();

    disableAllDisconnectedOutputs(config->outputs());

    KScreen::OutputList connectedOutputs = config->connectedOutputs();
    qCDebug(KSCREEN_KDED) << "Connected outputs: " << connectedOutputs.count();

    if (connectedOutputs.isEmpty()) {
        return config;
    }

    if (connectedOutputs.count() == 1) {
        singleOutput(connectedOutputs);
        return config;
    }

    if (isLaptop()) {
        laptop(connectedOutputs);
        return fallbackIfNeeded(config);
    }

    qCDebug(KSCREEN_KDED) << "Extend to Right";
    extendToRight(connectedOutputs);

    return fallbackIfNeeded(config);
}
Ejemplo n.º 2
0
    void Regression::regress() {
	SVDLib svdLib(inputCoefs);

	int items = output->dim1();
	int outSize = output->dim2();
	coefs = double2D_ptr(new double2D(outSize, inputCoefs->dim2()));

	for (int x = 0; x < outSize; x++) {
	    double1D_ptr singleOutput(new double1D(items));
	    for (int y = 0; y < items; y++) {
		(*singleOutput)[y] = (*output)[y][x];
	    }
	    double1D_ptr singleCoefs = svdLib.getCoefficients(singleOutput);
	    DoubleArray::setDouble1D(coefs, singleCoefs, x);

	}
    };
Ejemplo n.º 3
0
KScreen::ConfigPtr Generator::displaySwitch(DisplaySwitchAction action)
{
//     KDebug::Block switchBlock("Display Switch");
    KScreen::ConfigPtr config = m_currentConfig;
    Q_ASSERT(config);


    KScreen::OutputList connectedOutputs = config->connectedOutputs();

    // There's not much else we can do with only one output
    if (connectedOutputs.count() < 2) {
        singleOutput(connectedOutputs);
        return config;
    }

    // We cannot try all possible combinations with two and more outputs
    if (connectedOutputs.count() > 2) {
        extendToRight(connectedOutputs);
        return config;
    }

    KScreen::OutputPtr embedded, external;
    embedded = embeddedOutput(connectedOutputs);
    // If we don't have an embedded output (desktop with two external screens
    // for instance), then pretend one of them is embedded
    if (!embedded) {
        embedded = connectedOutputs.value(connectedOutputs.keys().first());
    }
    // Just to be sure
    if (embedded->modes().isEmpty()) {
        return config;
    }

    if (action == Generator::Clone) {
        qCDebug(KSCREEN_KDED) << "Cloning";
        embedded->setPrimary(true);
        cloneScreens(connectedOutputs);
        return config;
    }

    connectedOutputs.remove(embedded->id());
    external = connectedOutputs.value(connectedOutputs.keys().first());
    // Just to be sure
    if (external->modes().isEmpty()) {
        return config;
    }

    switch (action) {
    case Generator::ExtendToLeft: {
        qCDebug(KSCREEN_KDED) << "Extend to left";
        external->setPos(QPoint(0,0));
        external->setEnabled(true);
        const KScreen::ModePtr extMode = bestModeForOutput(external);
        Q_ASSERT(extMode);
        external->setCurrentModeId(extMode->id());

        Q_ASSERT(external->currentMode()); // we must have a mode now
        const QSize size = external->currentMode()->size();
        embedded->setPos(QPoint(size.width(), 0));
        embedded->setEnabled(true);
        embedded->setPrimary(true);
        const KScreen::ModePtr embeddedMode = bestModeForOutput(embedded);
        Q_ASSERT(embeddedMode);
        embedded->setCurrentModeId(embeddedMode->id());

        return config;
    }
    case Generator::TurnOffEmbedded: {
        qCDebug(KSCREEN_KDED) << "Turn off embedded (laptop)";
        embedded->setEnabled(false);
        embedded->setPrimary(false);

        external->setEnabled(true);
        external->setPrimary(true);
        const KScreen::ModePtr extMode = bestModeForOutput(external);
        Q_ASSERT(extMode);
        external->setCurrentModeId(extMode->id());
        return config;
    }
    case Generator::TurnOffExternal: {
        qCDebug(KSCREEN_KDED) << "Turn off external screen";
        embedded->setPos(QPoint(0,0));
        embedded->setEnabled(true);
        embedded->setPrimary(true);
        const KScreen::ModePtr embeddedMode = bestModeForOutput(embedded);
        Q_ASSERT(embeddedMode);
        embedded->setCurrentModeId(embeddedMode->id());

        external->setEnabled(false);
        external->setPrimary(false);
        return config;
    }
    case Generator::ExtendToRight: {
        qCDebug(KSCREEN_KDED) << "Extend to the right";
        embedded->setPos(QPoint(0,0));
        embedded->setEnabled(true);
        embedded->setPrimary(true);
        const KScreen::ModePtr embeddedMode = bestModeForOutput(embedded);
        Q_ASSERT(embeddedMode);
        embedded->setCurrentModeId(embeddedMode->id());


        Q_ASSERT(embedded->currentMode()); // we must have a mode now
        const QSize size = embedded->currentMode()->size();
        external->setPos(QPoint(size.width(), 0));
        external->setEnabled(true);
        external->setPrimary(false);
        const KScreen::ModePtr extMode = bestModeForOutput(external);
        Q_ASSERT(extMode);
        external->setCurrentModeId(extMode->id());

        return config;
    }
    default:
        // None: just return config
        // Clone: handled above
        break;
    } // switch

    return config;
}