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>bb10
parent
6a3509baa2
commit
b5457082bb
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue