Get output position and scale from output device interface
Summary: Let the data saved in OutputDeviceInterface be the single source of truth and as low hanging fruits first do this for global position and scale. Test Plan: Nested Wayland, Drm, virtual backends tested. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Maniphest Tasks: T11459 Differential Revision: https://phabricator.kde.org/D23489
This commit is contained in:
parent
0bcfb4d609
commit
819609a8a6
2 changed files with 21 additions and 13 deletions
|
@ -54,7 +54,12 @@ QString AbstractWaylandOutput::name() const
|
|||
|
||||
QRect AbstractWaylandOutput::geometry() const
|
||||
{
|
||||
return QRect(m_globalPos, pixelSize() / scale());
|
||||
// TODO: This is inefficient on current KWayland since
|
||||
// we loop over modes.
|
||||
// const QSize size = m_waylandOutputDevice->pixelSize();
|
||||
const QSize size = pixelSize();
|
||||
|
||||
return QRect(globalPos(), size / scale());
|
||||
}
|
||||
|
||||
QSize AbstractWaylandOutput::physicalSize() const
|
||||
|
@ -70,9 +75,13 @@ int AbstractWaylandOutput::refreshRate() const
|
|||
return m_waylandOutput->refreshRate();
|
||||
}
|
||||
|
||||
QPoint AbstractWaylandOutput::globalPos() const
|
||||
{
|
||||
return m_waylandOutputDevice->globalPosition();
|
||||
}
|
||||
|
||||
void AbstractWaylandOutput::setGlobalPos(const QPoint &pos)
|
||||
{
|
||||
m_globalPos = pos;
|
||||
m_waylandOutputDevice->setGlobalPosition(pos);
|
||||
|
||||
if (m_waylandOutput) {
|
||||
|
@ -84,9 +93,13 @@ void AbstractWaylandOutput::setGlobalPos(const QPoint &pos)
|
|||
}
|
||||
}
|
||||
|
||||
qreal AbstractWaylandOutput::scale() const
|
||||
{
|
||||
return m_waylandOutputDevice->scaleF();
|
||||
}
|
||||
|
||||
void AbstractWaylandOutput::setScale(qreal scale)
|
||||
{
|
||||
m_scale = scale;
|
||||
m_waylandOutputDevice->setScaleF(scale);
|
||||
|
||||
if (m_waylandOutput) {
|
||||
|
@ -99,7 +112,7 @@ void AbstractWaylandOutput::setScale(qreal scale)
|
|||
m_waylandOutput->setScale(std::ceil(scale));
|
||||
}
|
||||
if (m_xdgOutput) {
|
||||
m_xdgOutput->setLogicalSize(pixelSize() / m_scale);
|
||||
m_xdgOutput->setLogicalSize(pixelSize() / scale);
|
||||
m_xdgOutput->done();
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +185,7 @@ void AbstractWaylandOutput::createXdgOutput()
|
|||
}
|
||||
m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, m_waylandOutput);
|
||||
m_xdgOutput->setLogicalSize(pixelSize() / scale());
|
||||
m_xdgOutput->setLogicalPosition(m_globalPos);
|
||||
m_xdgOutput->setLogicalPosition(globalPos());
|
||||
m_xdgOutput->done();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,9 +65,8 @@ public:
|
|||
}
|
||||
|
||||
virtual QSize pixelSize() const = 0;
|
||||
qreal scale() const override {
|
||||
return m_scale;
|
||||
}
|
||||
qreal scale() const override;
|
||||
|
||||
/**
|
||||
* The geometry of this output in global compositor co-ordinates (i.e scaled)
|
||||
*/
|
||||
|
@ -125,9 +124,7 @@ protected:
|
|||
return m_waylandOutputDevice;
|
||||
}
|
||||
|
||||
QPoint globalPos() const {
|
||||
return m_globalPos;
|
||||
}
|
||||
QPoint globalPos() const;
|
||||
|
||||
QSize rawPhysicalSize() const {
|
||||
return m_physicalSize;
|
||||
|
@ -169,8 +166,6 @@ private:
|
|||
|
||||
KWayland::Server::OutputInterface::DpmsMode m_dpms = KWayland::Server::OutputInterface::DpmsMode::On;
|
||||
|
||||
QPoint m_globalPos;
|
||||
qreal m_scale = 1;
|
||||
QSize m_physicalSize;
|
||||
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
|
||||
bool m_internal = false;
|
||||
|
|
Loading…
Reference in a new issue