summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-12-11 12:50:31 -0500
committerDavid Robillard <d@drobilla.net>2022-12-11 12:52:25 -0500
commitad39b43b42b25293ef3e72c83c640ff1e315b3dd (patch)
tree48fc0edea9d2d7376a90a8cf2fc5dfb70e190385
parent5a92421ad95a8dc50c509c493b57c31eb57cf58e (diff)
downloadsuil-ad39b43b42b25293ef3e72c83c640ff1e315b3dd.tar.gz
suil-ad39b43b42b25293ef3e72c83c640ff1e315b3dd.tar.bz2
suil-ad39b43b42b25293ef3e72c83c640ff1e315b3dd.zip
Remove Gtk in Qt and Qt in Gtk wrappers
-rw-r--r--NEWS3
-rw-r--r--PACKAGING.md12
-rw-r--r--meson.build39
-rw-r--r--src/gtk2_in_qt5.cpp156
-rw-r--r--src/instance.c21
-rw-r--r--src/qt5_in_gtk.cpp239
6 files changed, 8 insertions, 462 deletions
diff --git a/NEWS b/NEWS
index 4dacc70..811ec96 100644
--- a/NEWS
+++ b/NEWS
@@ -3,8 +3,9 @@ suil (0.10.19) unstable; urgency=medium
* Fix dependencies in pkg-config file
* Override pkg-config dependency within meson
* Replace duplicated dox_to_sphinx script with sphinxygen dependency
+ * Remove Gtk in Qt and Qt in Gtk wrappers
- -- David Robillard <d@drobilla.net> Mon, 05 Dec 2022 00:03:30 +0000
+ -- David Robillard <d@drobilla.net> Sun, 11 Dec 2022 17:52:13 +0000
suil (0.10.18) stable; urgency=medium
diff --git a/PACKAGING.md b/PACKAGING.md
index 4702379..6b0debb 100644
--- a/PACKAGING.md
+++ b/PACKAGING.md
@@ -9,7 +9,7 @@ versions. To facilitate this, the shared library name, include directory, and
pkg-config file are suffixed with the major version number of the library.
Dependencies check for the pkg-config package `suil-0` and will build against a
-compatible version 0, regardless any other installed versions.
+compatible version 0, regardless any other installed major versions.
Packages should follow the same conventions as above, that is, include the
major version (and only the major version) in the name of the package so that
@@ -23,12 +23,12 @@ achieve this, Suil dynamically loads modules for the toolkits in use. The main
Suil library does NOT depend on any toolkit libraries, and its package
shouldn't either (otherwise, for example, every LV2 host in the distribution
would depend directly on Gtk and Qt). Individual modules (like
-`libsuil_gtk2_in_qt5.so`) should be packaged separately and themselves depend
-on the involved toolkits. These packages should also be versioned as described
-above to support parallel installation.
+`libsuil_x11_in_gtk3.so`) should be packaged separately and themselves depend
+on the involved libraries or toolkits. These packages should also be versioned
+as described above to support parallel installation.
Please do not make the main Suil package strongly depend on any toolkit
-package, this defeats the purpose of Suil and will irritate users who want to
-avoid a particular toolkit dependency for whatever reason. "Weak" or
+package, this defeats the purpose of Suil and will cause problems for users who
+need to avoid a particular toolkit dependency for whatever reason. "Weak" or
"recommended" dependencies are fine, the important thing is that users are able
to avoid particular toolkits if they choose.
diff --git a/meson.build b/meson.build
index 7154590..0d3c894 100644
--- a/meson.build
+++ b/meson.build
@@ -206,31 +206,6 @@ endif
gtk_c_args = cc.get_supported_arguments(gtk_args)
gtk_cpp_args = cpp.get_supported_arguments(gtk_args)
-if gtk2_dep.found() and qt5_dep.found()
- shared_module(
- 'suil_gtk2_in_qt5',
- files('src/gtk2_in_qt5.cpp'),
- cpp_args: cpp_suppressions + gtk_cpp_args + platform_defines,
- dependencies: [gtk2_dep, lv2_dep, qt5_dep],
- gnu_symbol_visibility: 'hidden',
- include_directories: include_dirs,
- install: true,
- install_dir: suil_module_dir,
- )
-
- shared_module(
- 'suil_qt5_in_gtk2',
- files('src/qt5_in_gtk.cpp'),
- cpp_args: cpp_suppressions + gtk_cpp_args + platform_defines,
- dependencies: [gtk2_dep, lv2_dep, qt5_dep],
- gnu_symbol_visibility: 'hidden',
- include_directories: include_dirs,
- install: true,
- install_dir: suil_module_dir,
- link_args: nodelete_cpp_link_args,
- )
-endif
-
if gtk2_dep.found() and gtk2_x11_dep.found() and x11_dep.found()
shared_module(
'suil_x11_in_gtk2',
@@ -259,20 +234,6 @@ if gtk3_dep.found() and gtk3_x11_dep.found() and x11_dep.found()
)
endif
-if gtk3_dep.found() and gtk3_x11_dep.found() and qt5_dep.found()
- shared_module(
- 'suil_qt5_in_gtk3',
- files('src/qt5_in_gtk.cpp'),
- cpp_args: cpp_suppressions + gtk_cpp_args + platform_defines,
- dependencies: [gtk3_dep, lv2_dep, qt5_dep],
- gnu_symbol_visibility: 'hidden',
- include_directories: include_dirs,
- install: true,
- install_dir: suil_module_dir,
- link_args: nodelete_cpp_link_args,
- )
-endif
-
if gtk2_dep.found() and gtk2_quartz_dep.found()
shared_module(
'suil_cocoa_in_gtk2',
diff --git a/src/gtk2_in_qt5.cpp b/src/gtk2_in_qt5.cpp
deleted file mode 100644
index 705f119..0000000
--- a/src/gtk2_in_qt5.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 2011-2022 David Robillard <d@drobilla.net>
-// Copyright 2015 Rui Nuno Capela <rncbc@rncbc.org>
-// SPDX-License-Identifier: ISC
-
-#include "dylib.h"
-#include "suil_config.h" // IWYU pragma: keep
-#include "suil_internal.h"
-#include "warnings.h"
-
-#include "lv2/core/lv2.h"
-#include "suil/suil.h"
-
-SUIL_DISABLE_QT_WARNINGS
-#include <QVBoxLayout>
-#include <QWidget>
-#include <QWindow>
-#include <Qt>
-#include <QtGui>
-SUIL_RESTORE_WARNINGS
-
-#undef signals
-
-SUIL_DISABLE_GTK_WARNINGS
-#include <gdk/gdk.h>
-#include <glib-object.h>
-#include <glib.h>
-#include <gobject/gclosure.h>
-#include <gtk/gtk.h>
-SUIL_RESTORE_WARNINGS
-
-#include <cstdlib>
-
-extern "C" {
-
-struct SuilGtk2InQt5Wrapper {
- QWidget* host_widget;
- QWindow* window;
- GtkWidget* plug;
-};
-
-static void
-on_size_request(GtkWidget*, GtkRequisition* requisition, gpointer user_data)
-{
- auto* const wrap = static_cast<QWidget*>(user_data);
- wrap->setMinimumSize(requisition->width, requisition->height);
-}
-
-static void
-on_size_allocate(GtkWidget*, GdkRectangle* allocation, gpointer user_data)
-{
- auto* const wrap = static_cast<QWidget*>(user_data);
- wrap->resize(allocation->width, allocation->height);
-}
-
-static void
-wrapper_free(SuilWrapper* wrapper)
-{
- auto* impl = static_cast<SuilGtk2InQt5Wrapper*>(wrapper->impl);
-
- if (impl->window) {
- impl->window->setParent(nullptr);
- delete impl->window;
- }
-
- if (impl->plug) {
- gtk_widget_destroy(impl->plug);
- }
-
- delete impl->host_widget;
-
- free(impl);
-}
-
-static int
-wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance)
-{
- auto* const impl = static_cast<SuilGtk2InQt5Wrapper*>(wrapper->impl);
- auto* const wrap = new QWidget(nullptr, Qt::Window);
- GtkWidget* const plug = gtk_plug_new(0);
- auto* const widget = static_cast<GtkWidget*>(instance->ui_widget);
-
- gtk_container_add(GTK_CONTAINER(plug), widget);
- gtk_widget_show_all(plug);
-
- const WId wid = (WId)gtk_plug_get_id(GTK_PLUG(plug));
-
- QWindow* window = QWindow::fromWinId(wid);
- QWidget* container =
- QWidget::createWindowContainer(window, wrap, Qt::WindowFlags());
-
- auto* layout = new QVBoxLayout();
- layout->setMargin(0);
- layout->setSpacing(0);
- layout->addWidget(container, 0, Qt::Alignment());
- wrap->setLayout(layout);
-
-#ifdef SUIL_OLD_GTK
- wrap->resize(widget->allocation.width, widget->allocation.height);
-#else
- GtkAllocation alloc;
- gtk_widget_get_allocation(widget, &alloc);
- wrap->resize(alloc.width, alloc.height);
-#endif
-
- g_signal_connect(
- G_OBJECT(plug), "size-request", G_CALLBACK(on_size_request), wrap);
-
- g_signal_connect(
- G_OBJECT(plug), "size-allocate", G_CALLBACK(on_size_allocate), wrap);
-
- impl->host_widget = wrap;
- impl->window = window;
- impl->plug = plug;
- instance->host_widget = wrap;
-
- return 0;
-}
-
-SUIL_LIB_EXPORT
-SuilWrapper*
-suil_wrapper_new(SuilHost* host,
- const char*,
- const char*,
- LV2_Feature***,
- unsigned)
-{
- /* We have to open libgtk here, so Gtk type symbols are present and will be
- found by the introspection stuff. This is required at least to make
- GtkBuilder use in UIs work, otherwise they will cause "Invalid object
- type" errors.
- */
- if (!host->gtk_lib) {
- dylib_error();
- host->gtk_lib = dylib_open(SUIL_GTK2_LIB_NAME, DYLIB_LAZY | DYLIB_GLOBAL);
- if (!host->gtk_lib) {
- SUIL_ERRORF(
- "Failed to open %s (%s)\n", SUIL_GTK2_LIB_NAME, dylib_error());
- return nullptr;
- }
-
- gtk_init(nullptr, nullptr);
- }
-
- /* Create wrapper implementation. */
- auto* const impl =
- static_cast<SuilGtk2InQt5Wrapper*>(calloc(1, sizeof(SuilGtk2InQt5Wrapper)));
-
- auto* wrapper = static_cast<SuilWrapper*>(calloc(1, sizeof(SuilWrapper)));
- wrapper->wrap = wrapper_wrap;
- wrapper->free = wrapper_free;
- wrapper->impl = impl;
-
- return wrapper;
-}
-
-} // extern "C"
diff --git a/src/instance.c b/src/instance.c
index a2e478a..60dfee2 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -36,15 +36,9 @@ suil_ui_supported(const char* host_type_uri, const char* ui_type_uri)
}
if ((!strcmp(host_type_uri, GTK2_UI_URI) &&
- !strcmp(ui_type_uri, QT5_UI_URI)) ||
- (!strcmp(host_type_uri, QT5_UI_URI) &&
- !strcmp(ui_type_uri, GTK2_UI_URI)) ||
- (!strcmp(host_type_uri, GTK2_UI_URI) &&
!strcmp(ui_type_uri, X11_UI_URI)) ||
(!strcmp(host_type_uri, GTK3_UI_URI) &&
!strcmp(ui_type_uri, X11_UI_URI)) ||
- (!strcmp(host_type_uri, GTK3_UI_URI) &&
- !strcmp(ui_type_uri, QT5_UI_URI)) ||
(!strcmp(host_type_uri, GTK2_UI_URI) &&
!strcmp(ui_type_uri, WIN_UI_URI)) ||
(!strcmp(host_type_uri, GTK2_UI_URI) &&
@@ -68,16 +62,6 @@ open_wrapper(SuilHost* host,
{
const char* module_name = NULL;
- if (!strcmp(container_type_uri, QT5_UI_URI) &&
- !strcmp(ui_type_uri, GTK2_UI_URI)) {
- module_name = "suil_gtk2_in_qt5";
- }
-
- if (!strcmp(container_type_uri, GTK2_UI_URI) &&
- !strcmp(ui_type_uri, QT5_UI_URI)) {
- module_name = "suil_qt5_in_gtk2";
- }
-
if (!strcmp(container_type_uri, GTK2_UI_URI) &&
!strcmp(ui_type_uri, X11_UI_URI)) {
module_name = "suil_x11_in_gtk2";
@@ -88,11 +72,6 @@ open_wrapper(SuilHost* host,
module_name = "suil_x11_in_gtk3";
}
- if (!strcmp(container_type_uri, GTK3_UI_URI) &&
- !strcmp(ui_type_uri, QT5_UI_URI)) {
- module_name = "suil_qt5_in_gtk3";
- }
-
if (!strcmp(container_type_uri, GTK2_UI_URI) &&
!strcmp(ui_type_uri, WIN_UI_URI)) {
module_name = "suil_win_in_gtk2";
diff --git a/src/qt5_in_gtk.cpp b/src/qt5_in_gtk.cpp
deleted file mode 100644
index 1b3f31d..0000000
--- a/src/qt5_in_gtk.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-// Copyright 2011-2022 David Robillard <d@drobilla.net>
-// Copyright 2018 Rui Nuno Capela <rncbc@rncbc.org>
-// SPDX-License-Identifier: ISC
-
-#include "suil_internal.h"
-#include "warnings.h"
-
-#include "lv2/core/lv2.h"
-#include "lv2/options/options.h"
-#include "lv2/ui/ui.h"
-#include "lv2/urid/urid.h"
-#include "suil/suil.h"
-
-SUIL_DISABLE_QT_WARNINGS
-#include <QVBoxLayout>
-#include <QWidget>
-#include <QWindow>
-#include <Qt>
-#include <QtGui>
-SUIL_RESTORE_WARNINGS
-
-#undef signals
-
-SUIL_DISABLE_GTK_WARNINGS
-
-#include <glib-object.h>
-#include <glib.h>
-#include <gobject/gclosure.h>
-#include <gtk/gtk.h>
-
-#if GTK_MAJOR_VERSION == 3
-# include <gtk/gtkx.h>
-#endif
-
-SUIL_RESTORE_WARNINGS
-
-#include <cstdlib>
-#include <cstring>
-
-extern "C" {
-
-struct SuilQtWrapper {
- GtkSocket socket;
- QWidget* qembed;
- SuilWrapper* wrapper;
- SuilInstance* instance;
- const LV2UI_Idle_Interface* idle_iface;
- guint idle_id;
- guint idle_ms;
-};
-
-struct SuilQtWrapperClass {
- GtkSocketClass parent_class;
-};
-
-GType
-suil_qt_wrapper_get_type(void); // Accessor for SUIL_TYPE_QT_WRAPPER
-
-#define SUIL_TYPE_QT_WRAPPER (suil_qt_wrapper_get_type())
-#define SUIL_QT_WRAPPER(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), SUIL_TYPE_QT_WRAPPER, SuilQtWrapper))
-
-G_DEFINE_TYPE(SuilQtWrapper, suil_qt_wrapper, GTK_TYPE_SOCKET)
-
-static void
-suil_qt_wrapper_finalize(GObject* gobject)
-{
- SuilQtWrapper* const self = SUIL_QT_WRAPPER(gobject);
-
- if (self->idle_id) {
- g_source_remove(self->idle_id);
- self->idle_id = 0;
- }
-
- if (self->instance->handle) {
- self->instance->descriptor->cleanup(self->instance->handle);
- self->instance->handle = nullptr;
- }
-
- if (self->qembed) {
- self->qembed->deleteLater();
- }
-
- self->qembed = nullptr;
- self->idle_iface = nullptr;
- self->wrapper->impl = nullptr;
-
- G_OBJECT_CLASS(suil_qt_wrapper_parent_class)->finalize(gobject);
-}
-
-static void
-suil_qt_wrapper_class_init(SuilQtWrapperClass* klass)
-{
- GObjectClass* const gobject_class = G_OBJECT_CLASS(klass);
-
- gobject_class->finalize = suil_qt_wrapper_finalize;
-}
-
-static void
-suil_qt_wrapper_init(SuilQtWrapper* self)
-{
- self->qembed = nullptr;
- self->wrapper = nullptr;
- self->instance = nullptr;
- self->idle_iface = nullptr;
- self->idle_id = 0;
- self->idle_ms = 1000 / 30; // 30 Hz default
-}
-
-static void
-suil_qt_wrapper_realize(GtkWidget* w, gpointer)
-{
- SuilQtWrapper* const wrap = SUIL_QT_WRAPPER(w);
- GtkSocket* const s = GTK_SOCKET(w);
- const WId id = (WId)gtk_socket_get_id(s);
-
- wrap->qembed->winId();
- wrap->qembed->windowHandle()->setParent(QWindow::fromWinId(id));
- wrap->qembed->show();
-}
-
-static int
-suil_qt_wrapper_resize(LV2UI_Feature_Handle handle, int width, int height)
-{
- gtk_widget_set_size_request(GTK_WIDGET(handle), width, height);
-
- return 0;
-}
-
-static gboolean
-suil_qt_wrapper_idle(void* data)
-{
- SuilQtWrapper* const wrap = SUIL_QT_WRAPPER(data);
-
- if (wrap->idle_iface) {
- wrap->idle_iface->idle(wrap->instance->handle);
- return TRUE; // Continue calling
- }
-
- return FALSE;
-}
-
-static int
-wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance)
-{
- SuilQtWrapper* const wrap = SUIL_QT_WRAPPER(wrapper->impl);
-
- wrap->qembed = new QWidget(nullptr, Qt::WindowFlags());
- wrap->wrapper = wrapper;
- wrap->instance = instance;
-
- auto* qwidget = static_cast<QWidget*>(instance->ui_widget);
- auto* layout = new QVBoxLayout();
- layout->setMargin(0);
- layout->setSpacing(0);
- layout->addWidget(qwidget, 0, Qt::Alignment());
-
- wrap->qembed->setLayout(layout);
-
- g_signal_connect_after(
- G_OBJECT(wrap), "realize", G_CALLBACK(suil_qt_wrapper_realize), nullptr);
-
- instance->host_widget = GTK_WIDGET(wrap);
-
- const LV2UI_Idle_Interface* idle_iface = nullptr;
- if (instance->descriptor->extension_data) {
- idle_iface = static_cast<const LV2UI_Idle_Interface*>(
- instance->descriptor->extension_data(LV2_UI__idleInterface));
- }
-
- if (idle_iface) {
- wrap->idle_iface = idle_iface;
- wrap->idle_id = g_timeout_add(wrap->idle_ms, suil_qt_wrapper_idle, wrap);
- }
-
- return 0;
-}
-
-static void
-wrapper_free(SuilWrapper* wrapper)
-{
- if (wrapper->impl) {
- SuilQtWrapper* const wrap = SUIL_QT_WRAPPER(wrapper->impl);
- gtk_widget_destroy(GTK_WIDGET(wrap));
- }
-}
-
-SUIL_LIB_EXPORT
-SuilWrapper*
-suil_wrapper_new(SuilHost*,
- const char*,
- const char*,
- LV2_Feature*** features,
- unsigned n_features)
-{
- auto* wrapper = static_cast<SuilWrapper*>(calloc(1, sizeof(SuilWrapper)));
- wrapper->wrap = wrapper_wrap;
- wrapper->free = wrapper_free;
-
- SuilQtWrapper* const wrap =
- SUIL_QT_WRAPPER(g_object_new(SUIL_TYPE_QT_WRAPPER, nullptr));
-
- wrap->wrapper = nullptr;
- wrapper->impl = wrap;
-
- wrapper->resize.handle = wrap;
- wrapper->resize.ui_resize = suil_qt_wrapper_resize;
-
- suil_add_feature(features, &n_features, LV2_UI__resize, &wrapper->resize);
- suil_add_feature(features, &n_features, LV2_UI__idleInterface, nullptr);
-
- // Scan for URID map and options
- LV2_URID_Map* map = nullptr;
- LV2_Options_Option* options = nullptr;
- for (LV2_Feature** f = *features; *f && (!map || !options); ++f) {
- if (!strcmp((*f)->URI, LV2_OPTIONS__options)) {
- options = static_cast<LV2_Options_Option*>((*f)->data);
- } else if (!strcmp((*f)->URI, LV2_URID__map)) {
- map = static_cast<LV2_URID_Map*>((*f)->data);
- }
- }
-
- if (map && options) {
- // Set UI update rate if given
- LV2_URID ui_updateRate = map->map(map->handle, LV2_UI__updateRate);
- for (LV2_Options_Option* o = options; o->key; ++o) {
- if (o->key == ui_updateRate) {
- wrap->idle_ms =
- static_cast<guint>(1000.0f / *static_cast<const float*>(o->value));
-
- break;
- }
- }
- }
-
- return wrapper;
-}
-
-} // extern "C"