Skip to content

Commit

Permalink
eglfs: change the condition to destroy the openglcompositor
Browse files Browse the repository at this point in the history
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 <laszlo.agocs@qt.io>
  • Loading branch information
Inho Lee committed Nov 21, 2024
1 parent e54d4ea commit 39bcd42
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/opengl/qopenglcompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 25 additions & 13 deletions src/plugins/platforms/eglfs/api/qeglfswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { };
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 39bcd42

Please sign in to comment.