Browse Source

Better support for NSM jack-apps: projects and non optional gui

Fixes #1188
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
eb3609b2cc
2 changed files with 51 additions and 14 deletions
  1. +41
    -10
      source/backend/plugin/CarlaPluginJack.cpp
  2. +10
    -4
      source/interposer/interposer-jack-x11.cpp

+ 41
- 10
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -71,11 +71,17 @@ static const ExternalMidiNote kExternalMidiNoteFallback = { -1, 0, 0 };


// ------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------


struct Announcer {
virtual ~Announcer() {}
virtual void nsmAnnounced(bool hasGui) = 0;
};

class CarlaPluginJackThread : public CarlaThread class CarlaPluginJackThread : public CarlaThread
{ {
public: public:
CarlaPluginJackThread(CarlaEngine* const engine, CarlaPlugin* const plugin) noexcept
CarlaPluginJackThread(Announcer* const ann, CarlaEngine* const engine, CarlaPlugin* const plugin) noexcept
: CarlaThread("CarlaPluginJackThread"), : CarlaThread("CarlaPluginJackThread"),
kAnnouncer(ann),
kEngine(engine), kEngine(engine),
kPlugin(plugin), kPlugin(plugin),
fShmIds(), fShmIds(),
@@ -114,7 +120,7 @@ public:
if (fSetupLabel != setupLabel) if (fSetupLabel != setupLabel)
fSetupLabel = setupLabel; fSetupLabel = setupLabel;


maybeOpenFirstTime();
maybeOpenFirstTime(false);


lo_send_from(fOscClientAddress, fOscServer, LO_TT_IMMEDIATE, "/nsm/client/save", ""); lo_send_from(fOscClientAddress, fOscServer, LO_TT_IMMEDIATE, "/nsm/client/save", "");
} }
@@ -179,20 +185,20 @@ protected:
return ((CarlaPluginJackThread*)data)->handleBroadcast(path, types, argv, msg); return ((CarlaPluginJackThread*)data)->handleBroadcast(path, types, argv, msg);
} }


void maybeOpenFirstTime()
void maybeOpenFirstTime(const bool announced)
{ {
if (fSetupLabel.length() <= 6) if (fSetupLabel.length() <= 6)
return; return;


if (fProject.path.isNotEmpty() || fProject.init(kPlugin->getName(),
kEngine->getCurrentProjectFolder(),
&fSetupLabel[6]))
if ((announced || fProject.path.isEmpty()) && fProject.init(kPlugin->getName(),
kEngine->getCurrentProjectFolder(),
&fSetupLabel[6]))
{ {
carla_stdout("Sending open signal %s %s %s", carla_stdout("Sending open signal %s %s %s",
fProject.path.buffer(), fProject.display.buffer(), fProject.clientName.buffer()); fProject.path.buffer(), fProject.display.buffer(), fProject.clientName.buffer());


lo_send_from(fOscClientAddress, fOscServer, LO_TT_IMMEDIATE, "/nsm/client/open", "sss", lo_send_from(fOscClientAddress, fOscServer, LO_TT_IMMEDIATE, "/nsm/client/open", "sss",
fProject.path.buffer(), fProject.display.buffer(), fProject.clientName.buffer());
fProject.path.buffer(), fProject.display.buffer(), fProject.clientName.buffer());
} }
} }


@@ -217,6 +223,8 @@ protected:
fProject.appName = &argv[0]->s; fProject.appName = &argv[0]->s;
fHasOptionalGui = std::strstr(&argv[1]->s, ":optional-gui:") != nullptr; fHasOptionalGui = std::strstr(&argv[1]->s, ":optional-gui:") != nullptr;


kAnnouncer->nsmAnnounced(fHasOptionalGui);

static const char* const featuresG = ":server-control:optional-gui:"; static const char* const featuresG = ":server-control:optional-gui:";
static const char* const featuresN = ":server-control:"; static const char* const featuresN = ":server-control:";


@@ -230,7 +238,7 @@ protected:
lo_send_from(fOscClientAddress, fOscServer, LO_TT_IMMEDIATE, "/reply", "ssss", lo_send_from(fOscClientAddress, fOscServer, LO_TT_IMMEDIATE, "/reply", "ssss",
method, message, smName, features); method, message, smName, features);


maybeOpenFirstTime();
maybeOpenFirstTime(true);
return 0; return 0;
} }


@@ -444,6 +452,7 @@ protected:
} }


private: private:
Announcer* const kAnnouncer;
CarlaEngine* const kEngine; CarlaEngine* const kEngine;
CarlaPlugin* const kPlugin; CarlaPlugin* const kPlugin;


@@ -499,7 +508,8 @@ private:


// ------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------


class CarlaPluginJack : public CarlaPlugin
class CarlaPluginJack : public CarlaPlugin,
public Announcer
{ {
public: public:
CarlaPluginJack(CarlaEngine* const engine, const uint id) CarlaPluginJack(CarlaEngine* const engine, const uint id)
@@ -512,7 +522,7 @@ public:
fBufferSize(engine->getBufferSize()), fBufferSize(engine->getBufferSize()),
fProcWaitTime(0), fProcWaitTime(0),
fSetupHints(0x0), fSetupHints(0x0),
fBridgeThread(engine, this),
fBridgeThread(this, engine, this),
fShmAudioPool(), fShmAudioPool(),
fShmRtClientControl(), fShmRtClientControl(),
fShmNonRtClientControl(), fShmNonRtClientControl(),
@@ -570,6 +580,27 @@ public:
fInfo.chunk.clear(); fInfo.chunk.clear();
} }


// -------------------------------------------------------------------

void nsmAnnounced(bool hasGui) override
{
if (hasGui || (pData->hints & PLUGIN_HAS_CUSTOM_UI) == 0x0)
return;

{
const CarlaMutexLocker _cml(fShmNonRtClientControl.mutex);

fShmNonRtClientControl.writeOpcode(kPluginBridgeNonRtClientShowUI);
fShmNonRtClientControl.commitWrite();
}

pData->engine->callback(true, true,
ENGINE_CALLBACK_UI_STATE_CHANGED,
pData->id,
1,
0, 0, 0.0f, nullptr);
}

// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Information (base) // Information (base)




+ 10
- 4
source/interposer/interposer-jack-x11.cpp View File

@@ -1,6 +1,6 @@
/* /*
* Carla Interposer for JACK Applications X11 control * Carla Interposer for JACK Applications X11 control
* Copyright (C) 2014-2019 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2014-2020 Filipe Coelho <falktx@falktx.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@@ -81,6 +81,7 @@ typedef enum {
#ifdef HAVE_X11 #ifdef HAVE_X11
static Display* gCurrentlyMappedDisplay = nullptr; static Display* gCurrentlyMappedDisplay = nullptr;
static Window gCurrentlyMappedWindow = 0; static Window gCurrentlyMappedWindow = 0;
static bool gSupportsOptionalGui = true;
#endif #endif
static CarlaInterposedCallback gInterposedCallback = nullptr; static CarlaInterposedCallback gInterposedCallback = nullptr;
static uint gInterposedSessionManager = LIBJACK_SESSION_MANAGER_NONE; static uint gInterposedSessionManager = LIBJACK_SESSION_MANAGER_NONE;
@@ -230,7 +231,9 @@ static int carlaWindowMap(Display* const display, const Window window, const Win
if (gCurrentlyMappedDisplay != nullptr && gCurrentlyMappedWindow != 0) if (gCurrentlyMappedDisplay != nullptr && gCurrentlyMappedWindow != 0)
{ {
// ignore requests against the current mapped window // ignore requests against the current mapped window
if (gCurrentlyMappedWindow == window && gInterposedSessionManager != LIBJACK_SESSION_MANAGER_NSM)
if (gCurrentlyMappedWindow == window)
return 0;
if (gInterposedSessionManager != LIBJACK_SESSION_MANAGER_NSM || ! gSupportsOptionalGui)
return 0; return 0;


// we already have a mapped window, with carla visible button on, should be a dialog of sorts.. // we already have a mapped window, with carla visible button on, should be a dialog of sorts..
@@ -278,7 +281,7 @@ static int carlaWindowMap(Display* const display, const Window window, const Win
gCurrentWindowMapped = false; gCurrentWindowMapped = false;
carla_stdout("JACK application window found and captured"); carla_stdout("JACK application window found and captured");


if (gInterposedSessionManager == LIBJACK_SESSION_MANAGER_NSM)
if (gInterposedSessionManager == LIBJACK_SESSION_MANAGER_NSM && gSupportsOptionalGui)
break; break;


return 0; return 0;
@@ -375,7 +378,7 @@ int XNextEvent(Display* display, XEvent* event)


if ((gInterposedHints & LIBJACK_FLAG_CONTROL_WINDOW) == 0x0) if ((gInterposedHints & LIBJACK_FLAG_CONTROL_WINDOW) == 0x0)
return ret; return ret;
if (gInterposedSessionManager == LIBJACK_SESSION_MANAGER_NSM)
if (gInterposedSessionManager == LIBJACK_SESSION_MANAGER_NSM && gSupportsOptionalGui)
return ret; return ret;


if (ret != 0) if (ret != 0)
@@ -428,6 +431,9 @@ int jack_carla_interposed_action(uint action, uint value, void* ptr)
return 1; return 1;


case LIBJACK_INTERPOSER_ACTION_SHOW_HIDE_GUI: case LIBJACK_INTERPOSER_ACTION_SHOW_HIDE_GUI:
#ifdef HAVE_X11
gSupportsOptionalGui = false;
#endif
// show gui // show gui
if (value != 0) if (value != 0)
{ {


Loading…
Cancel
Save