clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit a618ebfd1017f556b1a8badf71b81e0c29aeeeea
parent ba535ad72edc6e3e2e6d6e1abdb63d8744ded2b0
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Fri, 27 Aug 2021 13:24:19 +0200

Some work for osx and win32

Diffstat:
Mexamples/gui/application.cc | 42++++++++++++++++++++++++++++++++++++++----
Mexamples/io/messages.hh | 6++++++
Mexamples/plugins/remote-gui.cc | 6++++--
3 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/examples/gui/application.cc b/examples/gui/application.cc @@ -8,7 +8,7 @@ #include "../io/messages.hh" #include "application.hh" -Application::Application(int& argc, char **argv) +Application::Application(int &argc, char **argv) : QGuiApplication(argc, argv), quickView_(new QQuickView()) { bool waitForDebbugger = false; @@ -49,8 +49,7 @@ Application::Application(int& argc, char **argv) &QSocketNotifier::activated, [this](QSocketDescriptor socket, QSocketNotifier::Type type) { remoteChannel_->onWrite(); - if (!remoteChannel_->isOpen()) - { + if (!remoteChannel_->isOpen()) { quit(); } }); @@ -126,11 +125,46 @@ void Application::onMessage(const clap::RemoteChannel::Message &msg) { case clap::messages::kAttachX11Request: { clap::messages::AttachX11Request rq; + clap::messages::AttachResponse rp{false}; msg.get(rq); + +#ifdef Q_OS_LINUX hostWindow_.reset(QWindow::fromWinId(rq.window)); quickView_->setParent(hostWindow_.get()); + rp.succeed = true; +#endif + + remoteChannel_->sendResponseAsync(rp, msg.cookie); + break; + } + + case clap::messages::kAttachWin32Request: { + clap::messages::AttachWin32Request rq; + clap::messages::AttachResponse rp{false}; + msg.get(rq); + +#ifdef Q_OS_WIN + hostWindow_.reset(QWindow::fromWinId(rq.hwnd)); + quickView_->setParent(hostWindow_.get()); + rp.succeed = true; +#endif + + remoteChannel_->sendResponseAsync(rp, msg.cookie); + break; + } + + case clap::messages::kAttachCocoaRequest: { + clap::messages::AttachCocoaRequest rq; + clap::messages::AttachResponse rp{false}; + + msg.get(rq); + +#ifdef Q_OS_MACOS + hostWindow_.reset(QWindow::fromWinId(rq.nsView)); + quickView_->setParent(hostWindow_.get()); + rp.succeed = true; +#endif - clap::messages::AttachResponse rp; remoteChannel_->sendResponseAsync(rp, msg.cookie); break; } diff --git a/examples/io/messages.hh b/examples/io/messages.hh @@ -157,7 +157,13 @@ namespace clap::messages { char display[128]; }; + struct AttachCocoaRequest final { + static const constexpr Type type = kAttachCocoaRequest; + void *nsView; + }; + struct AttachResponse final { static const constexpr Type type = kAttachResponse; + bool succeed; }; } // namespace clap::messages \ No newline at end of file diff --git a/examples/plugins/remote-gui.cc b/examples/plugins/remote-gui.cc @@ -181,8 +181,10 @@ namespace clap { } bool RemoteGui::attachCocoa(void *nsView) noexcept { - // TODO - return false; + messages::AttachCocoaRequest request{nsView}; + messages::AttachResponse response; + + return channel_->sendRequestSync(request, response); } bool RemoteGui::attachWin32(clap_hwnd window) noexcept {