QSizeF q_physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize) { #ifndef Q_OS_LINUX Q_UNUSED(framebufferDevice) #endif const int defaultPhysicalDpi = 100; static QSizeF size; if (size.isEmpty()) { // Note: in millimeters int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH"); int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT"); if (width && height) { size.setWidth(width); size.setHeight(height); return size; } int w = -1; int h = -1; QSize screenResolution; #ifdef Q_OS_LINUX struct fb_var_screeninfo vinfo; if (framebufferDevice != -1) { if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) { qWarning("eglconvenience: Could not query screen info"); } else { w = vinfo.width; h = vinfo.height; screenResolution = QSize(vinfo.xres, vinfo.yres); } } else #endif { // Use the provided screen size, when available, since some platforms may have their own // specific way to query it. Otherwise try querying it from the framebuffer. screenResolution = screenSize.isEmpty() ? q_screenSizeFromFb(framebufferDevice) : screenSize; } size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w)); size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h)); if (w <= 0 || h <= 0) qWarning("Unable to query physical screen size, defaulting to %d dpi.\n" "To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH " "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi); } return size; }
QSize QEGLDeviceIntegration::screenSize() const { return q_screenSizeFromFb(framebuffer); }
QSize QEglFSHooks::screenSize() const { return q_screenSizeFromFb(framebuffer); }