Signed-off-by: falkTX <falktx@falktx.com>pull/272/head
@@ -84,6 +84,17 @@ public: | |||||
*/ | */ | ||||
void removeIdleCallback(IdleCallback* callback); | void removeIdleCallback(IdleCallback* callback); | ||||
/** | |||||
Set the class name of the application. | |||||
This is a stable identifier for the application, used as the window class/instance name on X11 and Windows. | |||||
It is not displayed to the user, but can be used in scripts and by window managers, | |||||
so it should be the same for every instance of the application, but different from other applications. | |||||
Plugins created with DPF have their class name automatically set based on DGL_NAMESPACE and plugin name. | |||||
*/ | |||||
void setClassName(const char* name); | |||||
private: | private: | ||||
struct PrivateData; | struct PrivateData; | ||||
PrivateData* const pData; | PrivateData* const pData; | ||||
@@ -67,6 +67,11 @@ void Application::removeIdleCallback(IdleCallback* const callback) | |||||
pData->idleCallbacks.remove(callback); | pData->idleCallbacks.remove(callback); | ||||
} | } | ||||
void Application::setClassName(const char* const name) | |||||
{ | |||||
pData->setClassName(name); | |||||
} | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
END_NAMESPACE_DGL | END_NAMESPACE_DGL |
@@ -41,18 +41,7 @@ Application::PrivateData::PrivateData(const bool standalone) | |||||
DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(world != nullptr,); | ||||
puglSetWorldHandle(world, this); | puglSetWorldHandle(world, this); | ||||
// FIXME | |||||
static int wc_count = 0; | |||||
char classNameBuf[256]; | |||||
std::srand((std::time(NULL))); | |||||
std::snprintf(classNameBuf, sizeof(classNameBuf), "%s_%d-%d-%p", | |||||
"TESTING", std::rand(), ++wc_count, this); | |||||
// DISTRHO_MACRO_AS_STRING(DGL_NAMESPACE) | |||||
classNameBuf[sizeof(classNameBuf)-1] = '\0'; | |||||
d_stderr("--------------------------------------------------------------- className is %s", classNameBuf); | |||||
puglSetClassName(world, classNameBuf); | |||||
puglSetClassName(world, DISTRHO_MACRO_AS_STRING(DGL_NAMESPACE)); | |||||
#ifdef HAVE_X11 | #ifdef HAVE_X11 | ||||
sofdFileDialogSetup(world); | sofdFileDialogSetup(world); | ||||
#endif | #endif | ||||
@@ -136,6 +125,13 @@ void Application::PrivateData::quit() | |||||
#endif | #endif | ||||
} | } | ||||
void Application::PrivateData::setClassName(const char* const name) | |||||
{ | |||||
DISTRHO_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0',); | |||||
puglSetClassName(world, name); | |||||
} | |||||
// -------------------------------------------------------------------------------------------------------------------- | // -------------------------------------------------------------------------------------------------------------------- | ||||
END_NAMESPACE_DGL | END_NAMESPACE_DGL |
@@ -76,6 +76,9 @@ struct Application::PrivateData { | |||||
For standalone mode only. */ | For standalone mode only. */ | ||||
void quit(); | void quit(); | ||||
/** Set pugl world class name. */ | |||||
void setClassName(const char* name); | |||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData) | ||||
}; | }; | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Plugin Framework (DPF) | * DISTRHO Plugin Framework (DPF) | ||||
* Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
@@ -53,14 +53,35 @@ UI* createUiWrapper(void* dspPtr, uintptr_t winId, double scaleFactor, const cha | |||||
UI* createUiWrapper(void* dspPtr, Window* window); | UI* createUiWrapper(void* dspPtr, Window* window); | ||||
#endif | #endif | ||||
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | |||||
// ----------------------------------------------------------------------- | |||||
// Plugin Application, will set class name based on plugin details | |||||
class PluginApplication : public Application | |||||
{ | |||||
public: | |||||
PluginApplication() | |||||
: Application(DISTRHO_UI_IS_STANDALONE) | |||||
{ | |||||
const char* const className = ( | |||||
#ifdef DISTRHO_PLUGIN_BRAND | |||||
DISTRHO_PLUGIN_BRAND | |||||
#else | |||||
DISTRHO_MACRO_AS_STRING(DISTRHO_NAMESPACE) | |||||
#endif | |||||
"-" DISTRHO_PLUGIN_NAME | |||||
); | |||||
setClassName(className); | |||||
} | |||||
}; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Plugin Window, needed to take care of resize properly | // Plugin Window, needed to take care of resize properly | ||||
#if !DISTRHO_PLUGIN_HAS_EXTERNAL_UI | |||||
class UIExporterWindow : public Window | class UIExporterWindow : public Window | ||||
{ | { | ||||
public: | public: | ||||
UIExporterWindow(Application& app, const intptr_t winId, const double scaleFactor, void* const dspPtr) | |||||
UIExporterWindow(PluginApplication& app, const intptr_t winId, const double scaleFactor, void* const dspPtr) | |||||
: Window(app, winId, scaleFactor, DISTRHO_UI_USER_RESIZABLE), | : Window(app, winId, scaleFactor, DISTRHO_UI_USER_RESIZABLE), | ||||
fUI(createUiWrapper(dspPtr, this)), | fUI(createUiWrapper(dspPtr, this)), | ||||
fIsReady(false) | fIsReady(false) | ||||
@@ -143,7 +164,7 @@ public: | |||||
#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI | ||||
: fUI(createUiWrapper(dspPtr, winId, scaleFactor, bundlePath)), | : fUI(createUiWrapper(dspPtr, winId, scaleFactor, bundlePath)), | ||||
#else | #else | ||||
: glApp(DISTRHO_UI_IS_STANDALONE), | |||||
: glApp(), | |||||
glWindow(glApp, winId, scaleFactor, dspPtr), | glWindow(glApp, winId, scaleFactor, dspPtr), | ||||
fChangingSize(false), | fChangingSize(false), | ||||
fUI(glWindow.getUI()), | fUI(glWindow.getUI()), | ||||
@@ -461,8 +482,8 @@ private: | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// DGL Application and Window for this widget | // DGL Application and Window for this widget | ||||
Application glApp; | |||||
UIExporterWindow glWindow; | |||||
PluginApplication glApp; | |||||
UIExporterWindow glWindow; | |||||
// prevent recursion | // prevent recursion | ||||
bool fChangingSize; | bool fChangingSize; | ||||