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/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/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 059eae89..17367299 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) @@ -196,7 +208,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); @@ -390,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); @@ -613,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 @@ -1022,10 +1039,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 +1104,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 +1165,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 +1301,21 @@ void Window::onClose() { } +#ifndef DGL_FILE_BROWSER_DISABLED void Window::fileBrowserSelected(const char*) { } +#endif + +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); +} bool Window::handlePluginKeyboard(const bool press, const uint key) { diff --git a/dgl/src/pugl/pugl_osx.m b/dgl/src/pugl/pugl_osx.m index 82985fbe..fb848791 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 @@ -438,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]; } @@ -572,4 +573,7 @@ void* puglGetContext(PuglView* view) { return NULL; + + // unused + (void)view; } diff --git a/dgl/src/pugl/pugl_x11.c b/dgl/src/pugl/pugl_x11.c index 95f0d3dc..22432488 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..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 @@ -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. @@ -212,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/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); } 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..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 @@ -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;