diff --git a/source/backend/plugin/CarlaPluginJack.cpp b/source/backend/plugin/CarlaPluginJack.cpp index 0b5a68b8b..ad9b8543a 100644 --- a/source/backend/plugin/CarlaPluginJack.cpp +++ b/source/backend/plugin/CarlaPluginJack.cpp @@ -142,9 +142,7 @@ public: CarlaString ret; ret += "export LD_LIBRARY_PATH=" + binaryDir + "/jack\n"; -#ifdef HAVE_X11 ret += "export LD_PRELOAD=" + binaryDir + "/libcarla_interposer-jack-x11.so\n"; -#endif #ifdef HAVE_LIBLO if (sessionManager == LIBJACK_SESSION_MANAGER_NSM) { @@ -329,14 +327,8 @@ protected: std::snprintf(winIdStr, STR_MAX, P_UINTPTR, options.frontendWinId); 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); diff --git a/source/interposer/Makefile b/source/interposer/Makefile index ae53e1cfe..88eaf2b0b 100644 --- a/source/interposer/Makefile +++ b/source/interposer/Makefile @@ -33,13 +33,13 @@ TARGETS = ifeq ($(LINUX),true) OBJS += $(OBJDIR)/interposer-safe.cpp.o +OBJS += $(OBJDIR)/interposer-jack-x11.cpp.o TARGETS += $(BINDIR)/libcarla_interposer-safe.so +TARGETS += $(BINDIR)/libcarla_interposer-jack-x11.so ifeq ($(HAVE_X11),true) OBJS += $(OBJDIR)/interposer-x11.cpp.o -OBJS += $(OBJDIR)/interposer-jack-x11.cpp.o TARGETS += $(BINDIR)/libcarla_interposer-x11.so -TARGETS += $(BINDIR)/libcarla_interposer-jack-x11.so endif endif diff --git a/source/interposer/interposer-jack-x11.cpp b/source/interposer/interposer-jack-x11.cpp index d5a06156d..b96ed9c24 100644 --- a/source/interposer/interposer-jack-x11.cpp +++ b/source/interposer/interposer-jack-x11.cpp @@ -19,7 +19,10 @@ #include "CarlaUtils.hpp" #include -#include + +#ifdef HAVE_X11 +# include +#endif // -------------------------------------------------------------------------------------------------------------------- @@ -59,12 +62,6 @@ struct ScopedLibOpen { CARLA_DECLARE_NON_COPY_STRUCT(ScopedLibOpen); }; -// -------------------------------------------------------------------------------------------------------------------- -// Function typedefs - -typedef int (*XWindowFunc)(Display*, Window); -typedef int (*XNextEventFunc)(Display*, XEvent*); - // -------------------------------------------------------------------------------------------------------------------- // Current state @@ -75,8 +72,10 @@ typedef enum { WindowMapSubwindows } WindowMappingType; +#ifdef HAVE_X11 static Display* gCurrentlyMappedDisplay = nullptr; static Window gCurrentlyMappedWindow = 0; +#endif static CarlaInterposedCallback gInterposedCallback = nullptr; static uint gInterposedSessionManager = LIBJACK_SESSION_MANAGER_NONE; static uint gInterposedHints = 0x0; @@ -84,8 +83,15 @@ static WindowMappingType gCurrentWindowType = WindowMapNone; static bool gCurrentWindowMapped = 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) { @@ -350,6 +356,8 @@ int XNextEvent(Display* display, XEvent* event) return real_XUnmapWindow(display, gCurrentlyMappedWindow); } +#endif // HAVE_X11 + // -------------------------------------------------------------------------------------------------------------------- // Full control helper @@ -373,13 +381,16 @@ int jack_carla_interposed_action(uint action, uint value, void* ptr) // show gui if (value != 0) { +#ifdef HAVE_X11 gCurrentWindowVisible = true; if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0) +#endif { carla_stdout("NOTICE: Interposer show-gui request ignored"); return 0; } +#ifdef HAVE_X11 gCurrentWindowMapped = true; switch (gCurrentWindowType) @@ -393,19 +404,24 @@ int jack_carla_interposed_action(uint action, uint value, void* ptr) default: return 0; } +#endif } // hide gui else { +#ifdef HAVE_X11 gCurrentWindowVisible = false; if (gCurrentlyMappedDisplay == nullptr || gCurrentlyMappedWindow == 0) +#endif { carla_stdout("NOTICE: Interposer hide-gui request ignored"); return 0; } +#ifdef HAVE_X11 gCurrentWindowMapped = false; return real_XUnmapWindow(gCurrentlyMappedDisplay, gCurrentlyMappedWindow); +#endif } break; @@ -413,8 +429,10 @@ int jack_carla_interposed_action(uint action, uint value, void* ptr) gCurrentWindowType = WindowMapNone; gCurrentWindowMapped = false; gCurrentWindowVisible = false; +#ifdef HAVE_X11 gCurrentlyMappedDisplay = nullptr; gCurrentlyMappedWindow = 0; +#endif return 0; }