From 3355e753bf7f4a15473068e25254b7a5cbc73797 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 26 Nov 2023 19:37:37 +0100 Subject: [PATCH] Keep track of LV2 externalUI visibility This allows Ardour to re-open previously shown plugins, and toggle externalUI. This worked in the distant past, before Ardour 3.3 introduced the Ardour Window Manager. --- gtk2_ardour/lv2_plugin_ui.cc | 16 ++++++++++++++-- gtk2_ardour/lv2_plugin_ui.h | 3 +++ gtk2_ardour/plugin_ui.h | 3 +++ gtk2_ardour/processor_box.cc | 26 +++++++++++++++++++++++++- gtk2_ardour/processor_box.h | 3 +++ 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc index 94b6ded7d9..70466d478d 100644 --- a/gtk2_ardour/lv2_plugin_ui.cc +++ b/gtk2_ardour/lv2_plugin_ui.cc @@ -250,7 +250,7 @@ LV2PluginUI::queue_port_update() void LV2PluginUI::output_update() { - //cout << "output_update" << endl; + //std::cout << "output_update" << std::endl; if (_external_ui_ptr) { LV2_EXTERNAL_UI_RUN(_external_ui_ptr); if (_lv2->is_external_kx() && !_external_ui_ptr) { @@ -590,7 +590,7 @@ LV2PluginUI::is_update_wanted(uint32_t /*index*/) bool LV2PluginUI::on_window_show(const std::string& title) { - //cout << "on_window_show - " << title << endl; flush(cout); + //std::cout << "on_window_show - " << title << std::endl;// flush(cout); if (_lv2->is_external_ui()) { if (_external_ui_ptr) { @@ -645,3 +645,15 @@ LV2PluginUI::on_window_hide() lv2ui_free(); } } + +bool +LV2PluginUI::is_external () const +{ + return _lv2->is_external_ui (); +} + +bool +LV2PluginUI::is_external_visible () const +{ + return _external_ui_ptr != 0; +} diff --git a/gtk2_ardour/lv2_plugin_ui.h b/gtk2_ardour/lv2_plugin_ui.h index 51b2d4b061..217148d20d 100644 --- a/gtk2_ardour/lv2_plugin_ui.h +++ b/gtk2_ardour/lv2_plugin_ui.h @@ -66,6 +66,9 @@ public: bool start_updating(GdkEventAny*); bool stop_updating(GdkEventAny*); + bool is_external () const; + bool is_external_visible () const; + int package (Gtk::Window&); void grab_focus (); diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index c6e4ed915a..2963a6f7a9 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -100,6 +100,9 @@ public: virtual bool start_updating(GdkEventAny*) = 0; virtual bool stop_updating(GdkEventAny*) = 0; + virtual bool is_external () const { return false; } + virtual bool is_external_visible () const { return false; } + virtual void activate () {} virtual void deactivate () {} diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index defe87e79a..705ae44fd5 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -4787,12 +4787,36 @@ ProcessorWindowProxy::session_handle() /* we don't care */ return 0; } +bool +ProcessorWindowProxy::visible () const +{ + PluginUIWindow* puiw = dynamic_cast (_window); + if (puiw && puiw->pluginui().is_external ()) { + return puiw->pluginui().is_external_visible (); + } + return WM::ProxyBase::visible (); +} + +bool +ProcessorWindowProxy::fully_visible () const +{ + PluginUIWindow* puiw = dynamic_cast (_window); + if (puiw && puiw->pluginui().is_external ()) { + return puiw->pluginui().is_external_visible (); + } + return WM::ProxyBase::fully_visible (); +} XMLNode& ProcessorWindowProxy::get_state () const { + PluginUIWindow* puiw = dynamic_cast (_window); + XMLNode *node; node = &ProxyBase::get_state(); + if (puiw && puiw->pluginui().is_external ()) { + node->set_property (X_("visible"), puiw->pluginui().is_external_visible ()); + } node->set_property (X_("custom-ui"), is_custom); return *node; } @@ -4844,7 +4868,7 @@ ProcessorWindowProxy::get (bool create) if (_window) { setup (); - _window->show_all (); + _window->show_all (); // XXX } } return _window; diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index 5c238f3feb..876a9ccc2f 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -105,6 +105,9 @@ public: int set_state (const XMLNode&, int); XMLNode& get_state () const; + bool visible() const; + bool fully_visible() const; + private: ProcessorBox* _processor_box; std::weak_ptr _processor;