summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2017-01-12 13:54:05 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-01-18 14:48:35 +0000
commita0bc9d0027e5e46d66b7d9b62b04d8c3cac9c82f (patch)
tree3b53de2428067a1896b84ec3c8806b6bde46ad9b /src/platformsupport
parent8c144298439a6537adc0d67ca03382a305484deb (diff)
DRM/KMS config: add support for specifying the primary screen
Not having a way to say that a given output should be registered as the primary screen (meaning it comes first in the QGuiApplication::screens() list, emits primaryScreenChanged() signal etc.) can be a problem for some systems. The order of the outputs array in the JSON configuration file is not relevant in this respect since screens are registered either in the original DRM connector order, or, when the virtual desktop layout is specified via virtualIndex, in the order specified by virtualIndex. The primary screen status is independent from this. Therefore, add a new, optional boolean property: primary. For example, the following forces the QScreen corresponding to the VGA output to be the primary screen on the Renesas R-Car H2 board, even though by default it is the HDMI one that happens to be reported first by the system. { "device": "/dev/dri/card0", "outputs": [ { "name": "HDMI1", "mode": "1280x720" }, { "name": "VGA1", "mode": "1280x720", "primary": true }, { "name": "LVDS1", "mode": "off" } ] } In addition, improve the quality of the logging output. [ChangeLog][Platform Specific Changes] Added support for specifying the primary screen in the JSON config file in QT_QPA_EGLFS_KMS_CONFIG when running on DRM/KMS with eglfs. Task-number: QTBUG-57980 Change-Id: Iba490800dee3b7162c68c4d40b0822f3f6d81b69 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/kmsconvenience/qkmsdevice.cpp23
-rw-r--r--src/platformsupport/kmsconvenience/qkmsdevice_p.h4
2 files changed, 20 insertions, 7 deletions
diff --git a/src/platformsupport/kmsconvenience/qkmsdevice.cpp b/src/platformsupport/kmsconvenience/qkmsdevice.cpp
index 319c7f3d9b..669abab331 100644
--- a/src/platformsupport/kmsconvenience/qkmsdevice.cpp
+++ b/src/platformsupport/kmsconvenience/qkmsdevice.cpp
@@ -204,6 +204,8 @@ QPlatformScreen *QKmsDevice::createScreenForConnector(drmModeResPtr resources,
if (vposComp.count() == 2)
vinfo->virtualPos = QPoint(vposComp[0].trimmed().toInt(), vposComp[1].trimmed().toInt());
}
+ if (userConnectorConfig.value(QStringLiteral("primary")).toBool())
+ vinfo->isPrimary = true;
}
const uint32_t crtc_id = resources->crtcs[crtc];
@@ -413,8 +415,11 @@ struct OrderedScreen
QDebug operator<<(QDebug dbg, const OrderedScreen &s)
{
QDebugStateSaver saver(dbg);
- dbg.nospace() << "OrderedScreen(" << s.screen << " : " << s.vinfo.virtualIndex
- << " / " << s.vinfo.virtualPos << ")";
+ dbg.nospace() << "OrderedScreen(QPlatformScreen=" << s.screen << " (" << s.screen->name() << ") : "
+ << s.vinfo.virtualIndex
+ << " / " << s.vinfo.virtualPos
+ << " / primary: " << s.vinfo.isPrimary
+ << ")";
return dbg;
}
@@ -461,13 +466,15 @@ void QKmsDevice::createScreens()
drmModeFreeResources(resources);
- // Use stable sort to preserve the original order for outputs with unspecified indices.
+ // Use stable sort to preserve the original (DRM connector) order
+ // for outputs with unspecified indices.
std::stable_sort(screens.begin(), screens.end(), orderedScreenLessThan);
qCDebug(qLcKmsDebug) << "Sorted screen list:" << screens;
QPoint pos(0, 0);
QList<QPlatformScreen *> siblings;
QVector<QPoint> virtualPositions;
+ int primarySiblingIdx = -1;
for (const OrderedScreen &orderedScreen : screens) {
QPlatformScreen *s = orderedScreen.screen;
@@ -482,22 +489,26 @@ void QKmsDevice::createScreens()
} else {
virtualPos = orderedScreen.vinfo.virtualPos;
}
- qCDebug(qLcKmsDebug) << "Adding screen" << s << "to QPA with geometry" << s->geometry();
+ qCDebug(qLcKmsDebug) << "Adding QPlatformScren" << s << "(" << s->name() << ")"
+ << "to QPA with geometry" << s->geometry()
+ << "and isPrimary=" << orderedScreen.vinfo.isPrimary;
// The order in qguiapp's screens list will match the order set by
// virtualIndex. This is not only handy but also required since for instance
// evdevtouch relies on it when performing touch device - screen mapping.
if (!m_screenConfig->separateScreens()) {
siblings.append(s);
virtualPositions.append(virtualPos);
+ if (orderedScreen.vinfo.isPrimary)
+ primarySiblingIdx = siblings.count() - 1;
} else {
- registerScreen(s, virtualPos, QList<QPlatformScreen *>() << s);
+ registerScreen(s, orderedScreen.vinfo.isPrimary, virtualPos, QList<QPlatformScreen *>() << s);
}
}
if (!m_screenConfig->separateScreens()) {
// enable the virtual desktop
for (int i = 0; i < siblings.count(); ++i)
- registerScreen(siblings[i], virtualPositions[i], siblings);
+ registerScreen(siblings[i], i == primarySiblingIdx, virtualPositions[i], siblings);
}
}
diff --git a/src/platformsupport/kmsconvenience/qkmsdevice_p.h b/src/platformsupport/kmsconvenience/qkmsdevice_p.h
index c41448bc99..35a51c18b1 100644
--- a/src/platformsupport/kmsconvenience/qkmsdevice_p.h
+++ b/src/platformsupport/kmsconvenience/qkmsdevice_p.h
@@ -120,9 +120,10 @@ class QKmsDevice
{
public:
struct VirtualDesktopInfo {
- VirtualDesktopInfo() : virtualIndex(0) { }
+ VirtualDesktopInfo() : virtualIndex(0), isPrimary(false) { }
int virtualIndex;
QPoint virtualPos;
+ bool isPrimary;
};
QKmsDevice(QKmsScreenConfig *screenConfig, const QString &path = QString());
@@ -142,6 +143,7 @@ public:
protected:
virtual QPlatformScreen *createScreen(const QKmsOutput &output) = 0;
virtual void registerScreen(QPlatformScreen *screen,
+ bool isPrimary,
const QPoint &virtualPos,
const QList<QPlatformScreen *> &virtualSiblings) = 0;