summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Redondo <qt@david-redondo.de>2023-07-10 11:25:01 +0200
committerDavid Redondo <qt@david-redondo.de>2024-03-27 13:43:55 +0100
commit75bbefcdf70bb688a264fa69827af554b186aff7 (patch)
treec8d81c01139f53956d015c93563b1bcef2b66c95
parent6a94e1fc24687fadb6a14cf4f43c948e9505fbaa (diff)
client: Implement dialog-v1 protocol
Allows to mark windows as modal dialogs. Change-Id: Ie4999552933e02fc473e621e7cc5e3f2928c0adb Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r--src/3rdparty/protocol/qt_attribution.json17
-rw-r--r--src/3rdparty/protocol/xdg-dialog-v1.xml110
-rw-r--r--src/plugins/shellintegration/xdg-shell/CMakeLists.txt2
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1.cpp33
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h32
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp20
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h4
-rw-r--r--tests/auto/client/shared/CMakeLists.txt3
-rw-r--r--tests/auto/client/shared/mockcompositor.cpp1
-rw-r--r--tests/auto/client/shared/mockcompositor.h2
-rw-r--r--tests/auto/client/shared/xdgdialog.cpp59
-rw-r--r--tests/auto/client/shared/xdgdialog.h49
-rw-r--r--tests/auto/client/xdgshell/tst_xdgshell.cpp36
13 files changed, 363 insertions, 5 deletions
diff --git a/src/3rdparty/protocol/qt_attribution.json b/src/3rdparty/protocol/qt_attribution.json
index 33a4f17c4..6ced46a2b 100644
--- a/src/3rdparty/protocol/qt_attribution.json
+++ b/src/3rdparty/protocol/qt_attribution.json
@@ -336,5 +336,22 @@
"License": "MIT License",
"LicenseFile": "MIT_LICENSE.txt",
"Copyright": "Copyright © 2022 Kenny Levinsen"
+ },
+
+ {
+ "Id": "xdg-dialog-v1",
+ "Name": "Wayland Dialog Protocol",
+ "QDocModule": "qtwaylandcompositor",
+ "QtUsage": "Used in the Qt Wayland platform plugin",
+ "Files": "xdg-dialog-v1.xml",
+
+ "Description": "Register toplevel as dialogs",
+ "Homepage": "https://wayland.freedesktop.org",
+ "Version": "1",
+ "DownloadLocation": "",
+ "LicenseId": "MIT",
+ "License": "MIT License",
+ "LicenseFile": "MIT_LICENSE.txt",
+ "Copyright": "Copyright © 2023 Carlos Garnacho"
}
]
diff --git a/src/3rdparty/protocol/xdg-dialog-v1.xml b/src/3rdparty/protocol/xdg-dialog-v1.xml
new file mode 100644
index 000000000..ed2141132
--- /dev/null
+++ b/src/3rdparty/protocol/xdg-dialog-v1.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="dialog_v1">
+ <copyright>
+ Copyright © 2023 Carlos Garnacho
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice (including the next
+ paragraph) shall be included in all copies or substantial portions of the
+ Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ </copyright>
+
+ <interface name="xdg_wm_dialog_v1" version="1">
+ <description summary="create dialogs related to other toplevels">
+ The xdg_wm_dialog_v1 interface is exposed as a global object allowing
+ to register surfaces with a xdg_toplevel role as "dialogs" relative to
+ another toplevel.
+
+ The compositor may let this relation influence how the surface is
+ placed, displayed or interacted with.
+
+ Warning! The protocol described in this file is currently in the testing
+ phase. Backward compatible changes may be added together with the
+ corresponding interface version bump. Backward incompatible changes can
+ only be done by creating a new major version of the extension.
+ </description>
+
+ <enum name="error">
+ <entry name="already_used" value="0"
+ summary="the xdg_toplevel object has already been used to create a xdg_dialog_v1"/>
+ </enum>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the dialog manager object">
+ Destroys the xdg_wm_dialog_v1 object. This does not affect
+ the xdg_dialog_v1 objects generated through it.
+ </description>
+ </request>
+
+ <request name="get_xdg_dialog">
+ <description summary="create a dialog object">
+ Creates a xdg_dialog_v1 object for the given toplevel. See the interface
+ description for more details.
+
+ Compositors must raise an already_used error if clients attempt to
+ create multiple xdg_dialog_v1 objects for the same xdg_toplevel.
+ </description>
+ <arg name="id" type="new_id" interface="xdg_dialog_v1"/>
+ <arg name="toplevel" type="object" interface="xdg_toplevel"/>
+ </request>
+ </interface>
+
+ <interface name="xdg_dialog_v1" version="1">
+ <description summary="dialog object">
+ A xdg_dialog_v1 object is an ancillary object tied to a xdg_toplevel. Its
+ purpose is hinting the compositor that the toplevel is a "dialog" (e.g. a
+ temporary window) relative to another toplevel (see
+ xdg_toplevel.set_parent). If the xdg_toplevel is destroyed, the xdg_dialog_v1
+ becomes inert.
+
+ Through this object, the client may provide additional hints about
+ the purpose of the secondary toplevel. This interface has no effect
+ on toplevels that are not attached to a parent toplevel.
+ </description>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy the dialog object">
+ Destroys the xdg_dialog_v1 object. If this object is destroyed
+ before the related xdg_toplevel, the compositor should unapply its
+ effects.
+ </description>
+ </request>
+
+ <request name="set_modal">
+ <description summary="mark dialog as modal">
+ Hints that the dialog has "modal" behavior. Modal dialogs typically
+ require to be fully addressed by the user (i.e. closed) before resuming
+ interaction with the parent toplevel, and may require a distinct
+ presentation.
+
+ Clients must implement the logic to filter events in the parent
+ toplevel on their own.
+
+ Compositors may choose any policy in event delivery to the parent
+ toplevel, from delivering all events unfiltered to using them for
+ internal consumption.
+ </description>
+ </request>
+
+ <request name="unset_modal">
+ <description summary="mark dialog as not modal">
+ Drops the hint that this dialog has "modal" behavior. See
+ xdg_dialog_v1.set_modal for more details.
+ </description>
+ </request>
+ </interface>
+</protocol>
diff --git a/src/plugins/shellintegration/xdg-shell/CMakeLists.txt b/src/plugins/shellintegration/xdg-shell/CMakeLists.txt
index a33a28a7e..af5a97fee 100644
--- a/src/plugins/shellintegration/xdg-shell/CMakeLists.txt
+++ b/src/plugins/shellintegration/xdg-shell/CMakeLists.txt
@@ -17,6 +17,7 @@ qt_internal_add_plugin(QWaylandXdgShellIntegrationPlugin
qwaylandxdgshell.cpp qwaylandxdgshell_p.h
qwaylandxdgshellintegration.cpp qwaylandxdgshellintegration_p.h
qwaylandxdgexporterv2.cpp qwaylandxdgexporterv2_p.h
+ qwaylandxdgdialogv1.cpp qwaylandxdgdialogv1_p.h
LIBRARIES
Qt::Core
Qt::Gui
@@ -31,6 +32,7 @@ qt6_generate_wayland_protocol_client_sources(QWaylandXdgShellIntegrationPlugin
${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-shell.xml
${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-activation-v1.xml
${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-foreign-unstable-v2.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-dialog-v1.xml
)
#### Keys ignored in scope 1:.:.:xdg-shell.pro:<TRUE>:
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1.cpp
new file mode 100644
index 000000000..abf674623
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1.cpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2023 David Reondo <kde@david-redondo.de>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qwaylandxdgdialogv1_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+QWaylandXdgDialogV1::QWaylandXdgDialogV1(::xdg_dialog_v1 *object) : xdg_dialog_v1(object) { }
+
+QWaylandXdgDialogV1::~QWaylandXdgDialogV1()
+{
+ xdg_dialog_v1_destroy(object());
+}
+
+QWaylandXdgDialogWmV1::QWaylandXdgDialogWmV1(wl_registry *registry, uint32_t id, int version)
+ : xdg_wm_dialog_v1(registry, id, version)
+{
+}
+
+QWaylandXdgDialogWmV1::~QWaylandXdgDialogWmV1()
+{
+ destroy();
+}
+QWaylandXdgDialogV1 *QWaylandXdgDialogWmV1::getDialog(xdg_toplevel *toplevel)
+{
+ return new QWaylandXdgDialogV1(get_xdg_dialog(toplevel));
+}
+
+} // namespace QtWaylandClient
+
+QT_END_NAMESPACE
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h
new file mode 100644
index 000000000..f5465a63e
--- /dev/null
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h
@@ -0,0 +1,32 @@
+// Copyright (C) 2022 David Reondo <kde@david-redondo.de>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QWAYLANDDIALOGV1_P_H
+#define QWAYLANDDIALOGV1_P_H
+
+#include <qwayland-xdg-dialog-v1.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWaylandClient {
+
+class QWaylandXdgDialogV1 : public QtWayland::xdg_dialog_v1
+{
+public:
+ QWaylandXdgDialogV1(::xdg_dialog_v1 *object);
+ ~QWaylandXdgDialogV1() override;
+};
+
+class QWaylandXdgDialogWmV1 : public QtWayland::xdg_wm_dialog_v1
+{
+public:
+ QWaylandXdgDialogWmV1(wl_registry *registry, uint32_t id, int version);
+ ~QWaylandXdgDialogWmV1() override;
+ QWaylandXdgDialogV1 *getDialog(xdg_toplevel *toplevel);
+};
+
+} // namespace QtWaylandClient
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index 498710beb..d338f7475 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -6,6 +6,7 @@
#include "qwaylandxdgshell_p.h"
#include "qwaylandxdgexporterv2_p.h"
+#include "qwaylandxdgdialogv1_p.h"
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
@@ -32,6 +33,16 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
}
requestWindowStates(window->windowStates());
requestWindowFlags(window->flags());
+ if (auto transientParent = xdgSurface->window()->transientParent()) {
+ if (auto parentSurface =
+ qobject_cast<QWaylandXdgSurface *>(transientParent->shellSurface())) {
+ 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();
+ }
+ }
+ }
}
QWaylandXdgSurface::Toplevel::~Toplevel()
@@ -296,11 +307,6 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s
setGrabPopup(transientParent, display->lastInputDevice(), display->lastInputSerial());
} else {
setToplevel();
- if (transientParent) {
- auto parentXdgSurface = qobject_cast<QWaylandXdgSurface *>(transientParent->shellSurface());
- if (parentXdgSurface)
- m_toplevel->set_parent(parentXdgSurface->m_toplevel->object());
- }
}
setSizeHints();
}
@@ -752,6 +758,10 @@ void QWaylandXdgShell::handleRegistryGlobal(void *data, wl_registry *registry, u
if (interface == QLatin1String(QWaylandXdgExporterV2::interface()->name)) {
xdgShell->m_xdgExporter.reset(new QWaylandXdgExporterV2(registry, id, version));
}
+
+ if (interface == QLatin1String(QWaylandXdgDialogWmV1::interface()->name)) {
+ xdgShell->m_xdgDialogWm.reset(new QWaylandXdgDialogWmV1(registry, id, version));
+ }
}
}
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
index 0310706fd..22a207a25 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
@@ -39,6 +39,8 @@ class QWaylandInputDevice;
class QWaylandXdgShell;
class QWaylandXdgExportedV2;
class QWaylandXdgExporterV2;
+class QWaylandXdgDialogWmV1;
+class QWaylandXdgDialogV1;
class Q_WAYLANDCLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface, public QtWayland::xdg_surface
{
@@ -109,6 +111,7 @@ private:
QWaylandXdgSurface *m_xdgSurface = nullptr;
QWaylandXdgToplevelDecorationV1 *m_decoration = nullptr;
QScopedPointer<QWaylandXdgExportedV2> m_exported;
+ QScopedPointer<QWaylandXdgDialogV1> m_xdgDialog;
};
class Popup : public QtWayland::xdg_popup {
@@ -171,6 +174,7 @@ private:
QScopedPointer<QWaylandXdgDecorationManagerV1> m_xdgDecorationManager;
QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation;
QScopedPointer<QWaylandXdgExporterV2> m_xdgExporter;
+ QScopedPointer<QWaylandXdgDialogWmV1> m_xdgDialogWm;
friend class QWaylandXdgSurface;
};
diff --git a/tests/auto/client/shared/CMakeLists.txt b/tests/auto/client/shared/CMakeLists.txt
index ee81b4d68..1d64f2956 100644
--- a/tests/auto/client/shared/CMakeLists.txt
+++ b/tests/auto/client/shared/CMakeLists.txt
@@ -16,6 +16,7 @@ qt_manual_moc(moc_files
textinput.h
qttextinput.h
viewport.h
+ xdgdialog.h
xdgoutputv1.h
xdgshell.h
)
@@ -33,6 +34,7 @@ add_library(SharedClientTest
qttextinput.cpp qttextinput.h
xdgoutputv1.cpp xdgoutputv1.h
xdgshell.cpp xdgshell.h
+ xdgdialog.cpp xdgdialog.h
viewport.cpp viewport.h
${moc_files}
)
@@ -50,6 +52,7 @@ qt6_generate_wayland_protocol_server_sources(SharedClientTest
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/viewporter.xml
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/wayland.xml
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/xdg-decoration-unstable-v1.xml
+ ${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/xdg-dialog-v1.xml
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/xdg-output-unstable-v1.xml
${PROJECT_SOURCE_DIR}/src/3rdparty/protocol/xdg-shell.xml
)
diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp
index 571117d6b..d6eb560c9 100644
--- a/tests/auto/client/shared/mockcompositor.cpp
+++ b/tests/auto/client/shared/mockcompositor.cpp
@@ -23,6 +23,7 @@ DefaultCompositor::DefaultCompositor(CompositorType t, int socketFd)
add<XdgWmBase>();
add<FractionalScaleManager>();
add<Viewporter>();
+ add<XdgWmDialog>();
switch (m_type) {
case CompositorType::Default:
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h
index 268f77680..7cde39954 100644
--- a/tests/auto/client/shared/mockcompositor.h
+++ b/tests/auto/client/shared/mockcompositor.h
@@ -13,6 +13,7 @@
#include "xdgshell.h"
#include "viewport.h"
#include "fractionalscalev1.h"
+#include "xdgdialog.h"
#include <QtGui/QGuiApplication>
@@ -50,6 +51,7 @@ public:
IviSurface *iviSurface(int i = 0) { return get<IviApplication>()->m_iviSurfaces.value(i, nullptr); }
FractionalScale *fractionalScale(int i = 0) {return get<FractionalScaleManager>()->m_fractionalScales.value(i, nullptr); }
Viewport *viewport(int i = 0) {return get<Viewporter>()->m_viewports.value(i, nullptr); }
+ XdgDialog *xdgDialog(int i = 0) { return get<XdgWmDialog>()->m_dialogs.value(i, nullptr); }
uint sendXdgShellPing();
void xdgPingAndWaitForPong();
diff --git a/tests/auto/client/shared/xdgdialog.cpp b/tests/auto/client/shared/xdgdialog.cpp
new file mode 100644
index 000000000..065a0fd3c
--- /dev/null
+++ b/tests/auto/client/shared/xdgdialog.cpp
@@ -0,0 +1,59 @@
+// Copyright (C) 2024 David Redondo <kde@david-redondo.de>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#include "xdgdialog.h"
+
+#include "xdgshell.h"
+
+namespace MockCompositor {
+
+XdgDialog::XdgDialog(XdgWmDialog *wm, XdgToplevel *toplevel, wl_client *client, int id, int version)
+ : QtWaylandServer::xdg_dialog_v1(client, id, version),
+ toplevel(toplevel),
+ modal(false),
+ m_wm(wm)
+{
+}
+
+void XdgDialog::xdg_dialog_v1_set_modal(Resource *resource)
+{
+ Q_UNUSED(resource)
+ modal = true;
+}
+
+void XdgDialog::xdg_dialog_v1_unset_modal(Resource *resource)
+{
+ Q_UNUSED(resource)
+ modal = false;
+}
+
+void XdgDialog::xdg_dialog_v1_destroy(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void XdgDialog::xdg_dialog_v1_destroy_resource(Resource *resource)
+{
+ Q_UNUSED(resource)
+ m_wm->m_dialogs.removeOne(this);
+ delete this;
+}
+
+XdgWmDialog::XdgWmDialog(CoreCompositor *compositor, int version)
+ : QtWaylandServer::xdg_wm_dialog_v1(compositor->m_display, version)
+{
+}
+
+void XdgWmDialog::xdg_wm_dialog_v1_destroy(Resource *resource)
+{
+ wl_resource_destroy(resource->handle);
+}
+
+void XdgWmDialog::xdg_wm_dialog_v1_get_xdg_dialog(Resource *resource, uint32_t id,
+ struct ::wl_resource *toplevel)
+{
+ auto *t = fromResource<XdgToplevel>(toplevel);
+ auto *dialog = new XdgDialog(this, t, resource->client(), id, resource->version());
+ m_dialogs.push_back(dialog);
+}
+
+} // namespace MockCompositor
diff --git a/tests/auto/client/shared/xdgdialog.h b/tests/auto/client/shared/xdgdialog.h
new file mode 100644
index 000000000..6b4ccd0bc
--- /dev/null
+++ b/tests/auto/client/shared/xdgdialog.h
@@ -0,0 +1,49 @@
+// Copyright (C) 2024 David Redondo <kde@david-redondo.de>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+#ifndef MOCKCOMPOSITOR_XDG_DIALOG_H
+#define MOCKCOMPOSITOR_XDG_DIALOG_H
+
+#include "corecompositor.h"
+#include <qwayland-server-xdg-dialog-v1.h>
+
+namespace MockCompositor {
+
+class XdgToplevel;
+class XdgWmDialog;
+
+class XdgDialog : public QtWaylandServer::xdg_dialog_v1
+{
+public:
+ explicit XdgDialog(XdgWmDialog *wm, XdgToplevel *toplevel, wl_client *client, int id,
+ int version);
+ XdgToplevel *toplevel;
+ bool modal;
+
+protected:
+ void xdg_dialog_v1_set_modal(Resource *resource) override;
+ void xdg_dialog_v1_unset_modal(Resource *resource) override;
+ void xdg_dialog_v1_destroy(Resource *resource) override;
+ void xdg_dialog_v1_destroy_resource(Resource *resource) override;
+
+private:
+ XdgWmDialog *m_wm;
+};
+
+class XdgWmDialog : public Global, public QtWaylandServer::xdg_wm_dialog_v1
+{
+ Q_OBJECT
+public:
+ explicit XdgWmDialog(CoreCompositor *compositor, int version = 1);
+ ~XdgWmDialog() = default;
+ QList<XdgDialog *> m_dialogs;
+
+protected:
+ void xdg_wm_dialog_v1_destroy(Resource *resource) override;
+ void xdg_wm_dialog_v1_get_xdg_dialog(Resource *resource, uint32_t id,
+ struct ::wl_resource *toplevel) override;
+};
+
+} // namespace MockCompositor
+
+#endif
diff --git a/tests/auto/client/xdgshell/tst_xdgshell.cpp b/tests/auto/client/xdgshell/tst_xdgshell.cpp
index a3e96d444..f222165e9 100644
--- a/tests/auto/client/xdgshell/tst_xdgshell.cpp
+++ b/tests/auto/client/xdgshell/tst_xdgshell.cpp
@@ -34,6 +34,7 @@ private slots:
void nativeResources();
void suspended();
void initiallySuspended();
+ void modality();
};
void tst_xdgshell::init()
@@ -769,5 +770,40 @@ void tst_xdgshell::initiallySuspended()
QVERIFY(!window.isExposed());
}
+void tst_xdgshell::modality()
+{
+ QRasterWindow parent;
+ parent.resize(400, 320);
+ parent.show();
+
+ QRasterWindow child;
+ child.resize(400, 320);
+ child.setTransientParent(&parent);
+ child.show();
+ QCOMPOSITOR_TRY_VERIFY(xdgToplevel(1));
+ 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"