QX11Info::display() and QX11Info::appRootWindow() replacement
-
Hi,
QX11Extras has been removed with Qt 6: https://bugreports.qt.io/browse/QTBUG-83251
Is there a better approach than using private Qt GUI (QPlatformNativeInterface)?This code works, but it depends on private Qt 6 GUI API:
Display *X11Display() { if (!qApp) return nullptr; QPlatformNativeInterface *native = qApp->platformNativeInterface(); if (!native) return nullptr; void *display = native->nativeResourceForIntegration("display"); return reinterpret_cast<Display*>(display); } quint32 AppRootWindow() { if (!qApp) return 0; QPlatformNativeInterface *native = qApp->platformNativeInterface(); if (!native) return 0; QScreen *screen = QGuiApplication::primaryScreen(); if (!screen) return 0; return static_cast<xcb_window_t>(reinterpret_cast<quintptr>(native->nativeResourceForScreen("rootwindow", screen))); }
-
As mentioned by the bug report:
Should just use native APIs. Don't be afraid to mix and match. Qt can't (and shouldn't) do everything, and using Qt with other platform or 3rd party libraries should be possible and easy.
Both those methods just make calls to xlib you can do manually
-
As mentioned by the bug report:
Should just use native APIs. Don't be afraid to mix and match. Qt can't (and shouldn't) do everything, and using Qt with other platform or 3rd party libraries should be possible and easy.
Both those methods just make calls to xlib you can do manually
@VRonin
I need the existing connection, Qt does XOpenDisplay() in this case, how do I get the pointer to that connection?
For the root window I can use DefaultRootWindow() but I still need the connection. -
@VRonin
You can't get the connection, since Qt holds it. But there is a new interface added as of Qt 6.2 to get it, see:
See: https://code.qt.io/cgit/qt/qtbase.git/commit/?id=f5203eeada83bbe8e316a5188e24636af3e83b09