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:
parent
6295d1e6a2
commit
6857fe5477
3 changed files with 12 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue