Browse Source

Make add-jack interposer work for builds without X11

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
218ff8f733
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
3 changed files with 30 additions and 20 deletions
  1. +2
    -10
      source/backend/plugin/CarlaPluginJack.cpp
  2. +2
    -2
      source/interposer/Makefile
  3. +26
    -8
      source/interposer/interposer-jack-x11.cpp

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

@@ -142,9 +142,7 @@ public:


CarlaString ret; CarlaString ret;
ret += "export LD_LIBRARY_PATH=" + binaryDir + "/jack\n"; ret += "export LD_LIBRARY_PATH=" + binaryDir + "/jack\n";
#ifdef HAVE_X11
ret += "export LD_PRELOAD=" + binaryDir + "/libcarla_interposer-jack-x11.so\n"; ret += "export LD_PRELOAD=" + binaryDir + "/libcarla_interposer-jack-x11.so\n";
#endif
#ifdef HAVE_LIBLO #ifdef HAVE_LIBLO
if (sessionManager == LIBJACK_SESSION_MANAGER_NSM) if (sessionManager == LIBJACK_SESSION_MANAGER_NSM)
{ {
@@ -329,14 +327,8 @@ protected:
std::snprintf(winIdStr, STR_MAX, P_UINTPTR, options.frontendWinId); std::snprintf(winIdStr, STR_MAX, P_UINTPTR, options.frontendWinId);
winIdStr[STR_MAX] = '\0'; winIdStr[STR_MAX] = '\0';


CarlaString libjackdir(options.binaryDir);
libjackdir += "/jack";

CarlaString ldpreload;
#ifdef HAVE_X11
ldpreload = (CarlaString(options.binaryDir)
+ "/libcarla_interposer-jack-x11.so");
#endif
const CarlaString libjackdir(CarlaString(options.binaryDir) + "/jack");
const CarlaString ldpreload(CarlaString(options.binaryDir) + "/libcarla_interposer-jack-x11.so");


const ScopedEngineEnvironmentLocker _seel(kEngine); const ScopedEngineEnvironmentLocker _seel(kEngine);




+ 2
- 2
source/interposer/Makefile View File

@@ -33,13 +33,13 @@ TARGETS =


ifeq ($(LINUX),true) ifeq ($(LINUX),true)
OBJS += $(OBJDIR)/interposer-safe.cpp.o OBJS += $(OBJDIR)/interposer-safe.cpp.o
OBJS += $(OBJDIR)/interposer-jack-x11.cpp.o
TARGETS += $(BINDIR)/libcarla_interposer-safe.so TARGETS += $(BINDIR)/libcarla_interposer-safe.so
TARGETS += $(BINDIR)/libcarla_interposer-jack-x11.so


ifeq ($(HAVE_X11),true) ifeq ($(HAVE_X11),true)
OBJS += $(OBJDIR)/interposer-x11.cpp.o OBJS += $(OBJDIR)/interposer-x11.cpp.o
OBJS += $(OBJDIR)/interposer-jack-x11.cpp.o
TARGETS += $(BINDIR)/libcarla_interposer-x11.so TARGETS += $(BINDIR)/libcarla_interposer-x11.so
TARGETS += $(BINDIR)/libcarla_interposer-jack-x11.so
endif endif
endif endif




+ 26
- 8
source/interposer/interposer-jack-x11.cpp View File

@@ -19,7 +19,10 @@
#include "CarlaUtils.hpp" #include "CarlaUtils.hpp"


#include <dlfcn.h> #include <dlfcn.h>
#include <X11/Xlib.h>

#ifdef HAVE_X11
# include <X11/Xlib.h>
#endif


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


@@ -59,12 +62,6 @@ struct ScopedLibOpen {
CARLA_DECLARE_NON_COPY_STRUCT(ScopedLibOpen); CARLA_DECLARE_NON_COPY_STRUCT(ScopedLibOpen);
}; };


// --------------------------------------------------------------------------------------------------------------------
// Function typedefs

typedef int (*XWindowFunc)(Display*, Window);
typedef int (*XNextEventFunc)(Display*, XEvent*);

// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
// Current state // Current state


@@ -75,8 +72,10 @@ typedef enum {
WindowMapSubwindows WindowMapSubwindows
} WindowMappingType; } WindowMappingType;


#ifdef HAVE_X11
static Display* gCurrentlyMappedDisplay = nullptr; static Display* gCurrentlyMappedDisplay = nullptr;
static Window gCurrentlyMappedWindow = 0; static Window gCurrentlyMappedWindow = 0;
#endif
static CarlaInterposedCallback gInterposedCallback = nullptr; static CarlaInterposedCallback gInterposedCallback = nullptr;
static uint gInterposedSessionManager = LIBJACK_SESSION_MANAGER_NONE; static uint gInterposedSessionManager = LIBJACK_SESSION_MANAGER_NONE;
static uint gInterposedHints = 0x0; static uint gInterposedHints = 0x0;
@@ -84,8 +83,15 @@ static WindowMappingType gCurrentWindowType = WindowMapNone;
static bool gCurrentWindowMapped = false; static bool gCurrentWindowMapped = false;
static bool gCurrentWindowVisible = false; static bool gCurrentWindowVisible = false;


#ifdef HAVE_X11
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
// Calling the real functions
// Function typedefs

typedef int (*XWindowFunc)(Display*, Window);
typedef int (*XNextEventFunc)(Display*, XEvent*);

// --------------------------------------------------------------------------------------------------------------------
// Calling the real X11 functions


static int real_XMapWindow(Display* display, Window window) static int real_XMapWindow(Display* display, Window window)
{ {
@@ -350,6 +356,8 @@ int XNextEvent(Display* display, XEvent* event)
return real_XUnmapWindow(display, gCurrentlyMappedWindow); return real_XUnmapWindow(display, gCurrentlyMappedWindow);
} }


#endif // HAVE_X11

// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
// Full control helper // Full control helper


@@ -373,13 +381,16 @@ int jack_carla_interposed_action(uint action, uint value, void* ptr)
// show gui // show gui
if (value != 0) if (value != 0)
{ {
#ifdef HAVE_X11
gCurrentWindowVisible = true; gCurrentWindowVisible = true;
if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0) if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0)
#endif
{ {
carla_stdout("NOTICE: Interposer show-gui request ignored"); carla_stdout("NOTICE: Interposer show-gui request ignored");
return 0; return 0;
} }


#ifdef HAVE_X11
gCurrentWindowMapped = true; gCurrentWindowMapped = true;


switch (gCurrentWindowType) switch (gCurrentWindowType)
@@ -393,19 +404,24 @@ int jack_carla_interposed_action(uint action, uint value, void* ptr)
default: default:
return 0; return 0;
} }
#endif
} }
// hide gui // hide gui
else else
{ {
#ifdef HAVE_X11
gCurrentWindowVisible = false; gCurrentWindowVisible = false;
if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0) if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0)
#endif
{ {
carla_stdout("NOTICE: Interposer hide-gui request ignored"); carla_stdout("NOTICE: Interposer hide-gui request ignored");
return 0; return 0;
} }


#ifdef HAVE_X11
gCurrentWindowMapped = false; gCurrentWindowMapped = false;
return real_XUnmapWindow(gCurrentlyMappedDisplay, gCurrentlyMappedWindow); return real_XUnmapWindow(gCurrentlyMappedDisplay, gCurrentlyMappedWindow);
#endif
} }
break; break;


@@ -413,8 +429,10 @@ int jack_carla_interposed_action(uint action, uint value, void* ptr)
gCurrentWindowType = WindowMapNone; gCurrentWindowType = WindowMapNone;
gCurrentWindowMapped = false; gCurrentWindowMapped = false;
gCurrentWindowVisible = false; gCurrentWindowVisible = false;
#ifdef HAVE_X11
gCurrentlyMappedDisplay = nullptr; gCurrentlyMappedDisplay = nullptr;
gCurrentlyMappedWindow = 0; gCurrentlyMappedWindow = 0;
#endif
return 0; return 0;
} }




Loading…
Cancel
Save