Fix: Plugin GUI X button now closes window — custom DocumentWindow with closeButtonPressed override
Browse files3 unmodified lines456789109 unmodified lines119120121122123124125101 unmodified lines2272282292302312322332342352362372382392402412422432442452463 unmodified lines#include <pthread.h>#include <sched.h>HelperPluginHost::HelperPluginHost(){#if JUCE_PLUGINHOST_VST3109 unmodified linesvoid HelperPluginHost::audioProcessingLoop(){// Set realtime thread priority using native macOS/POSIX APIstruct sched_param param;param.sched_priority = sched_get_priority_max(SCHED_FIFO);pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m);101 unmodified linesvoid HelperPluginHost::showGui(){if (!plugin || !plugin->hasEditor()) return;if (guiWindow) return;juce::MessageManager::callAsync([this](){if (!plugin) return;auto* editor = plugin->createEditor();if (!editor) return;guiWindow = std::make_unique<juce::DocumentWindow>(plugin->getName(),juce::Colour(0xff1a1a2e),juce::DocumentWindow::closeButton | juce::DocumentWindow::minimiseButton);guiWindow->setContentOwned(editor, true);guiWindow->setResizable(true, true);guiWindow->centreWithSize(editor->getWidth(), editor->getHeight());3 unmodified lines456789101112131415161718192021222324109 unmodified lines134135136137138139101 unmodified lines2412422432442452462472482492502512522532542552562572582592602612622633 unmodified lines#include <pthread.h>#include <sched.h>// Custom window that actually closes when you click Xclass PluginGuiWindow : public juce::DocumentWindow{public:PluginGuiWindow(const juce::String& name): DocumentWindow(name, juce::Colour(0xff1a1a2e),DocumentWindow::closeButton | DocumentWindow::minimiseButton){}void closeButtonPressed() override{setVisible(false);}};HelperPluginHost::HelperPluginHost(){#if JUCE_PLUGINHOST_VST3109 unmodified linesvoid HelperPluginHost::audioProcessingLoop(){struct sched_param param;param.sched_priority = sched_get_priority_max(SCHED_FIFO);pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m);101 unmodified linesvoid HelperPluginHost::showGui(){if (!plugin || !plugin->hasEditor()) return;juce::MessageManager::callAsync([this](){if (!plugin) return;// If window exists but hidden, just show it againif (guiWindow){guiWindow->setVisible(true);guiWindow->toFront(true);return;}auto* editor = plugin->createEditor();if (!editor) return;guiWindow = std::make_unique<PluginGuiWindow>(plugin->getName());guiWindow->setContentOwned(editor, true);guiWindow->setResizable(true, true);guiWindow->centreWithSize(editor->getWidth(), editor->getHeight());
Source/Helper/HelperPluginHost.cpp+24-7