diff --git a/source/backend/plugin/CarlaPluginJuce.cpp b/source/backend/plugin/CarlaPluginJuce.cpp index 4a7201fe4..1e616a936 100644 --- a/source/backend/plugin/CarlaPluginJuce.cpp +++ b/source/backend/plugin/CarlaPluginJuce.cpp @@ -314,7 +314,7 @@ public: juce::String uiName(pData->name); uiName += " (GUI)"; - fWindow = new JucePluginWindow(); + fWindow = new JucePluginWindow(pData->engine->getOptions().frontendWinId); fWindow->setName(uiName); } @@ -1232,7 +1232,8 @@ public: else pData->name = pData->engine->getUniquePluginName(fInstance->getName().toRawUTF8()); - pData->filename = carla_strdup(filename); + if (filename != nullptr && pData->filename[0] != '\0') + pData->filename = carla_strdup(filename); // --------------------------------------------------------------- // register client diff --git a/source/backend/plugin/Makefile b/source/backend/plugin/Makefile index e0980a433..e2af2da1b 100644 --- a/source/backend/plugin/Makefile +++ b/source/backend/plugin/Makefile @@ -60,6 +60,11 @@ $(OBJDIR)/CarlaPluginVST2.cpp.o: CarlaPluginVST2.cpp -@mkdir -p $(OBJDIR) @echo "Compiling $<" @$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@ + +$(OBJDIR)/CarlaPluginJuce.cpp.o: CarlaPluginJuce.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling $<" + @$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@ endif $(OBJDIR)/%.cpp.o: %.cpp diff --git a/source/backend/utils/CachedPlugins.cpp b/source/backend/utils/CachedPlugins.cpp index d43441215..0c56ddede 100644 --- a/source/backend/utils/CachedPlugins.cpp +++ b/source/backend/utils/CachedPlugins.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2018 Filipe Coelho + * Copyright (C) 2011-2019 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/source/utils/JucePluginWindow.hpp b/source/utils/JucePluginWindow.hpp index 081a6bc97..fef0d5f8a 100644 --- a/source/utils/JucePluginWindow.hpp +++ b/source/utils/JucePluginWindow.hpp @@ -1,6 +1,6 @@ /* * Juce Plugin Window Helper - * Copyright (C) 2013-2014 Filipe Coelho + * Copyright (C) 2013-2019 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -23,24 +23,27 @@ #include "AppConfig.h" #include "juce_gui_basics/juce_gui_basics.h" -#ifdef HAVE_X11 +#if JUCE_LINUX && defined(HAVE_X11) # include +#elif JUCE_MAC +# import #endif // ----------------------------------------------------------------------- namespace juce { -#ifdef HAVE_X11 +#if JUCE_LINUX && defined(HAVE_X11) extern Display* display; #endif -class JucePluginWindow : public DocumentWindow +class JucePluginWindow : public DialogWindow { public: - JucePluginWindow() - : DocumentWindow("JucePluginWindow", Colour(50, 50, 200), DocumentWindow::closeButton, false), - fClosed(false) + JucePluginWindow(const uintptr_t parentId) + : DialogWindow("JucePluginWindow", Colour(50, 50, 200), true, false), + fClosed(false), + fTransientId(parentId) { setVisible(false); //setAlwaysOnTop(true); @@ -49,21 +52,18 @@ public: setUsingNativeTitleBar(true); } - void show(Component* const comp, const bool useContentOwned = false) + void show(Component* const comp) { fClosed = false; centreWithSize(comp->getWidth(), comp->getHeight()); - - if (useContentOwned) - setContentOwned(comp, false); - else - setContentNonOwned(comp, true); + setContentNonOwned(comp, true); if (! isOnDesktop()) addToDesktop(); setVisible(true); + setTransient(); } void hide() @@ -81,29 +81,51 @@ public: return fClosed; } - void setTransientWinId(const uintptr_t winId) const +protected: + void closeButtonPressed() override + { + fClosed = true; + } + + bool escapeKeyPressed() override + { + fClosed = true; + return true; + } + +private: + volatile bool fClosed; + const uintptr_t fTransientId; + + void setTransient() { - CARLA_SAFE_ASSERT_RETURN(winId != 0,); + if (fTransientId == 0) + return; -#ifdef HAVE_X11 +#if JUCE_LINUX && defined(HAVE_X11) CARLA_SAFE_ASSERT_RETURN(display != nullptr,); ::Window window = (::Window)getWindowHandle(); CARLA_SAFE_ASSERT_RETURN(window != 0,); - XSetTransientForHint(display, window, static_cast(winId)); + XSetTransientForHint(display, window, static_cast<::Window>(fTransientId)); #endif - } -protected: - void closeButtonPressed() override - { - fClosed = true; - } +#if JUCE_MAC + NSView* const view = (NSView*)getWindowHandle(); + CARLA_SAFE_ASSERT_RETURN(view != nullptr,); -private: - volatile bool fClosed; + NSWindow* const window = [view window]; + CARLA_SAFE_ASSERT_RETURN(window != nullptr,); + + NSWindow* const parentWindow = [NSApp windowWithWindowNumber:fTransientId]; + CARLA_SAFE_ASSERT_RETURN(parentWindow != nullptr,); + + [parentWindow addChildWindow:window + ordered:NSWindowAbove]; +#endif + } CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(JucePluginWindow) };