diff options
author | Inho Lee <[email protected]> | 2024-10-07 13:38:16 +0200 |
---|---|---|
committer | Inho Lee <[email protected]> | 2024-11-21 11:35:58 +0000 |
commit | 39bcd4287a6146e6deba9c6a9fdb70298deed427 (patch) | |
tree | a5b420722800ff59422d2a11923d2a808acf92cf | |
parent | e54d4eabbeab3c010bc9367259d870bc1eeeadf7 (diff) |
eglfs: change the condition to destroy the openglcompositor
With an openglcompositor, only first QEglFSWindow is set
with a flag, HasNativeWindow and when it is destroyed,
the openglcompositor is destroyed, too.
For now, when using openglcompositor, Qt will not check
HasNativeWindow for its nativeWindow because it is not
possible to add a HasNativeWindow flag in an existing
window. And the openglcompositor will be destroyed after
the all the QEglFSWindows are closed.
Fixes: QTBUG-129576
Pick-to: 6.8 6.5
Change-Id: I620a904a03d29e8db1738d9392f716b3ebf5b553
Reviewed-by: Laszlo Agocs <[email protected]>
-rw-r--r-- | src/opengl/qopenglcompositor.cpp | 6 | ||||
-rw-r--r-- | src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 38 |
2 files changed, 28 insertions, 16 deletions
diff --git a/src/opengl/qopenglcompositor.cpp b/src/opengl/qopenglcompositor.cpp index 3c5b1df9055..da6230e2241 100644 --- a/src/opengl/qopenglcompositor.cpp +++ b/src/opengl/qopenglcompositor.cpp @@ -273,9 +273,9 @@ void QOpenGLCompositor::addWindow(QOpenGLCompositorWindow *window) void QOpenGLCompositor::removeWindow(QOpenGLCompositorWindow *window) { - m_windows.removeOne(window); - if (!m_windows.isEmpty()) - emit topWindowChanged(m_windows.last()); + bool couldChangeTopWindow = (m_windows.size() > 1) ? (window == m_windows.constLast()) : false; + if (m_windows.removeOne(window) && couldChangeTopWindow) + emit topWindowChanged(m_windows.constLast()); } void QOpenGLCompositor::moveToTop(QOpenGLCompositorWindow *window) diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index bb9076634da..1e8c1a963e9 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -129,29 +129,42 @@ void QEglFSWindow::destroy() if (!m_flags.testFlag(Created)) return; // already destroyed -#ifndef QT_NO_OPENGL - QOpenGLCompositor::instance()->removeWindow(this); -#endif - QEglFSScreen *screen = this->screen(); - if (m_flags.testFlag(HasNativeWindow)) { #ifndef QT_NO_OPENGL + QOpenGLCompositor *compositor = QOpenGLCompositor::instance(); + compositor->removeWindow(this); + if (compositor->targetWindow() == window()) { QEglFSCursor *cursor = qobject_cast<QEglFSCursor *>(screen->cursor()); if (cursor) cursor->resetResources(); -#endif + if (screen->primarySurface() == m_surface) screen->setPrimarySurface(EGL_NO_SURFACE); invalidateSurface(); -#ifndef QT_NO_OPENGL - QOpenGLCompositor::destroy(); - if (qt_gl_global_share_context() == m_rasterCompositingContext) - qt_gl_set_global_share_context(nullptr); - delete m_rasterCompositingContext; -#endif + if (compositor->windows().isEmpty()) { + compositor->destroy(); + if (qt_gl_global_share_context() == m_rasterCompositingContext) + qt_gl_set_global_share_context(nullptr); + delete m_rasterCompositingContext; + } else { + auto topWindow = static_cast<QEglFSWindow *>(compositor->windows().last()); + // Make fullscreen + topWindow->setGeometry(screen->rawGeometry()); + topWindow->resetSurface(); + screen->setPrimarySurface(topWindow->surface()); + compositor->setTargetWindow(topWindow->sourceWindow(), screen->rawGeometry()); + } + } +#else + if (m_flags.testFlag(HasNativeWindow)) { + if (screen->primarySurface() == m_surface) + screen->setPrimarySurface(EGL_NO_SURFACE); + + invalidateSurface(); } +#endif m_flags = { }; } @@ -179,7 +192,6 @@ void QEglFSWindow::invalidateSurface() if (screen()->primarySurface() == m_surface) screen()->setPrimarySurface(EGL_NO_SURFACE); - m_surface = EGL_NO_SURFACE; m_flags = m_flags & ~Created; } |