Signed-off-by: falkTX <falktx@falktx.com>pull/272/head
| @@ -9,7 +9,8 @@ include ../Makefile.base.mk | |||
| # --------------------------------------------------------------------------------------------------------------------- | |||
| BUILD_C_FLAGS += $(DGL_FLAGS) -I. -Isrc | |||
| BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc -Isrc/pugl-upstream/include -DDONT_SET_USING_DGL_NAMESPACE -Wno-unused-parameter | |||
| BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc -DDONT_SET_USING_DGL_NAMESPACE -Wno-unused-parameter | |||
| # -Isrc/pugl-upstream/include | |||
| LINK_FLAGS += $(DGL_LIBS) | |||
| # TODO fix these after pugl-upstream is done | |||
| @@ -17,7 +17,7 @@ | |||
| #include "ApplicationPrivateData.hpp" | |||
| #include "../Window.hpp" | |||
| #include "pugl-upstream/include/pugl/pugl.h" | |||
| #include "pugl.hpp" | |||
| START_NAMESPACE_DGL | |||
| @@ -27,10 +27,11 @@ Application::PrivateData::PrivateData(const bool standalone) | |||
| : world(puglNewWorld(standalone ? PUGL_PROGRAM : PUGL_MODULE, | |||
| standalone ? PUGL_WORLD_THREADS : 0x0)), | |||
| isStandalone(standalone), | |||
| isStarting(true), | |||
| isQuitting(false), | |||
| visibleWindows(0), | |||
| #ifndef DPF_TEST_APPLICATION_CPP | |||
| windows(), | |||
| #endif | |||
| idleCallbacks() | |||
| { | |||
| DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,); | |||
| @@ -44,11 +45,12 @@ Application::PrivateData::PrivateData(const bool standalone) | |||
| Application::PrivateData::~PrivateData() | |||
| { | |||
| DISTRHO_SAFE_ASSERT(!isStarting); | |||
| DISTRHO_SAFE_ASSERT(isQuitting); | |||
| DISTRHO_SAFE_ASSERT(visibleWindows == 0); | |||
| #ifndef DPF_TEST_APPLICATION_CPP | |||
| windows.clear(); | |||
| #endif | |||
| idleCallbacks.clear(); | |||
| if (world != nullptr) | |||
| @@ -62,10 +64,7 @@ void Application::PrivateData::oneWindowShown() noexcept | |||
| DISTRHO_SAFE_ASSERT_RETURN(isStandalone,); | |||
| if (++visibleWindows == 1) | |||
| { | |||
| isStarting = false; | |||
| isQuitting = false; | |||
| } | |||
| } | |||
| void Application::PrivateData::oneWindowHidden() noexcept | |||
| @@ -81,11 +80,13 @@ void Application::PrivateData::idle(const uint timeoutInMs) | |||
| { | |||
| puglUpdate(world, timeoutInMs == 0 ? 0.0 : static_cast<double>(timeoutInMs) / 1000.0); | |||
| #ifndef DPF_TEST_APPLICATION_CPP | |||
| for (std::list<Window*>::iterator it = windows.begin(), ite = windows.end(); it != ite; ++it) | |||
| { | |||
| Window* const window(*it); | |||
| window->_idle(); | |||
| } | |||
| #endif | |||
| for (std::list<IdleCallback*>::iterator it = idleCallbacks.begin(), ite = idleCallbacks.end(); it != ite; ++it) | |||
| { | |||
| @@ -98,11 +99,13 @@ void Application::PrivateData::quit() | |||
| { | |||
| isQuitting = true; | |||
| #ifndef DPF_TEST_APPLICATION_CPP | |||
| for (std::list<Window*>::reverse_iterator rit = windows.rbegin(), rite = windows.rend(); rit != rite; ++rit) | |||
| { | |||
| Window* const window(*rit); | |||
| window->close(); | |||
| } | |||
| #endif | |||
| } | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| @@ -36,9 +36,6 @@ struct Application::PrivateData { | |||
| /** Whether the application is running as standalone, otherwise it is part of a plugin. */ | |||
| const bool isStandalone; | |||
| /** Whether the applicating is starting up, not yet fully initialized. Defaults to true. */ | |||
| bool isStarting; | |||
| /** Whether the applicating is about to quit, or already stopped. Defaults to false. */ | |||
| bool isQuitting; | |||
| @@ -46,8 +43,10 @@ struct Application::PrivateData { | |||
| If 0->1, application is starting. If 1->0, application is quitting/stopping. */ | |||
| uint visibleWindows; | |||
| #ifndef DPF_TEST_APPLICATION_CPP | |||
| /** List of windows for this application. Used as a way to call each window `idle`. */ | |||
| std::list<Window*> windows; | |||
| #endif | |||
| /** List of idle callbacks for this application. Run after all windows `idle`. */ | |||
| std::list<IdleCallback*> idleCallbacks; | |||
| @@ -0,0 +1,65 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * 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 | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #include "pugl.hpp" | |||
| /* we will include all header files used in pugl in their C++ friendly form, then pugl stuff in custom namespace */ | |||
| #include <cassert> | |||
| #include <cmath> | |||
| #include <cstdlib> | |||
| #include <cstring> | |||
| #include <ctime> | |||
| #if defined(DISTRHO_OS_HAIKU) | |||
| #elif defined(DISTRHO_OS_MAC) | |||
| #elif defined(DISTRHO_OS_WINDOWS) | |||
| #else | |||
| # include <sys/select.h> | |||
| # include <sys/time.h> | |||
| # include <X11/X.h> | |||
| # include <X11/Xatom.h> | |||
| # include <X11/Xlib.h> | |||
| # include <X11/Xutil.h> | |||
| # include <X11/keysym.h> | |||
| # ifdef HAVE_XRANDR | |||
| # include <X11/extensions/Xrandr.h> | |||
| # endif | |||
| # ifdef HAVE_XSYNC | |||
| # include <X11/extensions/sync.h> | |||
| # include <X11/extensions/syncconst.h> | |||
| # endif | |||
| # ifdef HAVE_XCURSOR | |||
| # include <X11/Xcursor/Xcursor.h> | |||
| # include <X11/cursorfont.h> | |||
| # endif | |||
| #endif | |||
| START_NAMESPACE_DGL | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| #if defined(DISTRHO_OS_HAIKU) | |||
| #elif defined(DISTRHO_OS_MAC) | |||
| #elif defined(DISTRHO_OS_WINDOWS) | |||
| #else | |||
| # include "pugl-upstream/src/x11.c" | |||
| #endif | |||
| #include "pugl-upstream/src/implementation.c" | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| END_NAMESPACE_DGL | |||
| @@ -0,0 +1,37 @@ | |||
| /* | |||
| * DISTRHO Plugin Framework (DPF) | |||
| * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||
| * | |||
| * 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 | |||
| * permission notice appear in all copies. | |||
| * | |||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
| */ | |||
| #ifndef DGL_PUGL_HPP_INCLUDED | |||
| #define DGL_PUGL_HPP_INCLUDED | |||
| #include "../Base.hpp" | |||
| /* we will include all header files used in pugl in their C++ friendly form, then pugl stuff in custom namespace */ | |||
| #include <cstdbool> | |||
| #include <cstddef> | |||
| #include <cstdint> | |||
| START_NAMESPACE_DGL | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| #include "pugl-upstream/include/pugl/pugl.h" | |||
| // -------------------------------------------------------------------------------------------------------------------- | |||
| END_NAMESPACE_DGL | |||
| #endif // DGL_PUGL_HPP_INCLUDED | |||