Skip to content

Commit

Permalink
QGtk3Theme: Use GDK X11-specific API only built with X11
Browse files Browse the repository at this point in the history
And respect xlib config option

Pick-to: 6.4 6.3 6.2
Change-Id: I596097259ed008357e739c3cfe41ab2fc4e18db7
Reviewed-by: Dmitry Shachnev <[email protected]>
Reviewed-by: Liang Qi <[email protected]>
  • Loading branch information
ilya-fedin committed Jul 6, 2022
1 parent 6eda491 commit edee40a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/plugins/platformthemes/gtk3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
)

Expand Down
7 changes: 6 additions & 1 deletion src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit edee40a

Please sign in to comment.