[wayland] Add support for DpmsInterface
Our server announces the DpmsManagerInterface and in the DRM backend we announce support for Dpms on the OutputInterface (if the Output supports it) and we connect to changing Dpms requests.
This commit is contained in:
parent
679da47235
commit
43f6c1e041
2 changed files with 52 additions and 0 deletions
|
@ -612,6 +612,40 @@ void DrmOutput::cleanupBlackBuffer()
|
|||
}
|
||||
}
|
||||
|
||||
static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode)
|
||||
{
|
||||
using namespace KWayland::Server;
|
||||
switch (mode) {
|
||||
case DrmOutput::DpmsMode::On:
|
||||
return OutputInterface::DpmsMode::On;
|
||||
case DrmOutput::DpmsMode::Standby:
|
||||
return OutputInterface::DpmsMode::Standby;
|
||||
case DrmOutput::DpmsMode::Suspend:
|
||||
return OutputInterface::DpmsMode::Suspend;
|
||||
case DrmOutput::DpmsMode::Off:
|
||||
return OutputInterface::DpmsMode::Off;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
static DrmOutput::DpmsMode fromWaylandDpmsMode(KWayland::Server::OutputInterface::DpmsMode wlMode)
|
||||
{
|
||||
using namespace KWayland::Server;
|
||||
switch (wlMode) {
|
||||
case OutputInterface::DpmsMode::On:
|
||||
return DrmOutput::DpmsMode::On;
|
||||
case OutputInterface::DpmsMode::Standby:
|
||||
return DrmOutput::DpmsMode::Standby;
|
||||
case OutputInterface::DpmsMode::Suspend:
|
||||
return DrmOutput::DpmsMode::Suspend;
|
||||
case OutputInterface::DpmsMode::Off:
|
||||
return DrmOutput::DpmsMode::Off;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void DrmOutput::init(drmModeConnector *connector)
|
||||
{
|
||||
initEdid(connector);
|
||||
|
@ -683,6 +717,17 @@ void DrmOutput::init(drmModeConnector *connector)
|
|||
m_waylandOutput->addMode(QSize(m->hdisplay, m->vdisplay), flags, refreshRate);
|
||||
}
|
||||
|
||||
// set dpms
|
||||
if (!m_dpms.isNull()) {
|
||||
m_waylandOutput->setDpmsSupported(true);
|
||||
m_waylandOutput->setDpmsMode(toWaylandDpmsMode(m_dpmsMode));
|
||||
connect(m_waylandOutput, &KWayland::Server::OutputInterface::dpmsModeRequested, this,
|
||||
[this] (KWayland::Server::OutputInterface::DpmsMode mode) {
|
||||
setDpms(fromWaylandDpmsMode(mode));
|
||||
}, Qt::QueuedConnection
|
||||
);
|
||||
}
|
||||
|
||||
m_waylandOutput->create();
|
||||
}
|
||||
|
||||
|
@ -909,6 +954,9 @@ void DrmOutput::setDpms(DrmOutput::DpmsMode mode)
|
|||
return;
|
||||
}
|
||||
m_dpmsMode = mode;
|
||||
if (m_waylandOutput) {
|
||||
m_waylandOutput->setDpmsMode(toWaylandDpmsMode(m_dpmsMode));
|
||||
}
|
||||
emit dpmsChanged();
|
||||
if (m_dpmsMode != DpmsMode::On) {
|
||||
connect(input(), &InputRedirection::globalPointerChanged, this, &DrmOutput::reenableDpms);
|
||||
|
|
|
@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <KWayland/Server/compositor_interface.h>
|
||||
#include <KWayland/Server/datadevicemanager_interface.h>
|
||||
#include <KWayland/Server/display.h>
|
||||
#include <KWayland/Server/dpms_interface.h>
|
||||
#include <KWayland/Server/idle_interface.h>
|
||||
#include <KWayland/Server/output_interface.h>
|
||||
#include <KWayland/Server/plasmashell_interface.h>
|
||||
|
@ -63,6 +64,7 @@ WaylandServer::WaylandServer(QObject *parent)
|
|||
: QObject(parent)
|
||||
{
|
||||
qRegisterMetaType<KWayland::Server::SurfaceInterface *>("KWayland::Server::SurfaceInterface *");
|
||||
qRegisterMetaType<KWayland::Server::OutputInterface::DpmsMode>();
|
||||
}
|
||||
|
||||
WaylandServer::~WaylandServer()
|
||||
|
@ -186,6 +188,8 @@ void WaylandServer::init(const QByteArray &socketName)
|
|||
);
|
||||
auto shadowManager = m_display->createShadowManager(m_display);
|
||||
shadowManager->create();
|
||||
|
||||
m_display->createDpmsManager(m_display)->create();
|
||||
}
|
||||
|
||||
void WaylandServer::initWorkspace()
|
||||
|
|
Loading…
Reference in a new issue