[drm] Better support for multiple outputs in DrmScreens

We get the DrmOutputs from the backend to properly set count, size and
geometry of the outputs.

Dynamic changes are not yet supported.
This commit is contained in:
Martin Gräßlin 2015-04-17 11:13:31 +02:00
parent 6d6c951402
commit fcc895180b
3 changed files with 36 additions and 9 deletions

View file

@ -420,6 +420,11 @@ QSize DrmOutput::size() const
return QSize(m_mode.hdisplay, m_mode.vdisplay);
}
QRect DrmOutput::geometry() const
{
return QRect(m_globalPos, size());
}
bool DrmOutput::present(DrmBuffer *buffer)
{
if (!buffer || buffer->bufferId() == 0) {

View file

@ -58,6 +58,9 @@ public:
int fd() const {
return m_fd;
}
QVector<DrmOutput*> outputs() const {
return m_outputs;
}
Q_SIGNALS:
void screensQueried();
@ -98,6 +101,7 @@ public:
void blank();
QSize size() const;
QRect geometry() const;
private:
friend class DrmBackend;

View file

@ -40,29 +40,47 @@ void DrmScreens::init()
QRect DrmScreens::geometry(int screen) const
{
if (screen == 0) {
return QRect(QPoint(0, 0), size(screen));
const auto outputs = m_backend->outputs();
if (screen >= outputs.size()) {
return QRect();
}
return QRect();
return outputs.at(screen)->geometry();
}
QSize DrmScreens::size(int screen) const
{
if (screen == 0) {
return m_backend->size();
const auto outputs = m_backend->outputs();
if (screen >= outputs.size()) {
return QSize();
}
return QSize();
return outputs.at(screen)->size();
}
void DrmScreens::updateCount()
{
setCount(1);
setCount(m_backend->outputs().size());
}
int DrmScreens::number(const QPoint &pos) const
{
Q_UNUSED(pos)
return 0;
int bestScreen = 0;
int minDistance = INT_MAX;
const auto outputs = m_backend->outputs();
for (int i = 0; i < outputs.size(); ++i) {
const QRect &geo = outputs.at(i)->geometry();
if (geo.contains(pos)) {
return i;
}
int distance = QPoint(geo.topLeft() - pos).manhattanLength();
distance = qMin(distance, QPoint(geo.topRight() - pos).manhattanLength());
distance = qMin(distance, QPoint(geo.bottomRight() - pos).manhattanLength());
distance = qMin(distance, QPoint(geo.bottomLeft() - pos).manhattanLength());
if (distance < minDistance) {
minDistance = distance;
bestScreen = i;
}
}
return bestScreen;
}
}