summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michaƫl Celerier <jeanmichael.celerier@gmail.com>2024-07-08 05:17:23 -0400
committerDavid Robillard <d@drobilla.net>2024-07-11 19:41:00 -0400
commit35804e3346e687f01cbdd22738a46af6a38b43da (patch)
treed9c86d44d76b67f9d59cb8749473a61d1569effb
parentb050405c4912d29ea518cd7eea23e892be918e47 (diff)
downloadsuil-35804e3346e687f01cbdd22738a46af6a38b43da.tar.gz
suil-35804e3346e687f01cbdd22738a46af6a38b43da.tar.bz2
suil-35804e3346e687f01cbdd22738a46af6a38b43da.zip
Add support for X11 in Qt6
-rw-r--r--.includes.imp3
-rw-r--r--NEWS3
-rw-r--r--meson.build24
-rw-r--r--meson_options.txt3
-rw-r--r--src/instance.c10
-rw-r--r--src/x11_in_qt.cpp (renamed from src/x11_in_qt5.cpp)27
6 files changed, 61 insertions, 9 deletions
diff --git a/.includes.imp b/.includes.imp
index 5f8981a..8ee5ce4 100644
--- a/.includes.imp
+++ b/.includes.imp
@@ -1,4 +1,7 @@
[
+ { "symbol": [ "QT_VERSION", "private", "<QtGlobal>", "public" ] },
+ { "symbol": [ "QT_VERSION_CHECK", "private", "<QtGlobal>", "public" ] },
+ { "symbol": [ "QX11Application", "private", "<QGuiApplication>", "public" ] },
{ "symbol": [ "QX11Info", "private", "<QX11Info>", "public" ] },
{ "symbol": [ "WId", "private", "<QtGui>", "public" ] }
]
diff --git a/NEWS b/NEWS
index 6425f79..e19ae3d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,9 @@
suil (0.10.21) unstable; urgency=medium
+ * Add support for X11 in Qt6
* Fix library current_version on MacOS
- -- David Robillard <d@drobilla.net> Thu, 14 Mar 2024 16:54:56 +0000
+ -- David Robillard <d@drobilla.net> Thu, 11 Jul 2024 23:40:43 +0000
suil (0.10.20) stable; urgency=medium
diff --git a/meson.build b/meson.build
index 3089ce8..29c8467 100644
--- a/meson.build
+++ b/meson.build
@@ -8,7 +8,7 @@ project(
'b_ndebug=if-release',
'buildtype=release',
'c_std=c99',
- 'cpp_std=c++14',
+ 'cpp_std=c++17',
],
license: 'ISC',
meson_version: '>= 0.56.0',
@@ -124,6 +124,13 @@ qt5_x11_dep = dependency(
required: get_option('qt5').enabled() and get_option('x11').enabled(),
)
+qt6_dep = dependency(
+ 'Qt6Widgets',
+ include_type: 'system',
+ version: '>=6.2.0',
+ required: get_option('qt6'),
+)
+
if host_machine.system() == 'darwin' and not get_option('cocoa').disabled()
objcpp.has_header(
'QMacCocoaViewContainer',
@@ -279,7 +286,7 @@ endif
if qt5_dep.found() and qt5_x11_dep.found()
shared_module(
'suil_x11_in_qt5',
- files('src/x11_in_qt5.cpp'),
+ files('src/x11_in_qt.cpp'),
cpp_args: cpp_suppressions + platform_defines,
dependencies: [lv2_dep, qt5_dep, qt5_x11_dep],
gnu_symbol_visibility: 'hidden',
@@ -308,6 +315,19 @@ if host_machine.system() == 'darwin'
endif
endif
+if qt6_dep.found()
+ shared_module(
+ 'suil_x11_in_qt6',
+ files('src/x11_in_qt.cpp'),
+ cpp_args: cpp_suppressions + platform_defines,
+ dependencies: [lv2_dep, qt6_dep],
+ gnu_symbol_visibility: 'hidden',
+ include_directories: include_dirs,
+ install: true,
+ install_dir: suil_module_dir,
+ )
+endif
+
#########
# Tests #
#########
diff --git a/meson_options.txt b/meson_options.txt
index b468923..44e2ce7 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -19,6 +19,9 @@ option('html', type: 'feature', value: 'auto', yield: true,
option('qt5', type: 'feature', value: 'auto', yield: true,
description : 'Build Qt5 wrappers')
+option('qt6', type: 'feature', value: 'auto', yield: true,
+ description : 'Build Qt6 wrappers')
+
option('singlehtml', type: 'feature', value: 'auto', yield: true,
description: 'Build single-page HTML documentation')
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{};