eglfs: Add basic support for controlling how the virtual desktop is formed

Choose between horizontal (default) and vertical.

Task-number: QTBUG-55188
Change-Id: Ibc490b0ad8c60b66db785455c57987eb8afdad0d
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2016-08-09 09:16:38 +02:00
parent 7de7f981dc
commit 9ab5c329bf
3 changed files with 34 additions and 5 deletions

View File

@ -373,7 +373,12 @@ void QEglFSKmsDevice::createScreens()
QEglFSKmsScreen *screen = createScreenForConnector(resources, connector, pos); QEglFSKmsScreen *screen = createScreenForConnector(resources, connector, pos);
if (screen) { if (screen) {
integration->addScreen(screen); integration->addScreen(screen);
if (m_integration->virtualDesktopLayout() == QEglFSKmsIntegration::VirtualDesktopLayoutVertical)
pos.ry() += screen->geometry().height();
else
pos.rx() += screen->geometry().width(); pos.rx() += screen->geometry().width();
siblings << screen; siblings << screen;
if (!primaryScreen) if (!primaryScreen)

View File

@ -65,6 +65,7 @@ QEglFSKmsIntegration::QEglFSKmsIntegration()
, m_hwCursor(false) , m_hwCursor(false)
, m_pbuffers(false) , m_pbuffers(false)
, m_separateScreens(false) , m_separateScreens(false)
, m_virtualDesktopLayout(VirtualDesktopLayoutHorizontal)
{} {}
void QEglFSKmsIntegration::platformInit() void QEglFSKmsIntegration::platformInit()
@ -149,6 +150,11 @@ bool QEglFSKmsIntegration::separateScreens() const
return m_separateScreens; return m_separateScreens;
} }
QEglFSKmsIntegration::VirtualDesktopLayout QEglFSKmsIntegration::virtualDesktopLayout() const
{
return m_virtualDesktopLayout;
}
QMap<QString, QVariantMap> QEglFSKmsIntegration::outputSettings() const QMap<QString, QVariantMap> QEglFSKmsIntegration::outputSettings() const
{ {
return m_outputSettings; return m_outputSettings;
@ -169,14 +175,14 @@ void QEglFSKmsIntegration::loadConfig()
QFile file(QString::fromUtf8(json)); QFile file(QString::fromUtf8(json));
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
qCDebug(qLcEglfsKmsDebug) << "Could not open config file" qCWarning(qLcEglfsKmsDebug) << "Could not open config file"
<< json << "for reading"; << json << "for reading";
return; return;
} }
const QJsonDocument doc = QJsonDocument::fromJson(file.readAll()); const QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
if (!doc.isObject()) { if (!doc.isObject()) {
qCDebug(qLcEglfsKmsDebug) << "Invalid config file" << json qCWarning(qLcEglfsKmsDebug) << "Invalid config file" << json
<< "- no top-level JSON object"; << "- no top-level JSON object";
return; return;
} }
@ -188,6 +194,16 @@ void QEglFSKmsIntegration::loadConfig()
m_devicePath = object.value(QLatin1String("device")).toString(); m_devicePath = object.value(QLatin1String("device")).toString();
m_separateScreens = object.value(QLatin1String("separateScreens")).toBool(m_separateScreens); m_separateScreens = object.value(QLatin1String("separateScreens")).toBool(m_separateScreens);
const QString vdOriString = object.value(QLatin1String("virtualDesktopLayout")).toString();
if (!vdOriString.isEmpty()) {
if (vdOriString == QLatin1String("horizontal"))
m_virtualDesktopLayout = VirtualDesktopLayoutHorizontal;
else if (vdOriString == QLatin1String("vertical"))
m_virtualDesktopLayout = VirtualDesktopLayoutVertical;
else
qCWarning(qLcEglfsKmsDebug) << "Unknown virtualDesktop value" << vdOriString;
}
const QJsonArray outputs = object.value(QLatin1String("outputs")).toArray(); const QJsonArray outputs = object.value(QLatin1String("outputs")).toArray();
for (int i = 0; i < outputs.size(); i++) { for (int i = 0; i < outputs.size(); i++) {
const QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap(); const QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap();
@ -207,6 +223,7 @@ void QEglFSKmsIntegration::loadConfig()
<< "\thwcursor:" << m_hwCursor << "\n" << "\thwcursor:" << m_hwCursor << "\n"
<< "\tpbuffers:" << m_pbuffers << "\n" << "\tpbuffers:" << m_pbuffers << "\n"
<< "\tseparateScreens:" << m_separateScreens << "\n" << "\tseparateScreens:" << m_separateScreens << "\n"
<< "\tvirtualDesktopLayout:" << m_virtualDesktopLayout << "\n"
<< "\toutputs:" << m_outputSettings; << "\toutputs:" << m_outputSettings;
} }

View File

@ -56,6 +56,11 @@ Q_EGLFS_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEglFSDeviceIntegration class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEglFSDeviceIntegration
{ {
public: public:
enum VirtualDesktopLayout {
VirtualDesktopLayoutHorizontal,
VirtualDesktopLayoutVertical
};
QEglFSKmsIntegration(); QEglFSKmsIntegration();
void platformInit() Q_DECL_OVERRIDE; void platformInit() Q_DECL_OVERRIDE;
@ -70,6 +75,7 @@ public:
virtual bool hwCursor() const; virtual bool hwCursor() const;
virtual bool separateScreens() const; virtual bool separateScreens() const;
virtual VirtualDesktopLayout virtualDesktopLayout() const;
QMap<QString, QVariantMap> outputSettings() const; QMap<QString, QVariantMap> outputSettings() const;
QEglFSKmsDevice *device() const; QEglFSKmsDevice *device() const;
@ -83,6 +89,7 @@ protected:
bool m_hwCursor; bool m_hwCursor;
bool m_pbuffers; bool m_pbuffers;
bool m_separateScreens; bool m_separateScreens;
VirtualDesktopLayout m_virtualDesktopLayout;
QString m_devicePath; QString m_devicePath;
QMap<QString, QVariantMap> m_outputSettings; QMap<QString, QVariantMap> m_outputSettings;
}; };