Commit b7dbe0e8 authored by Roman Gilg's avatar Roman Gilg
Browse files

Set orientation from DRM on fallback

Summary:
In case of a failed atomic commit the previous mode should be fallen back to.
For orientation provide again a setter that DRM backend can use to set the
transform back to the last working one.

Test Plan: Compiles, fallback works, cursor still messed up somewhat (scaling issue?).

Reviewers: #kwin

Subscribers: zzag, kwin

Tags: #kwin

Maniphest Tasks: T11670

Differential Revision: https://phabricator.kde.org/D25507
parent 6bfa931f
......@@ -308,6 +308,47 @@ QSize AbstractWaylandOutput::orientateSize(const QSize &size) const
return size;
}
DeviceInterface::Transform toTransform(Qt::ScreenOrientations orientation)
{
if (orientation | Qt::LandscapeOrientation) {
if (orientation | Qt::InvertedPortraitOrientation) {
return DeviceInterface::Transform::Flipped;
}
return DeviceInterface::Transform::Normal;
}
if (orientation | Qt::PortraitOrientation) {
if (orientation | Qt::InvertedLandscapeOrientation) {
if (orientation | Qt::InvertedPortraitOrientation) {
return DeviceInterface::Transform::Flipped270;
}
return DeviceInterface::Transform::Flipped90;
}
return DeviceInterface::Transform::Rotated90;
}
if (orientation | Qt::InvertedLandscapeOrientation) {
return DeviceInterface::Transform::Rotated180;
}
if (orientation | Qt::InvertedPortraitOrientation) {
return DeviceInterface::Transform::Rotated270;
}
Q_ASSERT(orientation == Qt::PrimaryOrientation);
return DeviceInterface::Transform::Normal;
}
void AbstractWaylandOutput::setOrientation(Qt::ScreenOrientations orientation)
{
const auto transform = toTransform(orientation);
if (transform == m_waylandOutputDevice->transform()) {
return;
}
setTransform(transform);
emit modeChanged();
}
Qt::ScreenOrientations AbstractWaylandOutput::orientation() const
{
const DeviceInterface::Transform transform = m_waylandOutputDevice->transform();
......
......@@ -141,7 +141,7 @@ protected:
void setWaylandMode(const QSize &size, int refreshRate);
void setTransform(KWayland::Server::OutputDeviceInterface::Transform transform);
void setOrientation(Qt::ScreenOrientations orientation);
QSize orientateSize(const QSize &size) const;
/**
......@@ -159,6 +159,8 @@ private:
void createWaylandOutput();
void createXdgOutput();
void setTransform(KWayland::Server::OutputDeviceInterface::Transform transform);
QPointer<KWayland::Server::OutputInterface> m_waylandOutput;
QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput;
QPointer<KWayland::Server::OutputDeviceInterface> m_waylandOutputDevice;
......
......@@ -841,10 +841,7 @@ bool DrmOutput::presentAtomically(DrmBuffer *buffer)
// go back to previous state
if (m_lastWorkingState.valid) {
m_mode = m_lastWorkingState.mode;
// TODO: Add API back to set orientation from backend
// setOrientation(m_lastWorkingState.orientation);
setOrientation(m_lastWorkingState.orientation);
setGlobalPos(m_lastWorkingState.globalPos);
if (m_primaryPlane) {
m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations);
......
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