QGtk3Theme: Use GDK X11-specific API only built with X11

And respect xlib config option

Pick-to: 6.4 6.3 6.2
Change-Id: I596097259ed008357e739c3cfe41ab2fc4e18db7
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
Ilya Fedin 2022-07-04 20:36:38 +04:00
parent 6eda4919f2
commit edee40a179
2 changed files with 14 additions and 2 deletions

View File

@ -1,7 +1,10 @@
# Generated from gtk3.pro.
qt_find_package(GTK3) # special case
qt_find_package(X11) # special case
if(QT_FEATURE_xlib)
qt_find_package(X11) # special case
endif()
#####################################################################
## QGtk3ThemePlugin Plugin:
@ -24,6 +27,10 @@ qt_internal_add_plugin(QGtk3ThemePlugin
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
)
qt_internal_extend_target(QGtk3ThemePlugin CONDITION QT_FEATURE_xlib
LIBRARIES
X11::X11 # special case
)

View File

@ -17,9 +17,12 @@
#undef signals
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <pango/pango.h>
#if QT_CONFIG(xlib) && defined(GDK_WINDOWING_X11)
#include <gdk/gdkx.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
@ -105,12 +108,14 @@ bool QGtk3Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWind
GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget);
if (parent) {
#if QT_CONFIG(xlib) && defined(GDK_WINDOWING_X11)
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) {