From fa54750583225c2e6aa5cda9baf9c18eb722daee Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 25 Jul 2017 11:11:25 +0200 Subject: [PATCH 1/7] Testing: handle effEditKeyUp/Down from host Completely untested right now --- dgl/Window.hpp | 8 +++ dgl/src/Window.cpp | 94 +++++++++++++++++++++++++++++++ distrho/src/DistrhoPluginVST.cpp | 62 ++++++++++++++++++++ distrho/src/DistrhoUIInternal.hpp | 10 ++++ 4 files changed, 174 insertions(+) diff --git a/dgl/Window.hpp b/dgl/Window.hpp index 25fa9b27..28d21a26 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -19,6 +19,10 @@ #include "Geometry.hpp" +START_NAMESPACE_DISTRHO +class UIExporter; +END_NAMESPACE_DISTRHO + START_NAMESPACE_DGL // ----------------------------------------------------------------------- @@ -119,11 +123,15 @@ private: friend class Application; friend class Widget; friend class StandaloneWindow; + friend class DISTRHO_NAMESPACE::UIExporter; virtual void _addWidget(Widget* const widget); virtual void _removeWidget(Widget* const widget); void _idle(); + bool handlePluginKeyboard(const bool press, const uint key); + bool handlePluginSpecial(const bool press, const Key key); + DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Window) }; diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 784fe89e..059eae89 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -845,6 +845,90 @@ struct Window::PrivateData { // ------------------------------------------------------------------- + bool handlePluginKeyboard(const bool press, const uint key) + { + DBGp("PUGL: handlePluginKeyboard : %i %i\n", press, key); + + if (fModal.childFocus != nullptr) + { + fModal.childFocus->focus(); + return true; + } + + Widget::KeyboardEvent ev; + ev.press = press; + ev.key = key; + ev.mod = static_cast(fView->mods); + ev.time = 0; + + if ((ev.mod & kModifierShift) != 0 && ev.key >= 'a' && ev.key <= 'z') + ev.key -= 'a' - 'A'; // a-z -> A-Z + + FOR_EACH_WIDGET_INV(rit) + { + Widget* const widget(*rit); + + if (widget->isVisible() && widget->onKeyboard(ev)) + return true; + } + + return false; + } + + bool handlePluginSpecial(const bool press, const Key key) + { + DBGp("PUGL: handlePluginSpecial : %i %i\n", press, key); + + if (fModal.childFocus != nullptr) + { + fModal.childFocus->focus(); + return true; + } + + int mods = 0x0; + + switch (key) + { + case kKeyShift: + mods |= kModifierShift; + break; + case kKeyControl: + mods |= kModifierControl; + break; + case kKeyAlt: + mods |= kModifierAlt; + break; + default: + break; + } + + if (mods != 0x0) + { + if (press) + fView->mods |= mods; + else + fView->mods &= ~(mods); + } + + Widget::SpecialEvent ev; + ev.press = press; + ev.key = key; + ev.mod = static_cast(fView->mods); + ev.time = 0; + + FOR_EACH_WIDGET_INV(rit) + { + Widget* const widget(*rit); + + if (widget->isVisible() && widget->onSpecial(ev)) + return true; + } + + return false; + } + + // ------------------------------------------------------------------- + Application& fApp; Window* fSelf; PuglView* fView; @@ -1200,6 +1284,16 @@ void Window::fileBrowserSelected(const char*) { } +bool Window::handlePluginKeyboard(const bool press, const uint key) +{ + return pData->handlePluginKeyboard(press, key); +} + +bool Window::handlePluginSpecial(const bool press, const Key key) +{ + return pData->handlePluginSpecial(press, key); +} + // ----------------------------------------------------------------------- StandaloneWindow::StandaloneWindow() diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp index 2956021c..ce78b265 100644 --- a/distrho/src/DistrhoPluginVST.cpp +++ b/distrho/src/DistrhoPluginVST.cpp @@ -52,6 +52,8 @@ #define effGetProgramNameIndexed 29 #define effGetPlugCategory 35 #define effIdle 53 +#define effEditKeyDown 59 +#define effEditKeyUp 60 #define kPlugCategEffect 1 #define kPlugCategSynth 2 #define kVstVersion 2400 @@ -167,6 +169,56 @@ public: } # endif + int handlePluginKeyEvent(const bool down, int32_t index, const intptr_t value) + { + d_stdout("handlePluginKeyEvent %i %i %li\n", down, index, (long int)value); + + int special = 0; + switch (value) + { + // special casing (can be combined with normal keys) + case 54: fUI.handlePluginSpecial(down, kKeyShift); break; + case 55: fUI.handlePluginSpecial(down, kKeyControl); break; + case 56: fUI.handlePluginSpecial(down, kKeyAlt); break; + + // convert some specials to normal keys + case 1: index = kCharBackspace; break; + case 6: index = kCharEscape; break; + case 22: index = kCharDelete; break; + + // handle rest of special keys + case 40: special = kKeyF1; break; + case 41: special = kKeyF2; break; + case 42: special = kKeyF3; break; + case 43: special = kKeyF4; break; + case 44: special = kKeyF5; break; + case 45: special = kKeyF6; break; + case 46: special = kKeyF7; break; + case 47: special = kKeyF8; break; + case 48: special = kKeyF9; break; + case 49: special = kKeyF10; break; + case 50: special = kKeyF11; break; + case 51: special = kKeyF12; break; + case 11: special = kKeyLeft; break; + case 12: special = kKeyUp; break; + case 13: special = kKeyRight; break; + case 14: special = kKeyDown; break; + case 15: special = kKeyPageUp; break; + case 16: special = kKeyPageDown; break; + case 10: special = kKeyHome; break; + case 9: special = kKeyEnd; break; + case 21: special = kKeyInsert; break; + } + + if (special != 0) + return fUI.handlePluginSpecial(down, static_cast(special)); + + if (index >= 0) + return fUI.handlePluginKeyboard(down, static_cast(index)); + + return 0; + } + // ------------------------------------------------------------------- protected: @@ -499,6 +551,16 @@ public: if (fVstUI != nullptr) fVstUI->idle(); break; + + case effEditKeyDown: + if (fVstUI != nullptr) + return fVstUI->handlePluginKeyEvent(true, index, value); + break; + + case effEditKeyUp: + if (fVstUI != nullptr) + return fVstUI->handlePluginKeyEvent(false, index, value); + break; #endif // DISTRHO_PLUGIN_HAS_UI #if DISTRHO_PLUGIN_WANT_STATE diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp index f771781b..a4c64ca5 100644 --- a/distrho/src/DistrhoUIInternal.hpp +++ b/distrho/src/DistrhoUIInternal.hpp @@ -416,6 +416,16 @@ public: return ! glApp.isQuiting(); } + + bool handlePluginKeyboard(const bool press, const uint key) + { + return glWindow.handlePluginKeyboard(press, key); + } + + bool handlePluginSpecial(const bool press, const Key key) + { + return glWindow.handlePluginKeyboard(press, key); + } #else void setWindowSize(const uint width, const uint height, const bool updateUI = false) {} void setWindowTransientWinId(const uintptr_t winId) {} From 49022ac62d58abbc779e4a214cde42d032159bfa Mon Sep 17 00:00:00 2001 From: fundamental Date: Sun, 30 Jul 2017 11:20:56 -0400 Subject: [PATCH 2/7] Fix VST Build With DISTRHO_PLUGIN_HAS_EXTERNAL_UI --- distrho/src/DistrhoPluginVST.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp index ce78b265..491798df 100644 --- a/distrho/src/DistrhoPluginVST.cpp +++ b/distrho/src/DistrhoPluginVST.cpp @@ -171,6 +171,7 @@ public: int handlePluginKeyEvent(const bool down, int32_t index, const intptr_t value) { +# if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI d_stdout("handlePluginKeyEvent %i %i %li\n", down, index, (long int)value); int special = 0; @@ -215,6 +216,7 @@ public: if (index >= 0) return fUI.handlePluginKeyboard(down, static_cast(index)); +# endif return 0; } From bf326114bda07014e09e2a4ba9b3f41dc0de885f Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 2 Aug 2017 10:05:02 +0200 Subject: [PATCH 3/7] Fix some special VST key handling This closes #20 --- distrho/src/DistrhoPluginVST.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp index 491798df..efeedace 100644 --- a/distrho/src/DistrhoPluginVST.cpp +++ b/distrho/src/DistrhoPluginVST.cpp @@ -177,14 +177,10 @@ public: int special = 0; switch (value) { - // special casing (can be combined with normal keys) - case 54: fUI.handlePluginSpecial(down, kKeyShift); break; - case 55: fUI.handlePluginSpecial(down, kKeyControl); break; - case 56: fUI.handlePluginSpecial(down, kKeyAlt); break; - // convert some specials to normal keys case 1: index = kCharBackspace; break; case 6: index = kCharEscape; break; + case 7: index = ' '; break; case 22: index = kCharDelete; break; // handle rest of special keys @@ -209,6 +205,9 @@ public: case 10: special = kKeyHome; break; case 9: special = kKeyEnd; break; case 21: special = kKeyInsert; break; + case 54: special = kKeyShift; break; + case 55: special = kKeyControl; break; + case 56: special = kKeyAlt; break; } if (special != 0) From a186f083ca010739b73c13bc75b0973264871de2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 2 Aug 2017 10:13:15 +0200 Subject: [PATCH 4/7] Add vst product string test, to know if we should capture keys --- distrho/src/DistrhoPluginVST.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/distrho/src/DistrhoPluginVST.cpp b/distrho/src/DistrhoPluginVST.cpp index efeedace..e6b9f0f1 100644 --- a/distrho/src/DistrhoPluginVST.cpp +++ b/distrho/src/DistrhoPluginVST.cpp @@ -124,8 +124,20 @@ public: fEffect(effect), fUiHelper(uiHelper), fPlugin(plugin), - fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback, plugin->getInstancePointer()) + fUI(this, winId, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, setSizeCallback, plugin->getInstancePointer()), + fShouldCaptureVstKeys(false) { + // FIXME only needed for windows? +//#ifdef DISTRHO_OS_WINDOWS + char strBuf[0xff+1]; + std::memset(strBuf, 0, sizeof(char)*(0xff+1)); + hostCallback(audioMasterGetProductString, 0, 0, strBuf); + d_stdout("Plugin UI running in '%s'", strBuf); + + // TODO make a white-list of needed hosts + if (/*std::strcmp(strBuf, "") == 0*/ true) + fShouldCaptureVstKeys = true; +//#endif } // ------------------------------------------------------------------- @@ -172,6 +184,9 @@ public: int handlePluginKeyEvent(const bool down, int32_t index, const intptr_t value) { # if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI + if (! fShouldCaptureVstKeys) + return 0; + d_stdout("handlePluginKeyEvent %i %i %li\n", down, index, (long int)value); int special = 0; @@ -284,6 +299,7 @@ private: // Plugin UI UIExporter fUI; + bool fShouldCaptureVstKeys; // ------------------------------------------------------------------- // Callbacks From 0393d1e42956ea707488be47f82d65c6cbd20a4d Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 1 Jan 2018 12:41:10 +0100 Subject: [PATCH 5/7] Add DGL_FILE_BROWSER_DISABLED to optionaly disable file browser --- dgl/Window.hpp | 6 ++++++ dgl/src/Window.cpp | 14 +++++++++++--- dgl/src/pugl/pugl_x11.c | 6 ++++++ distrho/DistrhoUI.hpp | 2 ++ distrho/src/DistrhoUI.cpp | 2 ++ distrho/src/DistrhoUIInternal.hpp | 2 ++ 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/dgl/Window.hpp b/dgl/Window.hpp index 28d21a26..90d255fc 100644 --- a/dgl/Window.hpp +++ b/dgl/Window.hpp @@ -34,6 +34,7 @@ class StandaloneWindow; class Window { public: +#ifndef DGL_FILE_BROWSER_DISABLED /** File browser options. */ @@ -70,6 +71,7 @@ public: height(0), buttons() {} }; +#endif // DGL_FILE_BROWSER_DISABLED explicit Window(Application& app); explicit Window(Application& app, Window& parent); @@ -84,7 +86,9 @@ public: void focus(); void repaint() noexcept; +#ifndef DGL_FILE_BROWSER_DISABLED bool openFileBrowser(const FileBrowserOptions& options); +#endif bool isVisible() const noexcept; void setVisible(bool yesNo); @@ -115,7 +119,9 @@ protected: virtual void onReshape(uint width, uint height); virtual void onClose(); +#ifndef DGL_FILE_BROWSER_DISABLED virtual void fileBrowserSelected(const char* filename); +#endif private: struct PrivateData; diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 059eae89..2ed4c1fa 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -196,7 +196,9 @@ struct Window::PrivateData { puglSetSpecialFunc(fView, onSpecialCallback); puglSetReshapeFunc(fView, onReshapeCallback); puglSetCloseFunc(fView, onCloseCallback); +#ifndef DGL_FILE_BROWSER_DISABLED puglSetFileSelectedFunc(fView, fileBrowserSelectedCallback); +#endif puglCreateWindow(fView, nullptr); @@ -1022,10 +1024,12 @@ struct Window::PrivateData { handlePtr->onPuglClose(); } +#ifndef DGL_FILE_BROWSER_DISABLED static void fileBrowserSelectedCallback(PuglView* view, const char* filename) { handlePtr->fSelf->fileBrowserSelected(filename); } +#endif #undef handlePtr @@ -1085,9 +1089,10 @@ void Window::repaint() noexcept // (void)name; // } +#ifndef DGL_FILE_BROWSER_DISABLED bool Window::openFileBrowser(const FileBrowserOptions& options) { -#ifdef SOFD_HAVE_X11 +# ifdef SOFD_HAVE_X11 using DISTRHO_NAMESPACE::String; // -------------------------------------------------------------------------- @@ -1145,11 +1150,12 @@ bool Window::openFileBrowser(const FileBrowserOptions& options) // show return (x_fib_show(pData->xDisplay, pData->xWindow, /*options.width*/0, /*options.height*/0) == 0); -#else +# else // not implemented return false; -#endif +# endif } +#endif bool Window::isVisible() const noexcept { @@ -1280,9 +1286,11 @@ void Window::onClose() { } +#ifndef DGL_FILE_BROWSER_DISABLED void Window::fileBrowserSelected(const char*) { } +#endif bool Window::handlePluginKeyboard(const bool press, const uint key) { diff --git a/dgl/src/pugl/pugl_x11.c b/dgl/src/pugl/pugl_x11.c index 60be55e7..ebd5a7b3 100644 --- a/dgl/src/pugl/pugl_x11.c +++ b/dgl/src/pugl/pugl_x11.c @@ -41,9 +41,11 @@ #include "pugl/pugl_internal.h" +#ifndef DGL_FILE_BROWSER_DISABLED #define SOFD_HAVE_X11 #include "../sofd/libsofd.h" #include "../sofd/libsofd.c" +#endif struct PuglInternalsImpl { Display* display; @@ -339,7 +341,9 @@ puglDestroy(PuglView* view) return; } +#ifndef DGL_FILE_BROWSER_DISABLED x_fib_close(view->impl->display); +#endif destroyContext(view); XDestroyWindow(view->impl->display, view->impl->win); @@ -477,6 +481,7 @@ puglProcessEvents(PuglView* view) while (XPending(view->impl->display) > 0) { XNextEvent(view->impl->display, &event); +#ifndef DGL_FILE_BROWSER_DISABLED if (x_fib_handle_events(view->impl->display, &event)) { const int status = x_fib_status(); @@ -495,6 +500,7 @@ puglProcessEvents(PuglView* view) } break; } +#endif if (event.xany.window != view->impl->win && (view->parent == 0 || event.xany.window != (Window)view->parent)) { diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index da8db414..0e8cb1ac 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -175,11 +175,13 @@ protected: */ virtual void uiIdle() {} +#ifndef DGL_FILE_BROWSER_DISABLED /** File browser selected function. @see Window::fileBrowserSelected(const char*) */ virtual void uiFileBrowserSelected(const char* filename); +#endif /** OpenGL window reshape function, called when parent window is resized. diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp index a4663090..5500e394 100644 --- a/distrho/src/DistrhoUI.cpp +++ b/distrho/src/DistrhoUI.cpp @@ -125,9 +125,11 @@ void UI::sampleRateChanged(double) {} /* ------------------------------------------------------------------------------------------------------------ * UI Callbacks (optional) */ +#ifndef DGL_FILE_BROWSER_DISABLED void UI::uiFileBrowserSelected(const char*) { } +#endif void UI::uiReshape(uint width, uint height) { diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp index a4c64ca5..3bf459fa 100644 --- a/distrho/src/DistrhoUIInternal.hpp +++ b/distrho/src/DistrhoUIInternal.hpp @@ -186,6 +186,7 @@ protected: fIsReady = true; } +#ifndef DGL_FILE_BROWSER_DISABLED // custom file-browser selected void fileBrowserSelected(const char* filename) override { @@ -193,6 +194,7 @@ protected: fUI->uiFileBrowserSelected(filename); } +#endif private: UI* const fUI; From c8d968a230e509c3b886e4482c17de8e4f466f35 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 1 Jan 2018 12:43:22 +0100 Subject: [PATCH 6/7] Fix build with custom DGL namespace, use it for OSX class names --- dgl/src/pugl/pugl_osx.m | 3 +++ distrho/DistrhoUI.hpp | 6 +++--- distrho/src/DistrhoUIInternal.hpp | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dgl/src/pugl/pugl_osx.m b/dgl/src/pugl/pugl_osx.m index 82985fbe..b4d64be2 100644 --- a/dgl/src/pugl/pugl_osx.m +++ b/dgl/src/pugl/pugl_osx.m @@ -24,6 +24,9 @@ #include "pugl_internal.h" +#define PuglWindow PuglWindow ## DGL_NAMESPACE +#define PuglOpenGLView PuglOpenGLView ## DGL_NAMESPACE + @interface PuglWindow : NSWindow { @public diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp index 0e8cb1ac..7429bdc2 100644 --- a/distrho/DistrhoUI.hpp +++ b/distrho/DistrhoUI.hpp @@ -25,10 +25,10 @@ typedef DISTRHO_NAMESPACE::ExternalWindow UIWidget; #elif DISTRHO_UI_USE_NANOVG # include "../dgl/NanoVG.hpp" -typedef DGL::NanoWidget UIWidget; +typedef DGL_NAMESPACE::NanoWidget UIWidget; #else # include "../dgl/Widget.hpp" -typedef DGL::Widget UIWidget; +typedef DGL_NAMESPACE::Widget UIWidget; #endif START_NAMESPACE_DISTRHO @@ -214,7 +214,7 @@ private: void setAbsoluteX(int) const noexcept {} void setAbsoluteY(int) const noexcept {} void setAbsolutePos(int, int) const noexcept {} - void setAbsolutePos(const DGL::Point&) const noexcept {} + void setAbsolutePos(const DGL_NAMESPACE::Point&) const noexcept {} #endif DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UI) diff --git a/distrho/src/DistrhoUIInternal.hpp b/distrho/src/DistrhoUIInternal.hpp index 3bf459fa..b2dd7e67 100644 --- a/distrho/src/DistrhoUIInternal.hpp +++ b/distrho/src/DistrhoUIInternal.hpp @@ -22,9 +22,9 @@ #ifdef HAVE_DGL # include "../../dgl/Application.hpp" # include "../../dgl/Window.hpp" -using DGL::Application; -using DGL::IdleCallback; -using DGL::Window; +using DGL_NAMESPACE::Application; +using DGL_NAMESPACE::IdleCallback; +using DGL_NAMESPACE::Window; #endif START_NAMESPACE_DISTRHO From f0cca0af9210f7e22d695648bd20aa336437394a Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 1 Jan 2018 12:50:22 +0100 Subject: [PATCH 7/7] Misc changes --- dgl/Makefile | 3 --- dgl/src/NanoVG.cpp | 12 +++++++++++- dgl/src/Window.cpp | 33 ++++++++++++++++++++++++--------- dgl/src/pugl/pugl_osx.m | 15 ++++++++------- distrho/DistrhoUtils.hpp | 4 ++-- 5 files changed, 45 insertions(+), 22 deletions(-) diff --git a/dgl/Makefile b/dgl/Makefile index fc61422b..aa694c63 100644 --- a/dgl/Makefile +++ b/dgl/Makefile @@ -15,9 +15,6 @@ LINK_FLAGS += $(DGL_LIBS) ifneq ($(MACOS_OLD),true) # needed by sofd right now, fix later BUILD_CXX_FLAGS += -Wno-type-limits -fpermissive - -# needed by stb_image -BUILD_CXX_FLAGS += -Wno-misleading-indentation -Wno-shift-negative-value endif # -------------------------------------------------------------- diff --git a/dgl/src/NanoVG.cpp b/dgl/src/NanoVG.cpp index 0fcb29f9..2b9f0d4a 100644 --- a/dgl/src/NanoVG.cpp +++ b/dgl/src/NanoVG.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2018 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -972,8 +972,18 @@ END_NAMESPACE_DGL #undef final +#if defined(__GNUC__) && (__GNUC__ >= 6) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmisleading-indentation" +# pragma GCC diagnostic ignored "-Wshift-negative-value" +#endif + extern "C" { #include "nanovg/nanovg.c" } +#if defined(__GNUC__) && (__GNUC__ >= 6) +# pragma GCC diagnostic pop +#endif + // ----------------------------------------------------------------------- diff --git a/dgl/src/Window.cpp b/dgl/src/Window.cpp index 2ed4c1fa..85975f67 100644 --- a/dgl/src/Window.cpp +++ b/dgl/src/Window.cpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2018 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -25,6 +25,11 @@ #include "pugl/pugl.h" +#if defined(__GNUC__) && (__GNUC__ >= 7) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wimplicit-fallthrough" +#endif + #if defined(DISTRHO_OS_WINDOWS) # include "pugl/pugl_win.cpp" #elif defined(DISTRHO_OS_MAC) @@ -37,6 +42,10 @@ extern "C" { } #endif +#if defined(__GNUC__) && (__GNUC__ >= 7) +# pragma GCC diagnostic pop +#endif + #include "ApplicationPrivateData.hpp" #include "WidgetPrivateData.hpp" #include "../StandaloneWindow.hpp" @@ -123,11 +132,14 @@ struct Window::PrivateData { #if defined(DISTRHO_OS_WINDOWS) // TODO #elif defined(DISTRHO_OS_MAC) - // TODO - //[parentImpl->window orderWindow:NSWindowBelow relativeTo:[[mView window] windowNumber]]; + [parentImpl->window orderWindow:NSWindowBelow relativeTo:[[mView window] windowNumber]]; #else XSetTransientForHint(xDisplay, xWindow, parentImpl->win); #endif + return; + + // maybe unused + (void)parentImpl; } PrivateData(Application& app, Window* const self, const intptr_t parentId) @@ -392,11 +404,7 @@ struct Window::PrivateData { SetFocus(hwnd); #elif defined(DISTRHO_OS_MAC) if (mWindow != nullptr) - { - // TODO - //[NSApp activateIgnoringOtherApps:YES]; - //[mWindow makeKeyAndOrderFront:mWindow]; - } + [mWindow makeKeyWindow]; #else XRaiseWindow(xDisplay, xWindow); XSetInputFocus(xDisplay, xWindow, RevertToPointerRoot, CurrentTime); @@ -615,10 +623,17 @@ struct Window::PrivateData { void setTransientWinId(const uintptr_t winId) { + DISTRHO_SAFE_ASSERT_RETURN(winId != 0,); + #if defined(DISTRHO_OS_WINDOWS) // TODO #elif defined(DISTRHO_OS_MAC) - // TODO + NSWindow* const window = [NSApp windowWithWindowNumber:winId]; + DISTRHO_SAFE_ASSERT_RETURN(window != nullptr,); + + [window addChildWindow:mWindow + ordered:NSWindowAbove]; + [mWindow makeKeyWindow]; #else XSetTransientForHint(xDisplay, xWindow, static_cast< ::Window>(winId)); #endif diff --git a/dgl/src/pugl/pugl_osx.m b/dgl/src/pugl/pugl_osx.m index b4d64be2..fb848791 100644 --- a/dgl/src/pugl/pugl_osx.m +++ b/dgl/src/pugl/pugl_osx.m @@ -441,13 +441,11 @@ void puglLeaveContext(PuglView* view, bool flush) { #ifdef PUGL_HAVE_GL - if (view->ctx_type == PUGL_GL) { - if (flush) { - if (view->impl->glview->doubleBuffered) { - [[view->impl->glview openGLContext] flushBuffer]; - } else { - glFlush(); - } + if (view->ctx_type == PUGL_GL && flush) { + if (view->impl->glview->doubleBuffered) { + [[view->impl->glview openGLContext] flushBuffer]; + } else { + glFlush(); } //[NSOpenGLContext clearCurrentContext]; } @@ -575,4 +573,7 @@ void* puglGetContext(PuglView* view) { return NULL; + + // unused + (void)view; } diff --git a/distrho/DistrhoUtils.hpp b/distrho/DistrhoUtils.hpp index bd2eefff..ee2cb571 100644 --- a/distrho/DistrhoUtils.hpp +++ b/distrho/DistrhoUtils.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2016 Filipe Coelho + * Copyright (C) 2012-2018 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -33,7 +33,7 @@ # include #endif -#if defined(DISTRHO_OS_MAC) && ! defined(CARLA_OS_MAC) && ! (defined(DISTRHO_PROPER_CPP11_SUPPORT) && defined(__clang__)) +#if defined(DISTRHO_OS_MAC) && ! defined(CARLA_OS_MAC) && ! defined(DISTRHO_PROPER_CPP11_SUPPORT) namespace std { inline float fmin(float __x, float __y) { return __builtin_fminf(__x, __y); }