Commit b2d8bbec authored by Martin Flöser's avatar Martin Flöser

[platforms/drm] Rotate screen if requested from KScreen

Summary:
This change hooks up the drm plane rotate with the rotation requests
from KScreen. Our requests support more than what KScreen exposes in the
UI, that is all the flipped variants. I do not really understand what
the flip means, so this is not implemented yet.

Furthermore this only implements the visual rotation and not the input
rotation. This means mouse movement and touch input is currently broken
on a rotated screen.

Please note that the hardware I used seems to not support the vertical
rotation. I'm not sure whether my code works. On my system it just
results in atomic commit errors and we need to go back to a previous
working state. This is not yet implemented. I need to test the vertical
rotation on my notebook, which should (in theory) support it.

Reviewers: #kwin, #plasma, subdiff, sebas

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8594
parent 77b5c3ca
...@@ -110,9 +110,20 @@ void DrmOutput::moveCursor(const QPoint &globalPos) ...@@ -110,9 +110,20 @@ void DrmOutput::moveCursor(const QPoint &globalPos)
QSize DrmOutput::pixelSize() const QSize DrmOutput::pixelSize() const
{ {
if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) {
return QSize(m_mode.vdisplay, m_mode.hdisplay);
}
return QSize(m_mode.hdisplay, m_mode.vdisplay); return QSize(m_mode.hdisplay, m_mode.vdisplay);
} }
QSize DrmOutput::physicalSize() const
{
if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) {
return QSize(m_physicalSize.height(), m_physicalSize.width());
}
return m_physicalSize;
}
QRect DrmOutput::geometry() const QRect DrmOutput::geometry() const
{ {
return QRect(m_globalPos, pixelSize() / scale()); return QRect(m_globalPos, pixelSize() / scale());
...@@ -702,7 +713,72 @@ bool DrmOutput::commitChanges() ...@@ -702,7 +713,72 @@ bool DrmOutput::commitChanges()
if (m_changeset->transformChanged()) { if (m_changeset->transformChanged()) {
qCDebug(KWIN_DRM) << "Server setting transform: " << (int)(m_changeset->transform()); qCDebug(KWIN_DRM) << "Server setting transform: " << (int)(m_changeset->transform());
m_waylandOutputDevice->setTransform(m_changeset->transform()); m_waylandOutputDevice->setTransform(m_changeset->transform());
// FIXME: implement for wl_output using KWayland::Server::OutputDeviceInterface;
using KWayland::Server::OutputInterface;
switch (m_changeset->transform()) {
case OutputDeviceInterface::Transform::Normal:
if (m_primaryPlane) {
m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate0);
}
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Normal);
}
m_orientation = Qt::PrimaryOrientation;
break;
case OutputDeviceInterface::Transform::Rotated90:
if (m_primaryPlane) {
m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate90);
}
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Rotated90);
}
m_orientation = Qt::PortraitOrientation;
break;
case OutputDeviceInterface::Transform::Rotated180:
if (m_primaryPlane) {
m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate180);
}
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Rotated180);
}
m_orientation = Qt::InvertedLandscapeOrientation;
break;
case OutputDeviceInterface::Transform::Rotated270:
if (m_primaryPlane) {
m_primaryPlane->setTransformation(DrmPlane::Transformation::Rotate270);
}
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Rotated270);
}
m_orientation = Qt::InvertedPortraitOrientation;
break;
case OutputDeviceInterface::Transform::Flipped:
// TODO: what is this exactly?
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Flipped);
}
break;
case OutputDeviceInterface::Transform::Flipped90:
// TODO: what is this exactly?
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Flipped90);
}
break;
case OutputDeviceInterface::Transform::Flipped180:
// TODO: what is this exactly?
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Flipped180);
}
break;
case OutputDeviceInterface::Transform::Flipped270:
// TODO: what is this exactly?
if (m_waylandOutput) {
m_waylandOutput->setTransform(OutputInterface::Transform::Flipped270);
}
break;
}
m_modesetRequested = true;
emit modeChanged();
} }
if (m_changeset->positionChanged()) { if (m_changeset->positionChanged()) {
qCDebug(KWIN_DRM) << "Server setting position: " << m_changeset->position(); qCDebug(KWIN_DRM) << "Server setting position: " << m_changeset->position();
......
...@@ -103,9 +103,7 @@ public: ...@@ -103,9 +103,7 @@ public:
return m_uuid; return m_uuid;
} }
QSize physicalSize() const { QSize physicalSize() const;
return m_physicalSize;
}
Q_SIGNALS: Q_SIGNALS:
void dpmsChanged(); void dpmsChanged();
...@@ -167,6 +165,7 @@ private: ...@@ -167,6 +165,7 @@ private:
bool m_dpmsAtomicOffPending = false; bool m_dpmsAtomicOffPending = false;
bool m_modesetRequested = true; bool m_modesetRequested = true;
QSize m_physicalSize; QSize m_physicalSize;
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
}; };
} }
......
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