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_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) | LINK_FLAGS += $(DGL_LIBS) | ||||
# TODO fix these after pugl-upstream is done | # TODO fix these after pugl-upstream is done | ||||
@@ -17,7 +17,7 @@ | |||||
#include "ApplicationPrivateData.hpp" | #include "ApplicationPrivateData.hpp" | ||||
#include "../Window.hpp" | #include "../Window.hpp" | ||||
#include "pugl-upstream/include/pugl/pugl.h" | |||||
#include "pugl.hpp" | |||||
START_NAMESPACE_DGL | START_NAMESPACE_DGL | ||||
@@ -27,10 +27,11 @@ Application::PrivateData::PrivateData(const bool standalone) | |||||
: world(puglNewWorld(standalone ? PUGL_PROGRAM : PUGL_MODULE, | : world(puglNewWorld(standalone ? PUGL_PROGRAM : PUGL_MODULE, | ||||
standalone ? PUGL_WORLD_THREADS : 0x0)), | standalone ? PUGL_WORLD_THREADS : 0x0)), | ||||
isStandalone(standalone), | isStandalone(standalone), | ||||
isStarting(true), | |||||
isQuitting(false), | isQuitting(false), | ||||
visibleWindows(0), | visibleWindows(0), | ||||
#ifndef DPF_TEST_APPLICATION_CPP | |||||
windows(), | windows(), | ||||
#endif | |||||
idleCallbacks() | idleCallbacks() | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,); | ||||
@@ -44,11 +45,12 @@ Application::PrivateData::PrivateData(const bool standalone) | |||||
Application::PrivateData::~PrivateData() | Application::PrivateData::~PrivateData() | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT(!isStarting); | |||||
DISTRHO_SAFE_ASSERT(isQuitting); | DISTRHO_SAFE_ASSERT(isQuitting); | ||||
DISTRHO_SAFE_ASSERT(visibleWindows == 0); | DISTRHO_SAFE_ASSERT(visibleWindows == 0); | ||||
#ifndef DPF_TEST_APPLICATION_CPP | |||||
windows.clear(); | windows.clear(); | ||||
#endif | |||||
idleCallbacks.clear(); | idleCallbacks.clear(); | ||||
if (world != nullptr) | if (world != nullptr) | ||||
@@ -62,10 +64,7 @@ void Application::PrivateData::oneWindowShown() noexcept | |||||
DISTRHO_SAFE_ASSERT_RETURN(isStandalone,); | DISTRHO_SAFE_ASSERT_RETURN(isStandalone,); | ||||
if (++visibleWindows == 1) | if (++visibleWindows == 1) | ||||
{ | |||||
isStarting = false; | |||||
isQuitting = false; | isQuitting = false; | ||||
} | |||||
} | } | ||||
void Application::PrivateData::oneWindowHidden() noexcept | 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); | 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) | for (std::list<Window*>::iterator it = windows.begin(), ite = windows.end(); it != ite; ++it) | ||||
{ | { | ||||
Window* const window(*it); | Window* const window(*it); | ||||
window->_idle(); | window->_idle(); | ||||
} | } | ||||
#endif | |||||
for (std::list<IdleCallback*>::iterator it = idleCallbacks.begin(), ite = idleCallbacks.end(); it != ite; ++it) | for (std::list<IdleCallback*>::iterator it = idleCallbacks.begin(), ite = idleCallbacks.end(); it != ite; ++it) | ||||
{ | { | ||||
@@ -98,11 +99,13 @@ void Application::PrivateData::quit() | |||||
{ | { | ||||
isQuitting = true; | isQuitting = true; | ||||
#ifndef DPF_TEST_APPLICATION_CPP | |||||
for (std::list<Window*>::reverse_iterator rit = windows.rbegin(), rite = windows.rend(); rit != rite; ++rit) | for (std::list<Window*>::reverse_iterator rit = windows.rbegin(), rite = windows.rend(); rit != rite; ++rit) | ||||
{ | { | ||||
Window* const window(*rit); | Window* const window(*rit); | ||||
window->close(); | window->close(); | ||||
} | } | ||||
#endif | |||||
} | } | ||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
@@ -36,9 +36,6 @@ struct Application::PrivateData { | |||||
/** Whether the application is running as standalone, otherwise it is part of a plugin. */ | /** Whether the application is running as standalone, otherwise it is part of a plugin. */ | ||||
const bool isStandalone; | 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. */ | /** Whether the applicating is about to quit, or already stopped. Defaults to false. */ | ||||
bool isQuitting; | bool isQuitting; | ||||
@@ -46,8 +43,10 @@ struct Application::PrivateData { | |||||
If 0->1, application is starting. If 1->0, application is quitting/stopping. */ | If 0->1, application is starting. If 1->0, application is quitting/stopping. */ | ||||
uint visibleWindows; | uint visibleWindows; | ||||
#ifndef DPF_TEST_APPLICATION_CPP | |||||
/** List of windows for this application. Used as a way to call each window `idle`. */ | /** List of windows for this application. Used as a way to call each window `idle`. */ | ||||
std::list<Window*> windows; | std::list<Window*> windows; | ||||
#endif | |||||
/** List of idle callbacks for this application. Run after all windows `idle`. */ | /** List of idle callbacks for this application. Run after all windows `idle`. */ | ||||
std::list<IdleCallback*> idleCallbacks; | 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 |