diff options
author | Jean-Michaƫl Celerier <jeanmichael.celerier@gmail.com> | 2024-07-08 05:17:23 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-07-11 19:41:00 -0400 |
commit | 35804e3346e687f01cbdd22738a46af6a38b43da (patch) | |
tree | d9c86d44d76b67f9d59cb8749473a61d1569effb /src | |
parent | b050405c4912d29ea518cd7eea23e892be918e47 (diff) | |
download | suil-35804e3346e687f01cbdd22738a46af6a38b43da.tar.gz suil-35804e3346e687f01cbdd22738a46af6a38b43da.tar.bz2 suil-35804e3346e687f01cbdd22738a46af6a38b43da.zip |
Add support for X11 in Qt6
Diffstat (limited to 'src')
-rw-r--r-- | src/instance.c | 10 | ||||
-rw-r--r-- | src/x11_in_qt.cpp (renamed from src/x11_in_qt5.cpp) | 27 |
2 files changed, 31 insertions, 6 deletions
diff --git a/src/instance.c b/src/instance.c index 441176c..496155c 100644 --- a/src/instance.c +++ b/src/instance.c @@ -17,6 +17,7 @@ #define GTK2_UI_URI LV2_UI__GtkUI #define GTK3_UI_URI LV2_UI__Gtk3UI #define QT5_UI_URI LV2_UI__Qt5UI +#define QT6_UI_URI LV2_UI_PREFIX "Qt6UI" #define X11_UI_URI LV2_UI__X11UI #define WIN_UI_URI LV2_UI_PREFIX "WindowsUI" #define COCOA_UI_URI LV2_UI__CocoaUI @@ -43,7 +44,9 @@ suil_ui_supported(const char* host_type_uri, const char* ui_type_uri) !strcmp(ui_type_uri, X11_UI_URI)) || (!strcmp(host_type_uri, QT5_UI_URI) && (!strcmp(ui_type_uri, COCOA_UI_URI) || - !strcmp(ui_type_uri, X11_UI_URI)))) { + !strcmp(ui_type_uri, X11_UI_URI))) || + (!strcmp(host_type_uri, QT6_UI_URI) && + (!strcmp(ui_type_uri, X11_UI_URI)))) { return SUIL_WRAPPING_EMBEDDED; } @@ -84,6 +87,11 @@ open_wrapper(SuilHost* host, module_name = "suil_x11_in_qt5"; } + if (!strcmp(container_type_uri, QT6_UI_URI) && + !strcmp(ui_type_uri, X11_UI_URI)) { + module_name = "suil_x11_in_qt6"; + } + if (!strcmp(container_type_uri, QT5_UI_URI) && !strcmp(ui_type_uri, COCOA_UI_URI)) { module_name = "suil_cocoa_in_qt5"; diff --git a/src/x11_in_qt5.cpp b/src/x11_in_qt.cpp index 7e3d6ac..fcf96ab 100644 --- a/src/x11_in_qt5.cpp +++ b/src/x11_in_qt.cpp @@ -14,19 +14,36 @@ SUIL_DISABLE_QT_WARNINGS #include <QSize> #include <QTimerEvent> #include <QWidget> -#include <QX11Info> #include <Qt> +#include <QtGlobal> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/Xutil.h> +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +# include <QX11Info> +#else +# include <QGuiApplication> +#endif SUIL_RESTORE_WARNINGS +// IWYU pragma: no_include <qguiapplication_platform.h> + #include <cstdlib> #undef signals namespace { +inline Display* +getX11Display() +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + return QX11Info::display(); +#else + return qApp->nativeInterface<QNativeInterface::QX11Application>()->display(); +#endif +} + class SuilQX11Widget : public QWidget { public: @@ -58,7 +75,7 @@ public: { if (_window) { XWindowAttributes attrs{}; - XGetWindowAttributes(QX11Info::display(), _window, &attrs); + XGetWindowAttributes(getX11Display(), _window, &attrs); return {attrs.width, attrs.height}; } @@ -70,7 +87,7 @@ public: if (_window) { XSizeHints hints{}; long supplied{}; - XGetWMNormalHints(QX11Info::display(), _window, &hints, &supplied); + XGetWMNormalHints(getX11Display(), _window, &hints, &supplied); if ((hints.flags & PMinSize)) { return {hints.min_width, hints.min_height}; } @@ -85,7 +102,7 @@ protected: QWidget::resizeEvent(event); if (_window) { - XResizeWindow(QX11Info::display(), + XResizeWindow(getX11Display(), _window, static_cast<unsigned>(event->size().width()), static_cast<unsigned>(event->size().height())); @@ -141,7 +158,7 @@ wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance) auto* const impl = static_cast<SuilX11InQt5Wrapper*>(wrapper->impl); SuilQX11Widget* const ew = impl->parent; - Display* const display = QX11Info::display(); + Display* const display = getX11Display(); const auto window = reinterpret_cast<Window>(instance->ui_widget); XWindowAttributes attrs{}; |