diff options
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfswindow.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfswindow.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 28ce8c8a33..bf6e375ac0 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -42,6 +42,8 @@ #include "qeglfswindow.h" #include "qeglfshooks.h" #include <qpa/qwindowsysteminterface.h> +#include <qpa/qplatformintegration.h> +#include <private/qguiapplication_p.h> #include <QtPlatformSupport/private/qeglconvenience_p.h> @@ -66,6 +68,11 @@ QEglFSWindow::~QEglFSWindow() destroy(); } +static inline bool supportsMultipleWindows() +{ + return QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::MultipleWindows); +} + void QEglFSWindow::create() { if (has_window) @@ -80,6 +87,9 @@ void QEglFSWindow::create() return; } + if (!supportsMultipleWindows() && screen()->primarySurface()) + return; + EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display(); QSurfaceFormat platformFormat = QEglFSHooks::hooks()->surfaceFormatFor(window()->requestedFormat()); m_config = QEglFSIntegration::chooseConfig(display, platformFormat); @@ -105,11 +115,14 @@ void QEglFSWindow::resetSurface() m_window = QEglFSHooks::hooks()->createNativeWindow(QEglFSHooks::hooks()->screenSize(), m_format); has_window = true; m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL); + if (m_surface == EGL_NO_SURFACE) { EGLint error = eglGetError(); eglTerminate(display); qFatal("EGL Error : Could not create the egl surface: error = 0x%x\n", error); } + + screen()->setPrimarySurface(m_surface); } void QEglFSWindow::destroy() @@ -117,6 +130,12 @@ void QEglFSWindow::destroy() if (m_surface) { EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display(); eglDestroySurface(display, m_surface); + + if (!supportsMultipleWindows()) { + // ours must be the primary surface + screen()->setPrimarySurface(0); + } + m_surface = 0; } @@ -145,9 +164,21 @@ WId QEglFSWindow::winId() const return WId(m_window); } +EGLSurface QEglFSWindow::surface() const +{ + if (!supportsMultipleWindows()) + return screen()->primarySurface(); + return m_surface; +} + QSurfaceFormat QEglFSWindow::format() const { return m_format; } +QEglFSScreen *QEglFSWindow::screen() const +{ + return static_cast<QEglFSScreen *>(QPlatformWindow::screen()); +} + QT_END_NAMESPACE |