Custom Wayland extensions/protocols in Qt clients
-
Hello, I would like to know if its possible to implement custom Wayland extensions in a Qt client? Or at least a way to get access to the wl_display handle? I've searched with no luck, and I think it would be very useful.
-
Hi, and welcome!
@ehopperdietzel said in Custom Wayland extensions/protocols in Qt clients:
I would like to know if its possible to implement custom Wayland extensions in a Qt client?
Are these what you're looking for?
-
Hi @JKSH ! Thanks for the reply ! Sadly thats not what I am looking for, the links you provided are for implementing custom Wayland extensions in Qt compositors, or custom client shells. What I need is to implement custom extensions but in a client application (not shells). And that would be possible if I could get access to the wl_display used by the client. I think maybe QGuiApplication::QNativeInterface() could return a handle to wl_display when using the wayland or wayland-egl platform plugin, but not sure since the documentation doesn't say that. I'll check it out.
-
@ehopperdietzel said in Custom Wayland extensions/protocols in Qt clients:
I think maybe QGuiApplication::QNativeInterface() could return a handle to wl_display when using the wayland or wayland-egl platform plugin, but not sure since the documentation doesn't say that. I'll check it out.
You're definitely on the right track! I believe you want to call
QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_display");
on the Wayland platform.You can examine the source code here:
- https://code.woboq.org/qt6/qtbase/src/gui/kernel/qguiapplication.cpp.html#_ZN15QGuiApplication23platformNativeInterfaceEv
- https://code.woboq.org/qt6/qtwayland/src/client/qwaylandnativeinterface.cpp.html#_ZN15QtWaylandClient23QWaylandNativeInterface28nativeResourceForIntegrationERK10QByteArray
- https://code.woboq.org/qt6/qtwayland/src/client/qwaylanddisplay_p.h.html#QtWaylandClient::wl_display
-
OMG ! I tested it and it works !! Thank you so so much !! ❤️ @JKSH
The QPlatformNativeInterface class is defined here if someone wondered:
#include <QtGui/6.2.4/QtGui/qpa/qplatformnativeinterface.h>
Of course you should replace 6.2.4 with the version you're using.
-
That's great news, @ehopperdietzel !
Just note that this is all private API, so there is a small risk that it might break in a future version of Qt.
-
@ehopperdietzel said in Custom Wayland extensions/protocols in Qt clients:
#include <QtGui/6.2.4/QtGui/qpa/qplatformnativeinterface.h>
Of course you should replace 6.2.4 with the version you're using.
A somewhat more portable way is:
- Add the "gui-private" module to your project (e.g.
QT += gui-private
in your .pro file) - Write
#include <qpa/qplatformnativeinterface.h>
- Add the "gui-private" module to your project (e.g.