wayland: Wire in subpixel information

kwaylandserver has all the code to send subpixel information but kwin
doesn't really use it.
This commit is contained in:
Vlad Zahorodnii 2021-04-07 16:31:04 +03:00
parent 9d9747490e
commit da5fc3d9e9
5 changed files with 68 additions and 0 deletions

View file

@ -132,6 +132,16 @@ void AbstractWaylandOutput::setScale(qreal scale)
}
}
AbstractWaylandOutput::SubPixel AbstractWaylandOutput::subPixel() const
{
return m_subPixel;
}
void AbstractWaylandOutput::setSubPixelInternal(SubPixel subPixel)
{
m_subPixel = subPixel;
}
void AbstractWaylandOutput::applyChanges(const KWaylandServer::OutputChangeSet *changeSet)
{
qCDebug(KWIN_CORE) << "Apply changes to the Wayland output.";

View file

@ -68,6 +68,15 @@ public:
};
Q_DECLARE_FLAGS(Capabilities, Capability)
enum class SubPixel {
Unknown,
None,
Horizontal_RGB,
Horizontal_BGR,
Vertical_RGB,
Vertical_BGR,
};
explicit AbstractWaylandOutput(QObject *parent = nullptr);
QString name() const override;
@ -111,6 +120,7 @@ public:
bool isEnabled() const override;
void setEnabled(bool enable) override;
SubPixel subPixel() const;
QString description() const;
Capabilities capabilities() const;
QByteArray edid() const;
@ -167,6 +177,7 @@ protected:
void setTransformInternal(Transform transform);
void setDpmsModeInternal(DpmsMode dpmsMode);
void setCapabilityInternal(Capability capability, bool on = true);
void setSubPixelInternal(SubPixel subPixel);
QSize orientateSize(const QSize &size) const;
@ -186,6 +197,7 @@ private:
QByteArray m_edid;
QVector<Mode> m_modes;
DpmsMode m_dpmsMode = DpmsMode::On;
SubPixel m_subPixel = SubPixel::Unknown;
int m_refreshRate = -1;
int m_recorders = 0;
bool m_isEnabled = true;

View file

@ -185,6 +185,24 @@ quint64 refreshRateForMode(_drmModeModeInfo *m)
}
}
static AbstractWaylandOutput::SubPixel drmSubPixelToKWinSubPixel(drmModeSubPixel subpixel)
{
switch (subpixel) {
case DRM_MODE_SUBPIXEL_UNKNOWN:
return AbstractWaylandOutput::SubPixel::Unknown;
case DRM_MODE_SUBPIXEL_NONE:
return AbstractWaylandOutput::SubPixel::None;
case DRM_MODE_SUBPIXEL_HORIZONTAL_RGB:
return AbstractWaylandOutput::SubPixel::Horizontal_RGB;
case DRM_MODE_SUBPIXEL_HORIZONTAL_BGR:
return AbstractWaylandOutput::SubPixel::Horizontal_BGR;
case DRM_MODE_SUBPIXEL_VERTICAL_RGB:
return AbstractWaylandOutput::SubPixel::Vertical_RGB;
case DRM_MODE_SUBPIXEL_VERTICAL_BGR:
return AbstractWaylandOutput::SubPixel::Vertical_BGR;
}
}
bool DrmOutput::init(drmModeConnector *connector)
{
initUuid();
@ -192,6 +210,7 @@ bool DrmOutput::init(drmModeConnector *connector)
return false;
}
setSubPixelInternal(drmSubPixelToKWinSubPixel(connector->subpixel));
setInternal(m_conn->isInternal());
setCapabilityInternal(DrmOutput::Capability::Dpms);
initOutputDevice(connector);

View file

@ -36,6 +36,26 @@ static KWaylandServer::OutputInterface::Transform kwinTransformToOutputTransform
}
}
static KWaylandServer::OutputInterface::SubPixel kwinSubPixelToOutputSubPixel(AbstractWaylandOutput::SubPixel subPixel)
{
switch (subPixel) {
case AbstractWaylandOutput::SubPixel::Unknown:
return KWaylandServer::OutputInterface::SubPixel::Unknown;
case AbstractWaylandOutput::SubPixel::None:
return KWaylandServer::OutputInterface::SubPixel::None;
case AbstractWaylandOutput::SubPixel::Horizontal_RGB:
return KWaylandServer::OutputInterface::SubPixel::HorizontalRGB;
case AbstractWaylandOutput::SubPixel::Horizontal_BGR:
return KWaylandServer::OutputInterface::SubPixel::HorizontalBGR;
case AbstractWaylandOutput::SubPixel::Vertical_RGB:
return KWaylandServer::OutputInterface::SubPixel::VerticalRGB;
case AbstractWaylandOutput::SubPixel::Vertical_BGR:
return KWaylandServer::OutputInterface::SubPixel::VerticalBGR;
default:
Q_UNREACHABLE();
}
}
static KWaylandServer::OutputInterface::DpmsMode kwinDpmsModeToOutputDpmsMode(AbstractWaylandOutput::DpmsMode dpmsMode)
{
switch (dpmsMode) {
@ -85,6 +105,7 @@ WaylandOutput::WaylandOutput(AbstractWaylandOutput *output, QObject *parent)
m_waylandOutput->setGlobalPosition(geometry.topLeft());
m_waylandOutput->setScale(std::ceil(output->scale()));
m_waylandOutput->setMode(output->modeSize(), output->refreshRate());
m_waylandOutput->setSubPixel(kwinSubPixelToOutputSubPixel(output->subPixel()));
m_xdgOutputV1->setName(output->name());
m_xdgOutputV1->setDescription(output->description());

View file

@ -15,6 +15,11 @@ static KWaylandServer::OutputDeviceInterface::Transform kwinTransformToOutputDev
return static_cast<KWaylandServer::OutputDeviceInterface::Transform>(transform);
}
static KWaylandServer::OutputDeviceInterface::SubPixel kwinSubPixelToOutputDeviceSubPixel(AbstractWaylandOutput::SubPixel subPixel)
{
return static_cast<KWaylandServer::OutputDeviceInterface::SubPixel>(subPixel);
}
WaylandOutputDevice::WaylandOutputDevice(AbstractWaylandOutput *output, QObject *parent)
: QObject(parent)
, m_platformOutput(output)
@ -30,6 +35,7 @@ WaylandOutputDevice::WaylandOutputDevice(AbstractWaylandOutput *output, QObject
m_outputDevice->setTransform(kwinTransformToOutputDeviceTransform(output->transform()));
m_outputDevice->setEisaId(output->eisaId());
m_outputDevice->setSerialNumber(output->serialNumber());
m_outputDevice->setSubPixel(kwinSubPixelToOutputDeviceSubPixel(output->subPixel()));
const auto modes = output->modes();
for (const AbstractWaylandOutput::Mode &mode : modes) {