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
This commit is contained in:
parent
6bfa931f2b
commit
b7dbe0e88a
3 changed files with 45 additions and 5 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue