summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfshooks_stub.cpp')
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks_stub.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
index 0fd22e1757..d09423ec72 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
@@ -48,6 +48,11 @@
QT_BEGIN_NAMESPACE
+const char *QEglFSHooks::fbDeviceName() const
+{
+ return "/dev/fb0";
+}
+
void QEglFSHooks::platformInit()
{
Q_UNUSED(hooks);
@@ -62,6 +67,39 @@ EGLNativeDisplayType QEglFSHooks::platformDisplay() const
return EGL_DEFAULT_DISPLAY;
}
+QSizeF QEglFSHooks::physicalScreenSize() const
+{
+ static QSizeF size;
+ if (size.isEmpty()) {
+
+ // Note: in millimeters
+ int width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt();
+ int height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt();
+
+ if (width && height) {
+ // no need to read fb0
+ size.setWidth(width);
+ size.setHeight(height);
+ return size;
+ }
+
+ struct fb_var_screeninfo vinfo;
+ int fd = open(fbDeviceName(), O_RDONLY);
+
+ if (fd != -1) {
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1)
+ qWarning("Could not query variable screen info.");
+ else
+ size = QSizeF(vinfo.width, vinfo.height);
+
+ close(fd);
+ } else {
+ qWarning("Failed to open %s to detect screen size.", fbDeviceName());
+ }
+ }
+ return size;
+}
+
QSize QEglFSHooks::screenSize() const
{
static QSize size;
@@ -78,7 +116,7 @@ QSize QEglFSHooks::screenSize() const
}
struct fb_var_screeninfo vinfo;
- int fd = open("/dev/fb0", O_RDONLY);
+ int fd = open(fbDeviceName(), O_RDONLY);
if (fd != -1) {
if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1)
@@ -88,7 +126,7 @@ QSize QEglFSHooks::screenSize() const
close(fd);
} else {
- qWarning("Failed to open /dev/fb0 to detect screen resolution.");
+ qWarning("Failed to open %s to detect screen depth.", fbDeviceName());
}
// override fb0 from environment var setting
@@ -107,7 +145,7 @@ int QEglFSHooks::screenDepth() const
if (depth == 0) {
struct fb_var_screeninfo vinfo;
- int fd = open("/dev/fb0", O_RDONLY);
+ int fd = open(fbDeviceName(), O_RDONLY);
if (fd != -1) {
if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1)
@@ -117,7 +155,7 @@ int QEglFSHooks::screenDepth() const
close(fd);
} else {
- qWarning("Failed to open /dev/fb0 to detect screen depth.");
+ qWarning("Failed to open %s to detect screen depth.", fbDeviceName());
}
}