@@ -17,35 +17,44 @@ | |||
#ifndef DGL_BASE_HPP_INCLUDED | |||
#define DGL_BASE_HPP_INCLUDED | |||
/* Compatibility with non-clang compilers */ | |||
#ifndef __has_feature | |||
# define __has_feature(x) 0 | |||
#endif | |||
#ifndef __has_extension | |||
# define __has_extension __has_feature | |||
#endif | |||
/* Check OS */ | |||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) | |||
# define DGL_OS_WINDOWS 1 | |||
#elif defined(__APPLE__) | |||
# define DGL_OS_MAC 1 | |||
#elif defined(__HAIKU__) | |||
# define DGL_OS_HAIKU 1 | |||
#elif defined(__linux__) | |||
#elif defined(__linux__) || defined(__linux) | |||
# define DGL_OS_LINUX 1 | |||
#endif | |||
/* Check for C++11 support */ | |||
#if defined(HAVE_CPP11_SUPPORT) | |||
# define PROPER_CPP11_SUPPORT | |||
#elif defined(__GNUC__) && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) | |||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 | |||
# define PROPER_CPP11_SUPPORT | |||
# if (__GNUC__ * 100 + __GNUC_MINOR__) < 407 | |||
# define override // gcc4.7+ only | |||
# endif | |||
#elif __cplusplus >= 201103L || (defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405) || __has_extension(cxx_noexcept) | |||
# define PROPER_CPP11_SUPPORT | |||
# if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || ! __has_extension(cxx_override_control) | |||
# define override // gcc4.7+ only | |||
# define final // gcc4.7+ only | |||
# endif | |||
#endif | |||
#ifndef PROPER_CPP11_SUPPORT | |||
# ifndef __clang__ | |||
# define noexcept throw() | |||
# endif | |||
# define noexcept throw() | |||
# define override | |||
# define final | |||
# define nullptr (0) | |||
#endif | |||
/* Define namespace */ | |||
#ifndef DGL_NAMESPACE | |||
# define DGL_NAMESPACE DGL | |||
#endif | |||
@@ -54,12 +63,14 @@ | |||
#define END_NAMESPACE_DGL } | |||
#define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; | |||
/* GL includes */ | |||
#ifdef DGL_OS_MAC | |||
# include <OpenGL/gl.h> | |||
#else | |||
# include <GL/gl.h> | |||
#endif | |||
/* missing GL defines */ | |||
#if defined(GL_BGR_EXT) && ! defined(GL_BGR) | |||
# define GL_BGR GL_BGR_EXT | |||
#endif | |||
@@ -61,6 +61,8 @@ public: | |||
void setTitle(const char* title); | |||
void setTransientWinId(intptr_t winId); | |||
App& getApp() const noexcept; | |||
uint32_t getEventTimestamp() const; | |||
int getModifiers() const; | |||
@@ -34,6 +34,8 @@ struct PuglViewImpl { | |||
int height; | |||
};} | |||
#elif defined(DGL_OS_LINUX) | |||
# include <sys/types.h> | |||
# include <unistd.h> | |||
extern "C" { | |||
# include "pugl/pugl_x11.c" | |||
} | |||
@@ -185,6 +187,10 @@ public: | |||
xDisplay = impl->display; | |||
xWindow = impl->win; | |||
assert(xWindow != 0); | |||
pid_t pid = getpid(); | |||
Atom _nwp = XInternAtom(xDisplay, "_NET_WM_PID", True); | |||
XChangeProperty(xDisplay, xWindow, _nwp, XA_CARDINAL, 32, PropModeReplace, (const unsigned char*)&pid, 1); | |||
#endif | |||
DBG("Success!\n"); | |||
@@ -426,7 +432,9 @@ public: | |||
XSizeHints sizeHints; | |||
memset(&sizeHints, 0, sizeof(sizeHints)); | |||
sizeHints.flags = PMinSize|PMaxSize; | |||
sizeHints.flags = PSize|PMinSize|PMaxSize; | |||
sizeHints.width = static_cast<int>(width); | |||
sizeHints.height = static_cast<int>(height); | |||
sizeHints.min_width = static_cast<int>(width); | |||
sizeHints.min_height = static_cast<int>(height); | |||
sizeHints.max_width = static_cast<int>(width); | |||
@@ -457,6 +465,19 @@ public: | |||
#endif | |||
} | |||
void setTransientWinId(const intptr_t winId) | |||
{ | |||
#if defined(DGL_OS_LINUX) | |||
XSetTransientForHint(xDisplay, xWindow, static_cast<::Window>(winId)); | |||
#else | |||
return; | |||
// unused | |||
(void)winId; | |||
#endif | |||
} | |||
// ------------------------------------------------------------------- | |||
App& getApp() const noexcept | |||
{ | |||
return fApp; | |||
@@ -871,6 +892,11 @@ void Window::setTitle(const char* title) | |||
pData->setTitle(title); | |||
} | |||
void Window::setTransientWinId(intptr_t winId) | |||
{ | |||
pData->setTransientWinId(winId); | |||
} | |||
App& Window::getApp() const noexcept | |||
{ | |||
return pData->getApp(); | |||
@@ -55,6 +55,15 @@ | |||
# error DISTRHO_PLUGIN_WANT_TIMEPOS undefined! | |||
#endif | |||
/* Compatibility with non-clang compilers */ | |||
#ifndef __has_feature | |||
# define __has_feature(x) 0 | |||
#endif | |||
#ifndef __has_extension | |||
# define __has_extension __has_feature | |||
#endif | |||
/* Check OS */ | |||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) | |||
# define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport) | |||
# define DISTRHO_OS_WINDOWS 1 | |||
@@ -77,25 +86,25 @@ | |||
# define DISTRHO_DLL_EXTENSION "so" | |||
#endif | |||
/* Check for C++11 support */ | |||
#if defined(HAVE_CPP11_SUPPORT) | |||
# define PROPER_CPP11_SUPPORT | |||
#elif defined(__GNUC__) && (__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)) | |||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 | |||
# define PROPER_CPP11_SUPPORT | |||
# if (__GNUC__ * 100 + __GNUC_MINOR__) < 407 | |||
# define override // gcc4.7+ only | |||
# endif | |||
#elif __cplusplus >= 201103L || (defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405) || __has_extension(cxx_noexcept) | |||
# define PROPER_CPP11_SUPPORT | |||
# if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || ! __has_extension(cxx_override_control) | |||
# define override // gcc4.7+ only | |||
# define final // gcc4.7+ only | |||
# endif | |||
#endif | |||
#ifndef PROPER_CPP11_SUPPORT | |||
# ifndef __clang__ | |||
# define noexcept throw() | |||
# endif | |||
# define noexcept throw() | |||
# define override | |||
# define final | |||
# define nullptr (0) | |||
#endif | |||
/* Define namespace */ | |||
#ifndef DISTRHO_NO_NAMESPACE | |||
# ifndef DISTRHO_NAMESPACE | |||
# define DISTRHO_NAMESPACE DISTRHO | |||
@@ -46,6 +46,9 @@ public: | |||
fUI(this, 0, editParameterCallback, setParameterCallback, setStateCallback, sendNoteCallback, uiResizeCallback) | |||
{ | |||
fUI.setTitle(host->uiName); | |||
if (host->uiParentId != 0) | |||
fUI.setTransientWinId(host->uiParentId); | |||
} | |||
// --------------------------------------------- | |||
@@ -198,7 +201,7 @@ protected: | |||
const NativeParameter* getParameterInfo(const uint32_t index) const override | |||
{ | |||
CARLA_ASSERT(index < getParameterCount()); | |||
CARLA_SAFE_ASSERT_RETURN(index < getParameterCount(), nullptr); | |||
static NativeParameter param; | |||
@@ -234,9 +237,6 @@ protected: | |||
param.ranges.def = ranges.def; | |||
param.ranges.min = ranges.min; | |||
param.ranges.max = ranges.max; | |||
//param.ranges.step = ranges.step; | |||
//param.ranges.stepSmall = ranges.stepSmall; | |||
//param.ranges.stepLarge = ranges.stepLarge; | |||
} | |||
return ¶m; | |||
@@ -244,7 +244,7 @@ protected: | |||
float getParameterValue(const uint32_t index) const override | |||
{ | |||
CARLA_ASSERT(index < getParameterCount()); | |||
CARLA_SAFE_ASSERT_RETURN(index < getParameterCount(), 0.0f); | |||
return fPlugin.getParameterValue(index); | |||
} | |||
@@ -260,10 +260,7 @@ protected: | |||
const NativeMidiProgram* getMidiProgramInfo(const uint32_t index) const override | |||
{ | |||
CARLA_ASSERT(index < getMidiProgramCount()); | |||
if (index >= fPlugin.getProgramCount()) | |||
return nullptr; | |||
CARLA_SAFE_ASSERT_RETURN(index < getMidiProgramCount(), nullptr); | |||
static NativeMidiProgram midiProgram; | |||
@@ -280,7 +277,7 @@ protected: | |||
void setParameterValue(const uint32_t index, const float value) override | |||
{ | |||
CARLA_ASSERT(index < getParameterCount()); | |||
CARLA_SAFE_ASSERT_RETURN(index < getParameterCount(),); | |||
fPlugin.setParameterValue(index, value); | |||
} | |||
@@ -290,8 +287,7 @@ protected: | |||
{ | |||
const uint32_t realProgram(bank * 128 + program); | |||
if (realProgram >= fPlugin.getProgramCount()) | |||
return; | |||
CARLA_SAFE_ASSERT_RETURN(realProgram < getMidiProgramCount(),); | |||
fPlugin.setProgram(realProgram); | |||
} | |||
@@ -300,8 +296,8 @@ protected: | |||
#if DISTRHO_PLUGIN_WANT_STATE | |||
void setCustomData(const char* const key, const char* const value) override | |||
{ | |||
CARLA_ASSERT(key != nullptr); | |||
CARLA_ASSERT(value != nullptr); | |||
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',); | |||
CARLA_SAFE_ASSERT_RETURN(value != nullptr,); | |||
fPlugin.setState(key, value); | |||
} | |||
@@ -323,21 +319,20 @@ protected: | |||
#if DISTRHO_PLUGIN_IS_SYNTH | |||
void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const NativeMidiEvent* const midiEvents, const uint32_t midiEventCount) override | |||
{ | |||
uint32_t i; | |||
MidiEvent realMidiEvents[midiEventCount]; | |||
for (i=0; i < midiEventCount && i < kMaxMidiEvents; ++i) | |||
for (uint32_t i=0; i < midiEventCount; ++i) | |||
{ | |||
const NativeMidiEvent* const midiEvent(&midiEvents[i]); | |||
MidiEvent* const realMidiEvent(&fRealMidiEvents[i]); | |||
const NativeMidiEvent& midiEvent(midiEvents[i]); | |||
MidiEvent& realMidiEvent(realMidiEvents[i]); | |||
realMidiEvent->frame = midiEvent->time; | |||
realMidiEvent->size = midiEvent->size; | |||
realMidiEvent.frame = midiEvent.time; | |||
realMidiEvent.size = midiEvent.size; | |||
for (uint8_t j=0; j < midiEvent->size; ++j) | |||
realMidiEvent->buf[j] = midiEvent->data[j]; | |||
carla_copy<uint8_t>(realMidiEvent.buf, midiEvent.data, midiEvent.size); | |||
} | |||
fPlugin.run(inBuffer, outBuffer, frames, fRealMidiEvents, i); | |||
fPlugin.run(inBuffer, outBuffer, frames, realMidiEvents, midiEventCount); | |||
} | |||
#else | |||
void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const NativeMidiEvent* const, const uint32_t) override | |||
@@ -361,45 +356,40 @@ protected: | |||
void uiIdle() override | |||
{ | |||
CARLA_ASSERT(fUiPtr != nullptr); | |||
CARLA_SAFE_ASSERT_RETURN(fUiPtr != nullptr,); | |||
if (fUiPtr != nullptr) | |||
fUiPtr->carla_idle(); | |||
fUiPtr->carla_idle(); | |||
} | |||
void uiSetParameterValue(const uint32_t index, const float value) override | |||
{ | |||
CARLA_ASSERT(fUiPtr != nullptr); | |||
CARLA_ASSERT(index < getParameterCount()); | |||
CARLA_SAFE_ASSERT_RETURN(fUiPtr != nullptr,); | |||
CARLA_SAFE_ASSERT_RETURN(index < getParameterCount(),); | |||
if (fUiPtr != nullptr) | |||
fUiPtr->carla_setParameterValue(index, value); | |||
fUiPtr->carla_setParameterValue(index, value); | |||
} | |||
# if DISTRHO_PLUGIN_WANT_PROGRAMS | |||
void uiSetMidiProgram(const uint8_t, const uint32_t bank, const uint32_t program) override | |||
{ | |||
CARLA_ASSERT(fUiPtr != nullptr); | |||
CARLA_SAFE_ASSERT_RETURN(fUiPtr != nullptr,); | |||
const uint32_t realProgram(bank * 128 + program); | |||
if (realProgram >= fPlugin.getProgramCount()) | |||
return; | |||
CARLA_SAFE_ASSERT_RETURN(realProgram < getMidiProgramCount(),); | |||
if (fUiPtr != nullptr) | |||
fUiPtr->carla_setMidiProgram(realProgram); | |||
fUiPtr->carla_setMidiProgram(realProgram); | |||
} | |||
# endif | |||
# if DISTRHO_PLUGIN_WANT_STATE | |||
void uiSetCustomData(const char* const key, const char* const value) override | |||
{ | |||
CARLA_ASSERT(fUiPtr != nullptr); | |||
CARLA_ASSERT(key != nullptr); | |||
CARLA_ASSERT(value != nullptr); | |||
CARLA_SAFE_ASSERT_RETURN(fUiPtr != nullptr,); | |||
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',); | |||
CARLA_SAFE_ASSERT_RETURN(value != nullptr,); | |||
if (fUiPtr != nullptr) | |||
fUiPtr->carla_setCustomData(key, value); | |||
fUiPtr->carla_setCustomData(key, value); | |||
} | |||
# endif | |||
#endif | |||
@@ -420,8 +410,9 @@ protected: | |||
#if DISTRHO_PLUGIN_HAS_UI | |||
void uiNameChanged(const char* const uiName) override | |||
{ | |||
if (fUiPtr != nullptr) | |||
fUiPtr->carla_setUiTitle(uiName); | |||
CARLA_SAFE_ASSERT_RETURN(fUiPtr != nullptr,); | |||
fUiPtr->carla_setUiTitle(uiName); | |||
} | |||
#endif | |||
@@ -430,10 +421,6 @@ protected: | |||
private: | |||
PluginExporter fPlugin; | |||
#if DISTRHO_PLUGIN_IS_SYNTH | |||
MidiEvent fRealMidiEvents[kMaxMidiEvents]; | |||
#endif | |||
#if DISTRHO_PLUGIN_HAS_UI | |||
// UI | |||
UICarla* fUiPtr; | |||
@@ -223,6 +223,11 @@ public: | |||
glWindow.setTitle(uiTitle); | |||
} | |||
void setTransientWinId(const intptr_t winId) | |||
{ | |||
glWindow.setTransientWinId(winId); | |||
} | |||
void setVisible(const bool yesNo) | |||
{ | |||
glWindow.setVisible(yesNo); | |||
@@ -7,7 +7,7 @@ if [ ! -d bin ]; then | |||
exit | |||
fi | |||
DPF_SOURCE_DIR="/home/falktx/FOSS/GIT-mine/DPF" | |||
DPF_SOURCE_DIR="/home/falktx/Personal/FOSS/GIT/falktx/DPF" | |||
make clean -C $DPF_SOURCE_DIR/dgl | |||