QWaylandXdgSurface: Always use XDG Dialog for modal windows
Even when it doesn't have a transient parent Qt knows about. The surface might get a parent assigned externally through XDG Foreign. Change-Id: I21dbfd00aa0ff78e26ce4c111fe260f18b9dc905 Reviewed-by: David Redondo <qt@david-redondo.de> Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
b964195096
commit
4468b53645
@ -36,13 +36,14 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
|
||||
requestWindowFlags(window->flags());
|
||||
if (auto transientParent = xdgSurface->window()->transientParent()) {
|
||||
auto parentSurface = qobject_cast<QWaylandXdgSurface *>(transientParent->shellSurface());
|
||||
if (parentSurface && parentSurface->m_toplevel) {
|
||||
if (parentSurface && parentSurface->m_toplevel)
|
||||
set_parent(parentSurface->m_toplevel->object());
|
||||
if (window->modality() != Qt::NonModal && m_xdgSurface->m_shell->m_xdgDialogWm) {
|
||||
m_xdgDialog.reset(m_xdgSurface->m_shell->m_xdgDialogWm->getDialog(object()));
|
||||
m_xdgDialog->set_modal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Always use XDG Dialog, a window could be assigned a parent through XDG Foreign.
|
||||
if (window->modality() != Qt::NonModal && m_xdgSurface->m_shell->m_xdgDialogWm) {
|
||||
m_xdgDialog.reset(m_xdgSurface->m_shell->m_xdgDialogWm->getDialog(object()));
|
||||
m_xdgDialog->set_modal();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ private slots:
|
||||
void suspended();
|
||||
void initiallySuspended();
|
||||
void modality();
|
||||
void modalityWithoutTransientParent();
|
||||
};
|
||||
|
||||
void tst_xdgshell::init()
|
||||
@ -823,5 +824,35 @@ void tst_xdgshell::modality()
|
||||
QCOMPOSITOR_TRY_VERIFY(!xdgDialog());
|
||||
}
|
||||
|
||||
void tst_xdgshell::modalityWithoutTransientParent()
|
||||
{
|
||||
QRasterWindow child;
|
||||
child.resize(400, 320);
|
||||
child.show();
|
||||
QCOMPOSITOR_TRY_VERIFY(xdgToplevel());
|
||||
QCOMPOSITOR_VERIFY(!xdgDialog());
|
||||
|
||||
child.hide();
|
||||
child.setModality(Qt::WindowModal);
|
||||
child.show();
|
||||
QCOMPOSITOR_TRY_VERIFY(xdgDialog());
|
||||
QCOMPOSITOR_VERIFY(xdgDialog()->modal);
|
||||
|
||||
child.hide();
|
||||
QCOMPOSITOR_TRY_VERIFY(!xdgDialog());
|
||||
|
||||
child.setModality(Qt::ApplicationModal);
|
||||
child.show();
|
||||
QCOMPOSITOR_TRY_VERIFY(xdgDialog());
|
||||
QCOMPOSITOR_VERIFY(xdgDialog()->modal);
|
||||
|
||||
child.hide();
|
||||
QCOMPOSITOR_TRY_VERIFY(!xdgDialog());
|
||||
|
||||
child.show();
|
||||
child.setModality(Qt::NonModal);
|
||||
QCOMPOSITOR_TRY_VERIFY(!xdgDialog());
|
||||
}
|
||||
|
||||
QCOMPOSITOR_TEST_MAIN(tst_xdgshell)
|
||||
#include "tst_xdgshell.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user