Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 32a9a618 authored by Roman Gilg's avatar Roman Gilg

Abstract OutputDevice initialization

Summary:
Move generic Wayland parts of OutputDevice initialization into
AbstractOutput class.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T10016

Differential Revision: https://phabricator.kde.org/D16789
parent 27946199
......@@ -152,11 +152,6 @@ void AbstractOutput::createXdgOutput()
m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, m_waylandOutput);
}
void AbstractOutput::setWaylandOutputDevice(KWayland::Server::OutputDeviceInterface *set)
{
m_waylandOutputDevice = set;
}
void AbstractOutput::initWaylandOutput()
{
Q_ASSERT(m_waylandOutputDevice);
......@@ -203,4 +198,33 @@ void AbstractOutput::initWaylandOutput()
);
}
void AbstractOutput::initWaylandOutputDevice(const QString &model,
const QString &manufacturer,
const QByteArray &uuid,
const QVector<KWayland::Server::OutputDeviceInterface::Mode> &modes)
{
if (!m_waylandOutputDevice.isNull()) {
delete m_waylandOutputDevice.data();
m_waylandOutputDevice.clear();
}
m_waylandOutputDevice = waylandServer()->display()->createOutputDevice();
m_waylandOutputDevice->setUuid(uuid);
if (!manufacturer.isEmpty()) {
m_waylandOutputDevice->setManufacturer(manufacturer);
} else {
m_waylandOutputDevice->setManufacturer(i18n("unknown"));
}
m_waylandOutputDevice->setModel(model);
m_waylandOutputDevice->setPhysicalSize(m_physicalSize);
int i = 0;
for (auto mode : modes) {
qCDebug(KWIN_CORE).nospace() << "Adding mode " << ++i << ": " << mode.size << " [" << mode.refreshRate << "]";
m_waylandOutputDevice->addMode(mode);
}
m_waylandOutputDevice->create();
}
}
......@@ -109,6 +109,10 @@ Q_SIGNALS:
protected:
void initWaylandOutput();
void initWaylandOutputDevice(const QString &model,
const QString &manufacturer,
const QByteArray &uuid,
const QVector<KWayland::Server::OutputDeviceInterface::Mode> &modes);
QPointer<KWayland::Server::XdgOutputInterface> xdgOutput() const {
return m_xdgOutput;
......@@ -118,7 +122,6 @@ protected:
QPointer<KWayland::Server::OutputDeviceInterface> waylandOutputDevice() const {
return m_waylandOutputDevice;
}
void setWaylandOutputDevice(KWayland::Server::OutputDeviceInterface *set);
QPoint globalPos() const {
return m_globalPos;
......
......@@ -331,41 +331,31 @@ void DrmOutput::initUuid()
void DrmOutput::initOutputDevice(drmModeConnector *connector)
{
auto wlOutputDevice = waylandOutputDevice();
if (!wlOutputDevice.isNull()) {
delete wlOutputDevice.data();
wlOutputDevice.clear();
}
wlOutputDevice = waylandServer()->display()->createOutputDevice();
wlOutputDevice->setUuid(m_uuid);
QString manufacturer;
if (!m_edid.eisaId.isEmpty()) {
wlOutputDevice->setManufacturer(QString::fromLatin1(m_edid.eisaId));
} else {
wlOutputDevice->setManufacturer(i18n("unknown"));
manufacturer = QString::fromLatin1(m_edid.eisaId);
}
QString connectorName = s_connectorNames.value(connector->connector_type, QByteArrayLiteral("Unknown"));
QString modelName;
if (!m_edid.monitorName.isEmpty()) {
QString model = QString::fromLatin1(m_edid.monitorName);
QString m = QString::fromLatin1(m_edid.monitorName);
if (!m_edid.serialNumber.isEmpty()) {
model.append('/');
model.append(QString::fromLatin1(m_edid.serialNumber));
m.append('/');
m.append(QString::fromLatin1(m_edid.serialNumber));
}
modelName = model;
modelName = m;
} else if (!m_edid.serialNumber.isEmpty()) {
modelName = QString::fromLatin1(m_edid.serialNumber);
} else {
modelName = i18n("unknown");
}
wlOutputDevice->setModel(connectorName + QStringLiteral("-") + QString::number(connector->connector_type_id) + QStringLiteral("-") + modelName);
wlOutputDevice->setPhysicalSize(rawPhysicalSize());
const QString model = connectorName + QStringLiteral("-") + QString::number(connector->connector_type_id) + QStringLiteral("-") + modelName;
// read in mode information
QVector<KWayland::Server::OutputDeviceInterface::Mode> modes;
for (int i = 0; i < connector->count_modes; ++i) {
// TODO: in AMS here we could read and store for later every mode's blob_id
// would simplify isCurrentMode(..) and presentAtomically(..) in case of mode set
......@@ -378,18 +368,15 @@ void DrmOutput::initOutputDevice(drmModeConnector *connector)
deviceflags |= KWayland::Server::OutputDeviceInterface::ModeFlag::Preferred;
}
const auto refreshRate = refreshRateForMode(m);
KWayland::Server::OutputDeviceInterface::Mode mode;
mode.id = i;
mode.size = QSize(m->hdisplay, m->vdisplay);
mode.flags = deviceflags;
mode.refreshRate = refreshRate;
qCDebug(KWIN_DRM) << "Adding mode: " << i << mode.size;
wlOutputDevice->addMode(mode);
mode.refreshRate = refreshRateForMode(m);
modes << mode;
}
wlOutputDevice->create();
setWaylandOutputDevice(wlOutputDevice.data());
AbstractOutput::initWaylandOutputDevice(model, manufacturer, m_uuid, modes);
}
bool DrmOutput::isCurrentMode(const drmModeModeInfo *mode) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment