Add output orientation size helper

Summary:
In order to reduce code duplication add this helper
to AbstractOutput.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16794
This commit is contained in:
Roman Gilg 2018-11-09 23:53:02 +01:00
parent 6295d1e6a2
commit 6857fe5477
3 changed files with 12 additions and 9 deletions

View file

@ -59,10 +59,7 @@ QRect AbstractOutput::geometry() const
QSize AbstractOutput::physicalSize() const QSize AbstractOutput::physicalSize() const
{ {
if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) { return orientateSize(m_physicalSize);
return m_physicalSize.transposed();
}
return m_physicalSize;
} }
int AbstractOutput::refreshRate() const int AbstractOutput::refreshRate() const
@ -251,4 +248,12 @@ void AbstractOutput::initWaylandOutputDevice(const QString &model,
m_waylandOutputDevice->create(); m_waylandOutputDevice->create();
} }
QSize AbstractOutput::orientateSize(const QSize &size) const
{
if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) {
return size.transposed();
}
return size;
}
} }

View file

@ -171,6 +171,8 @@ protected:
void setWaylandMode(const QSize &size, int refreshRate); void setWaylandMode(const QSize &size, int refreshRate);
QSize orientateSize(const QSize &size) const;
private: private:
QPointer<KWayland::Server::OutputInterface> m_waylandOutput; QPointer<KWayland::Server::OutputInterface> m_waylandOutput;
QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput; QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput;

View file

@ -783,11 +783,7 @@ void DrmOutput::updateMode(int modeIndex)
QSize DrmOutput::pixelSize() const QSize DrmOutput::pixelSize() const
{ {
auto orient = orientation(); return orientateSize(QSize(m_mode.hdisplay, m_mode.vdisplay));
if (orient == Qt::PortraitOrientation || orient == Qt::InvertedPortraitOrientation) {
return QSize(m_mode.vdisplay, m_mode.hdisplay);
}
return QSize(m_mode.hdisplay, m_mode.vdisplay);
} }
void DrmOutput::setWaylandMode() void DrmOutput::setWaylandMode()