From dcbf8b5225a08557dd50cfd36f512aad0c4d44dd Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 16 May 2018 00:36:23 +0200 Subject: [PATCH] qgtkintegration: Make requests for x11 root window work zeal uses these for global key shortcuts. The key shortcuts don't appear to work, but at least we no longer crash with X protocol errors. Reported-by: Donald Carr --- src/platform-plugin/platform-plugin.pro | 2 +- src/platform-plugin/qgtkintegration.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/platform-plugin/platform-plugin.pro b/src/platform-plugin/platform-plugin.pro index 781a4cc..67c3d08 100644 --- a/src/platform-plugin/platform-plugin.pro +++ b/src/platform-plugin/platform-plugin.pro @@ -69,7 +69,7 @@ QT += gtkextras CONFIG += qpa/genericunixfontdatabase -LIBS += -lX11-xcb +LIBS += -lX11-xcb -lxcb CONFIG += link_pkgconfig PKGCONFIG_PRIVATE += gdk-3.0 gtk+-3.0 libnotify diff --git a/src/platform-plugin/qgtkintegration.cpp b/src/platform-plugin/qgtkintegration.cpp index ceb5dc1..e4f8247 100644 --- a/src/platform-plugin/qgtkintegration.cpp +++ b/src/platform-plugin/qgtkintegration.cpp @@ -287,6 +287,25 @@ void *QGtkIntegration::nativeResourceForScreen(const QByteArray &resource, QScre } result = reinterpret_cast(type + 1); + } else if (resource == "rootwindow") { +#ifdef GDK_WINDOWING_X11 + static bool rootwin_warned = false; + if (!rootwin_warned) { + qWarning() << "X root window requested; this is experimental, and may not work well."; + rootwin_warned = true; + } + Display *dpy = nullptr; + if (GDK_IS_X11_DISPLAY(m_display)) { + dpy = gdk_x11_display_get_xdisplay(m_display); + xcb_connection_t *conn = XGetXCBConnection(dpy); + + // use the first screen... hopefully this is okay? sigh... + xcb_screen_t *screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data; + result = reinterpret_cast(screen->root); + } else { + qWarning() << "Can't get root X window, GDK_BACKEND is not X11."; + } +#endif } else { qWarning() << "Unimplemented request for " << resource << " on " << screen; }