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
icc-effect-5.17.5
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
{
if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) {
return m_physicalSize.transposed();
}
return m_physicalSize;
return orientateSize(m_physicalSize);
}
int AbstractOutput::refreshRate() const
@ -251,4 +248,12 @@ void AbstractOutput::initWaylandOutputDevice(const QString &model,
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);
QSize orientateSize(const QSize &size) const;
private:
QPointer<KWayland::Server::OutputInterface> m_waylandOutput;
QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput;

View File

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