eglfs: find correct framebuffer index even if device node is symlink

Using the Vivante driver on a board with different device trees I found the need
to let udev point me to the framebuffer actually connected to HDMI by adding a
symlink. Since the extraction of the framebuffer index failed and always
returned 0 the GUI still always showed up on the first framebuffer.

Change-Id: Ib4aa0fdd6e85d296c17fd977921cbc78e52dcdcf
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
bb10
Rolf Eike Beer 2020-01-17 16:02:31 +01:00
parent 4b875caa6b
commit dd23313d66
1 changed files with 7 additions and 1 deletions

View File

@ -52,6 +52,7 @@
#include <QScreen>
#include <QDir>
#if QT_CONFIG(regularexpression)
# include <QFileInfo>
# include <QRegularExpression>
#endif
#include <QLoggingCategory>
@ -144,7 +145,12 @@ int QEglFSDeviceIntegration::framebufferIndex() const
int fbIndex = 0;
#if QT_CONFIG(regularexpression)
QRegularExpression fbIndexRx(QLatin1String("fb(\\d+)"));
QRegularExpressionMatch match = fbIndexRx.match(QString::fromLocal8Bit(fbDeviceName()));
QFileInfo fbinfo(QString::fromLocal8Bit(fbDeviceName()));
QRegularExpressionMatch match;
if (fbinfo.isSymLink())
match = fbIndexRx.match(fbinfo.symLinkTarget());
else
match = fbIndexRx.match(fbinfo.fileName());
if (match.hasMatch())
fbIndex = match.captured(1).toInt();
#endif