Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_backend.cpp
Show All 34 Lines | |||||
35 | #include "egl_gbm_backend.h" | 35 | #include "egl_gbm_backend.h" | ||
36 | #include <gbm.h> | 36 | #include <gbm.h> | ||
37 | #endif | 37 | #endif | ||
38 | #if HAVE_EGL_STREAMS | 38 | #if HAVE_EGL_STREAMS | ||
39 | #include "egl_stream_backend.h" | 39 | #include "egl_stream_backend.h" | ||
40 | #endif | 40 | #endif | ||
41 | // KWayland | 41 | // KWayland | ||
42 | #include <KWayland/Server/seat_interface.h> | 42 | #include <KWayland/Server/seat_interface.h> | ||
43 | #include <KWayland/Server/outputconfiguration_interface.h> | | |||
44 | // KF5 | 43 | // KF5 | ||
45 | #include <KConfigGroup> | 44 | #include <KConfigGroup> | ||
46 | #include <KCoreAddons> | 45 | #include <KCoreAddons> | ||
47 | #include <KLocalizedString> | 46 | #include <KLocalizedString> | ||
48 | #include <KSharedConfig> | 47 | #include <KSharedConfig> | ||
49 | // Qt | 48 | // Qt | ||
50 | #include <QCryptographicHash> | 49 | #include <QCryptographicHash> | ||
51 | #include <QSocketNotifier> | 50 | #include <QSocketNotifier> | ||
Show All 26 Lines | 73 | DrmBackend::DrmBackend(QObject *parent) | |||
78 | , m_dpmsFilter() | 77 | , m_dpmsFilter() | ||
79 | { | 78 | { | ||
80 | #if HAVE_EGL_STREAMS | 79 | #if HAVE_EGL_STREAMS | ||
81 | if (qEnvironmentVariableIsSet("KWIN_DRM_USE_EGL_STREAMS")) { | 80 | if (qEnvironmentVariableIsSet("KWIN_DRM_USE_EGL_STREAMS")) { | ||
82 | m_useEglStreams = true; | 81 | m_useEglStreams = true; | ||
83 | } | 82 | } | ||
84 | #endif | 83 | #endif | ||
85 | setSupportsGammaControl(true); | 84 | setSupportsGammaControl(true); | ||
85 | supportsOutputChanges(); | ||||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | DrmBackend::~DrmBackend() | 88 | DrmBackend::~DrmBackend() | ||
89 | { | 89 | { | ||
90 | writeOutputsConfiguration(); | 90 | writeOutputsConfiguration(); | ||
91 | #if HAVE_GBM | 91 | #if HAVE_GBM | ||
92 | if (m_gbmDevice) { | 92 | if (m_gbmDevice) { | ||
93 | gbm_device_destroy(m_gbmDevice); | 93 | gbm_device_destroy(m_gbmDevice); | ||
▲ Show 20 Lines • Show All 459 Lines • ▼ Show 20 Line(s) | 548 | { | |||
553 | } | 553 | } | ||
554 | QCryptographicHash hash(QCryptographicHash::Md5); | 554 | QCryptographicHash hash(QCryptographicHash::Md5); | ||
555 | for (; it != m_outputs.constEnd(); ++it) { | 555 | for (; it != m_outputs.constEnd(); ++it) { | ||
556 | hash.addData((*it)->uuid()); | 556 | hash.addData((*it)->uuid()); | ||
557 | } | 557 | } | ||
558 | return hash.result().toHex().left(10); | 558 | return hash.result().toHex().left(10); | ||
559 | } | 559 | } | ||
560 | 560 | | |||
561 | void DrmBackend::configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) | 561 | void DrmBackend::enableOutput(AbstractOutput *output, bool enable) | ||
562 | { | 562 | { | ||
563 | const auto changes = config->changes(); | 563 | auto *drmOutput = static_cast<DrmOutput*>(output); | ||
564 | bool countChanged = false; | 564 | if (enable) { | ||
565 | 565 | m_enabledOutputs << drmOutput; | |||
566 | //process all non-disabling changes | 566 | emit outputAdded(drmOutput); | ||
567 | for (auto it = changes.begin(); it != changes.end(); it++) { | | |||
568 | KWayland::Server::OutputChangeSet *changeset = it.value(); | | |||
569 | | ||||
570 | auto drmoutput = findOutput(it.key()->uuid()); | | |||
571 | if (drmoutput == nullptr) { | | |||
572 | qCWarning(KWIN_DRM) << "Could NOT find DrmOutput matching " << it.key()->uuid(); | | |||
573 | continue; | | |||
574 | } | | |||
575 | if (changeset->enabledChanged() && changeset->enabled() == KWayland::Server::OutputDeviceInterface::Enablement::Enabled) { | | |||
576 | drmoutput->setEnabled(true); | | |||
577 | m_enabledOutputs << drmoutput; | | |||
578 | emit outputAdded(drmoutput); | | |||
579 | countChanged = true; | | |||
580 | } | | |||
581 | drmoutput->setChanges(changeset); | | |||
582 | } | | |||
583 | //process any disable requests | | |||
584 | for (auto it = changes.begin(); it != changes.end(); it++) { | | |||
585 | KWayland::Server::OutputChangeSet *changeset = it.value(); | | |||
586 | if (changeset->enabledChanged() && changeset->enabled() == KWayland::Server::OutputDeviceInterface::Enablement::Disabled) { | | |||
587 | if (m_enabledOutputs.count() == 1) { | | |||
588 | qCWarning(KWIN_DRM) << "Not disabling final screen" << it.key()->uuid(); | | |||
589 | continue; | | |||
590 | } | | |||
591 | auto drmoutput = findOutput(it.key()->uuid()); | | |||
592 | if (drmoutput == nullptr) { | | |||
593 | qCWarning(KWIN_DRM) << "Could NOT find DrmOutput matching " << it.key()->uuid(); | | |||
594 | continue; | | |||
595 | } | | |||
596 | drmoutput->setEnabled(false); | | |||
597 | m_enabledOutputs.removeOne(drmoutput); | | |||
598 | emit outputRemoved(drmoutput); | | |||
599 | countChanged = true; | | |||
600 | } | | |||
601 | } | | |||
602 | | ||||
603 | if (countChanged) { | | |||
604 | emit screensQueried(); | | |||
605 | } else { | 567 | } else { | ||
606 | emit screens()->changed(); | 568 | m_enabledOutputs.removeOne(drmOutput); | ||
569 | emit outputRemoved(drmOutput); | ||||
607 | } | 570 | } | ||
608 | config->setApplied(); | | |||
609 | } | 571 | } | ||
610 | 572 | | |||
611 | DrmOutput *DrmBackend::findOutput(quint32 connector) | 573 | DrmOutput *DrmBackend::findOutput(quint32 connector) | ||
612 | { | 574 | { | ||
613 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [connector] (DrmOutput *o) { | 575 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [connector] (DrmOutput *o) { | ||
614 | return o->m_conn->id() == connector; | 576 | return o->m_conn->id() == connector; | ||
615 | }); | 577 | }); | ||
616 | if (it != m_outputs.constEnd()) { | 578 | if (it != m_outputs.constEnd()) { | ||
617 | return *it; | 579 | return *it; | ||
618 | } | 580 | } | ||
619 | return nullptr; | 581 | return nullptr; | ||
620 | } | 582 | } | ||
621 | 583 | | |||
622 | DrmOutput *DrmBackend::findOutput(const QByteArray &uuid) | | |||
623 | { | | |||
624 | auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [uuid] (DrmOutput *o) { | | |||
625 | return o->m_uuid == uuid; | | |||
626 | }); | | |||
627 | if (it != m_outputs.constEnd()) { | | |||
628 | return *it; | | |||
629 | } | | |||
630 | return nullptr; | | |||
631 | } | | |||
632 | | ||||
633 | bool DrmBackend::present(DrmBuffer *buffer, DrmOutput *output) | 584 | bool DrmBackend::present(DrmBuffer *buffer, DrmOutput *output) | ||
634 | { | 585 | { | ||
635 | if (!buffer || buffer->bufferId() == 0) { | 586 | if (!buffer || buffer->bufferId() == 0) { | ||
636 | if (m_deleteBufferAfterPageFlip) { | 587 | if (m_deleteBufferAfterPageFlip) { | ||
637 | delete buffer; | 588 | delete buffer; | ||
638 | } | 589 | } | ||
639 | return false; | 590 | return false; | ||
640 | } | 591 | } | ||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |