DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 57817027713af9e3b4bea411106c47c668478980
parent 3c641b3fe15a65654c3e7653971dff381d9a0507
Author: falkTX <falktx@falktx.com>
Date:   Thu, 27 May 2021 23:18:34 +0100

Fix/make clear distinction between standalone and plugin ui idle

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdistrho/src/DistrhoPluginJack.cpp | 2+-
Mdistrho/src/DistrhoPluginVST.cpp | 2+-
Mdistrho/src/DistrhoUIDSSI.cpp | 24+++++++++++++-----------
Mdistrho/src/DistrhoUIInternal.hpp | 24+++++++++++++++---------
Mdistrho/src/DistrhoUILV2.cpp | 4++--
Mdistrho/src/DistrhoUIPrivateData.hpp | 4++--
6 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/distrho/src/DistrhoPluginJack.cpp b/distrho/src/DistrhoPluginJack.cpp @@ -302,7 +302,7 @@ protected: } } - fUI.idle(); + fUI.exec_idle(); } #endif diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp @@ -212,7 +212,7 @@ public: } } - fUI.idle(); + fUI.plugin_idle(); } int16_t getWidth() const diff --git a/distrho/src/DistrhoUIDSSI.cpp b/distrho/src/DistrhoUIDSSI.cpp @@ -93,7 +93,7 @@ struct OscData { // ----------------------------------------------------------------------- -class UIDssi +class UIDssi : public IdleCallback { public: UIDssi(const OscData& oscData, const char* const uiTitle, const double sampleRate) @@ -111,17 +111,19 @@ public: fOscData.send_exiting(); } - void exec() + void exec_start() { - for (;;) - { - fOscData.idle(); + fUI.exec(this); + } + + void idleCallback() override + { + fOscData.idle(); - if (fHostClosed || ! fUI.idle()) - break; + if (fHostClosed) + return; - d_msleep(30); - } + fUI.exec_idle(); } // ------------------------------------------------------------------- @@ -393,7 +395,7 @@ int main(int argc, char* argv[]) initUiIfNeeded(); globalUI->dssiui_show(true); - globalUI->exec(); + globalUI->exec_start(); delete globalUI; globalUI = nullptr; @@ -492,7 +494,7 @@ int main(int argc, char* argv[]) { initUiIfNeeded(); - globalUI->exec(); + globalUI->exec_start(); delete globalUI; globalUI = nullptr; diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp @@ -210,10 +210,6 @@ public: } } - void exec_idle() - { - } - bool idle() { return true; @@ -231,6 +227,7 @@ public: ui->terminateAndWaitForProcess(); } #else +# if DISTRHO_UI_IS_STANDALONE void exec(IdleCallback* const cb) { DISTRHO_SAFE_ASSERT_RETURN(cb != nullptr,); @@ -240,26 +237,35 @@ public: uiData->app.exec(); } - void focus() + void exec_idle() { - uiData->window->focus(); - } + DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, ); - bool idle() + ui->uiIdle(); + } +# else + bool plugin_idle() { DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, false); + uiData->app.idle(); ui->uiIdle(); return ! uiData->app.isQuiting(); } +# endif + + void focus() + { + uiData->window->focus(); + } void quit() { uiData->window->close(); uiData->app.quit(); } - #endif + // ------------------------------------------------------------------- #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI diff --git a/distrho/src/DistrhoUILV2.cpp b/distrho/src/DistrhoUILV2.cpp @@ -191,9 +191,9 @@ public: int lv2ui_idle() { if (fWinIdWasNull) - return (fUI.idle() && fUI.isVisible()) ? 0 : 1; + return (fUI.plugin_idle() && fUI.isVisible()) ? 0 : 1; - return fUI.idle() ? 0 : 1; + return fUI.plugin_idle() ? 0 : 1; } int lv2ui_show() diff --git a/distrho/src/DistrhoUIPrivateData.hpp b/distrho/src/DistrhoUIPrivateData.hpp @@ -25,9 +25,9 @@ #endif #if defined(DISTRHO_PLUGIN_TARGET_JACK) || defined(DISTRHO_PLUGIN_TARGET_DSSI) -# define DISTRHO_UI_IS_STANDALONE true +# define DISTRHO_UI_IS_STANDALONE 1 #else -# define DISTRHO_UI_IS_STANDALONE false +# define DISTRHO_UI_IS_STANDALONE 0 #endif START_NAMESPACE_DISTRHO