diff options
author | David Robillard <d@drobilla.net> | 2017-03-17 22:32:36 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-03-17 22:32:36 +0100 |
commit | 64a2647d8d81b5c23d22b52cc9e0dd2595270b67 (patch) | |
tree | 0457994c528d45710722c5428ce10c2ae7a1c1d1 | |
parent | 2b4b9d1ceaecf9940c5a28c3e69327059d0017ff (diff) | |
download | suil-64a2647d8d81b5c23d22b52cc9e0dd2595270b67.tar.gz suil-64a2647d8d81b5c23d22b52cc9e0dd2595270b67.tar.bz2 suil-64a2647d8d81b5c23d22b52cc9e0dd2595270b67.zip |
Remove X11 hackery and use Qt5 facilities to embed Gtk
-rw-r--r-- | src/qt5_in_gtk2.cpp | 58 | ||||
-rw-r--r-- | wscript | 8 |
2 files changed, 7 insertions, 59 deletions
diff --git a/src/qt5_in_gtk2.cpp b/src/qt5_in_gtk2.cpp index 48704c9..0823afc 100644 --- a/src/qt5_in_gtk2.cpp +++ b/src/qt5_in_gtk2.cpp @@ -17,12 +17,9 @@ #include <gtk/gtk.h> #include <QApplication> -#include <QMouseEvent> #include <QVBoxLayout> #include <QWidget> #include <QWindow> -#include <QX11Info> -#include <X11/Xlib.h> #include "./suil_internal.h" @@ -34,55 +31,11 @@ extern "C" { typedef struct _SuilQtWrapper SuilQtWrapper; typedef struct _SuilQtWrapperClass SuilQtWrapperClass; -class EmbedWidget : public QWidget -{ -public: - EmbedWidget() - : QWidget() - , display(QX11Info::display()) - , wid(winId()) - {} - - WId id() const { return wid; } - -protected: - bool eventFilter(QObject*, QEvent* ev) { - if (wid == 0 || !display) { - return false; - } - - if (ev->type() == QEvent::Enter || - ev->type() == QEvent::WindowActivate) { - const Window root = XRootWindow(display, 0); - int x, y; - Window child; - XTranslateCoordinates(display, wid, root, 0, 0, &x, &y, &child); - - XWindowAttributes attrs; - XGetWindowAttributes(display, wid, &attrs); - - const QPoint p = QPoint(x - attrs.x, y - attrs.y); - if (p != pos) { - pos = p; - move(pos); - XMoveWindow(display, wid, 0, 0); - } - } - - return false; - } - -private: - Display* display; - QPoint pos; - WId wid; -}; - struct _SuilQtWrapper { GtkSocket socket; QApplication* app; - EmbedWidget* qembed; + QWidget* qembed; SuilWrapper* wrapper; SuilInstance* instance; }; @@ -136,8 +89,10 @@ suil_qt_wrapper_realize(GtkWidget* w, gpointer data) { SuilQtWrapper* const wrap = SUIL_QT_WRAPPER(w); GtkSocket* const s = GTK_SOCKET(w); + const WId id = gtk_socket_get_id(s); - gtk_socket_add_id(s, wrap->qembed->id()); + wrap->qembed->winId(); + wrap->qembed->windowHandle()->setParent(QWindow::fromWinId(id)); wrap->qembed->show(); } @@ -146,17 +101,14 @@ wrapper_wrap(SuilWrapper* wrapper, SuilInstance* instance) { SuilQtWrapper* const wrap = SUIL_QT_WRAPPER(wrapper->impl); - wrap->qembed = new EmbedWidget(); + wrap->qembed = new QWidget(); wrap->wrapper = wrapper; wrap->instance = instance; - wrap->qembed->setAttribute(Qt::WA_LayoutUsesWidgetRect); - QWidget* qwidget = (QWidget*)instance->ui_widget; QVBoxLayout* layout = new QVBoxLayout(wrap->qembed); layout->addWidget(qwidget); - qwidget->installEventFilter(wrap->qembed); qwidget->setParent(wrap->qembed); g_signal_connect_after(G_OBJECT(wrap), "realize", @@ -95,8 +95,6 @@ def configure(conf): if not Options.options.no_qt5: autowaf.check_pkg(conf, 'Qt5Widgets', uselib_store='QT5', atleast_version='5.1.0', mandatory=False) - autowaf.check_pkg(conf, 'Qt5X11Extras', uselib_store='QT5_X11', - atleast_version='5.1.0', mandatory=False) conf.check_cc(define_name = 'HAVE_LIBDL', lib = 'dl', @@ -115,8 +113,6 @@ def configure(conf): if conf.env.HAVE_GTK2 and conf.env.HAVE_QT5: autowaf.define(conf, 'SUIL_WITH_GTK2_IN_QT5', 1) - - if conf.env.HAVE_GTK2 and conf.env.HAVE_QT5_X11: autowaf.define(conf, 'SUIL_WITH_QT5_IN_GTK2', 1) if conf.env.HAVE_GTK2 and conf.env.HAVE_GTK2_X11: @@ -276,9 +272,9 @@ def build(bld): defines = ['SUIL_SHARED', 'SUIL_INTERNAL'], install_path = module_dir, cxxflags = cflags, - lib = modlib + ['X11'], + lib = modlib, linkflags = bld.env.NODELETE_FLAGS) - autowaf.use_lib(bld, obj, 'GTK2 QT5 QT5_X11 LV2') + autowaf.use_lib(bld, obj, 'GTK2 QT5 LV2') if bld.env.SUIL_WITH_X11_IN_GTK2: obj = bld(features = 'c cshlib', |