Add physicalSize to the Screens API
Summary: Allows to share the implementation in a better way and is a requirement to get the Screen implementation in the QPA plugin to be based on KWin::Screens instead of KWayland::Output. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D8344
This commit is contained in:
parent
c2d4cb8846
commit
02d3daf28a
11 changed files with 47 additions and 3 deletions
|
@ -243,6 +243,7 @@ bool DrmOutput::init(drmModeConnector *connector)
|
|||
qCWarning(KWIN_DRM) << "Overwriting monitor physical size for" << m_edid.eisaId << "/" << m_edid.monitorName << "/" << m_edid.serialNumber << " from " << physicalSize << "to " << overwriteSize;
|
||||
physicalSize = overwriteSize;
|
||||
}
|
||||
m_physicalSize = physicalSize;
|
||||
m_waylandOutput->setPhysicalSize(physicalSize);
|
||||
m_waylandOutputDevice->setPhysicalSize(physicalSize);
|
||||
|
||||
|
|
|
@ -103,6 +103,10 @@ public:
|
|||
return m_uuid;
|
||||
}
|
||||
|
||||
QSize physicalSize() const {
|
||||
return m_physicalSize;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void dpmsChanged();
|
||||
|
||||
|
@ -159,6 +163,7 @@ private:
|
|||
bool m_pageFlipPending = false;
|
||||
bool m_dpmsAtomicOffPending = false;
|
||||
bool m_modesetRequested = true;
|
||||
QSize m_physicalSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -113,4 +113,13 @@ float DrmScreens::refreshRate(int screen) const
|
|||
return outputs.at(screen)->currentRefreshRate() / 1000.0f;
|
||||
}
|
||||
|
||||
QSizeF DrmScreens::physicalSize(int screen) const
|
||||
{
|
||||
const auto outputs = m_backend->outputs();
|
||||
if (screen >= outputs.size()) {
|
||||
return Screens::physicalSize(screen);
|
||||
}
|
||||
return outputs.at(screen)->physicalSize();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
QString name(int screen) const override;
|
||||
float refreshRate(int screen) const override;
|
||||
|
||||
QSizeF physicalSize(int screen) const override;
|
||||
|
||||
private:
|
||||
DrmBackend *m_backend;
|
||||
};
|
||||
|
|
|
@ -194,8 +194,9 @@ static KWayland::Server::OutputInterface *createOutput(hwc_composer_device_1_t *
|
|||
|
||||
if (attr_values[2] != 0 && attr_values[3] != 0) {
|
||||
static const qreal factor = 25.4;
|
||||
o->setPhysicalSize(QSizeF(qreal(pixel.width() * 1000) / qreal(attr_values[2]) * factor,
|
||||
qreal(pixel.height() * 1000) / qreal(attr_values[3]) * factor).toSize());
|
||||
m_physicalSize = QSizeF(qreal(pixel.width() * 1000) / qreal(attr_values[2]) * factor,
|
||||
qreal(pixel.height() * 1000) / qreal(attr_values[3]) * factor);
|
||||
o->setPhysicalSize(m_physicalSize.toSize());
|
||||
} else {
|
||||
// couldn't read physical size, assume 96 dpi
|
||||
o->setPhysicalSize(pixel / 3.8);
|
||||
|
|
|
@ -85,6 +85,9 @@ public:
|
|||
QVector<CompositingType> supportedCompositors() const override {
|
||||
return QVector<CompositingType>{OpenGLCompositing};
|
||||
}
|
||||
QSizeF physicalSize() const {
|
||||
return m_physicalSize;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void outputBlankChanged();
|
||||
|
@ -110,6 +113,7 @@ private:
|
|||
QMutex m_vsyncMutex;
|
||||
QWaitCondition m_vsyncWaitCondition;
|
||||
QScopedPointer<BacklightInputEventFilter> m_filter;
|
||||
QSizeF m_physicalSize;
|
||||
};
|
||||
|
||||
class HwcomposerWindow : public HWComposerNativeWindow
|
||||
|
|
|
@ -37,4 +37,13 @@ float HwcomposerScreens::refreshRate(int screen) const
|
|||
return m_backend->refreshRate() / 1000.0f;
|
||||
}
|
||||
|
||||
QSizeF HwcomposerScreens::physicalSize(int screen) const
|
||||
{
|
||||
const QSizeF size = m_backend->physicalSize();
|
||||
if (size.isValid()) {
|
||||
return size;
|
||||
}
|
||||
return Screens::physicalSize(screen);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
HwcomposerScreens(HwcomposerBackend *backend, QObject *parent = nullptr);
|
||||
virtual ~HwcomposerScreens();
|
||||
float refreshRate(int screen) const override;
|
||||
QSizeF physicalSize(int screen) const override;
|
||||
|
||||
private:
|
||||
HwcomposerBackend *m_backend;
|
||||
|
|
|
@ -190,6 +190,11 @@ QSize Screens::displaySize() const
|
|||
return size();
|
||||
}
|
||||
|
||||
QSizeF Screens::physicalSize(int screen) const
|
||||
{
|
||||
return QSizeF(size(screen)) / 3.8;
|
||||
}
|
||||
|
||||
BasicScreens::BasicScreens(Platform *backend, QObject *parent)
|
||||
: Screens(parent)
|
||||
, m_backend(backend)
|
||||
|
|
|
@ -117,6 +117,13 @@ public:
|
|||
**/
|
||||
virtual QSize displaySize() const;
|
||||
|
||||
|
||||
/**
|
||||
* The physical size of @p screen in mm.
|
||||
* Default implementation returns a size derived from 96 DPI.
|
||||
**/
|
||||
virtual QSizeF physicalSize(int screen) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void reconfigure();
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@ void WaylandServer::syncOutputsToWayland()
|
|||
output->setScale(s->scale(i));
|
||||
const QRect &geo = s->geometry(i);
|
||||
output->setGlobalPosition(geo.topLeft());
|
||||
output->setPhysicalSize(geo.size() / 3.8);
|
||||
output->setPhysicalSize(s->physicalSize(i).toSize());
|
||||
output->addMode(geo.size());
|
||||
output->create();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue