summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIlya Fedin <fedin-ilja2010@ya.ru>2022-07-27 00:02:04 +0400
committerIlya Fedin <fedin-ilja2010@ya.ru>2022-08-19 02:15:02 +0400
commitb5457082bb6ae1b321e8bbe69237e8d3f4ed934a (patch)
tree990bb074749879a7a94dddbdf13268ec5d81e764 /src
parent6a3509baa20ba049b84a7774a9b270bb81748148 (diff)
QGtk3Theme: Support setting dialog parent on Wayland
This adds support for setting parent window for GTK dialogs on Wayland using the new API added for portals Change-Id: I29085c926ce4338ff2ad75728d566ec843d3aa5a Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
index ce8e2ff756..24fea73dd2 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
@@ -12,6 +12,8 @@
#include <qfileinfo.h>
#include <private/qguiapplication_p.h>
+#include <private/qgenericunixservices_p.h>
+#include <qpa/qplatformintegration.h>
#include <qpa/qplatformfontdatabase.h>
#undef signals
@@ -23,6 +25,10 @@
#include <gdk/gdkx.h>
#endif
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
+
// The size of the preview we display for selected image files. We set height
// larger than width because generally there is more free space vertically
// than horizontally (setting the preview image will always expand the width of
@@ -98,14 +104,27 @@ bool QGtk3Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWind
GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget);
if (parent) {
+ if (false) {
+#if defined(GDK_WINDOWING_WAYLAND) && GTK_CHECK_VERSION(3, 22, 0)
+ } else if (GDK_IS_WAYLAND_WINDOW(gdkWindow)) {
+ const auto unixServices = dynamic_cast<QGenericUnixServices *>(
+ QGuiApplicationPrivate::platformIntegration()->services());
+ if (unixServices) {
+ const auto handle = unixServices->portalWindowIdentifier(parent);
+ if (handle.startsWith("wayland:"_L1)) {
+ auto handleBa = handle.sliced(8).toUtf8();
+ gdk_wayland_window_set_transient_for_exported(gdkWindow, handleBa.data());
+ }
+ }
+#endif
#if QT_CONFIG(xlib) && defined(GDK_WINDOWING_X11)
- if (GDK_IS_X11_WINDOW(gdkWindow)) {
+ } else if (GDK_IS_X11_WINDOW(gdkWindow)) {
GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow);
XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay),
gdk_x11_window_get_xid(gdkWindow),
parent->winId());
- }
#endif
+ }
}
if (modality != Qt::NonModal) {