33 #include <glibmm/timer.h>
57 const char magic[] =
"VSTFX Plugin State v002";
83 int getXWindowProperty(Window window, Atom atom)
88 unsigned long userCount;
114 result = *(
int*)data;
116 XSetErrorHandler(olderrorhandler);
132 long getXWindowProperty(Window window, Atom atom)
137 unsigned long userCount;
163 result = *(
long*)data;
165 XSetErrorHandler(olderrorhandler);
186 case ConfigureNotify:
188 Window window =
event->xconfigure.event;
190 int width =
event->xconfigure.width;
191 int height =
event->xconfigure.height;
201 if (width != vstfx->
width || height!=vstfx->
height) {
202 vstfx->
width = width;
225 Window ParentWindow =
event->xreparent.parent;
239 Window PluginUIWindowID =
event->xreparent.window;
243 int result = getXWindowProperty(PluginUIWindowID, XInternAtom(
LXVST_XDisplay,
"_XEventProc",
false));
248 vstfx->
eventProc = (void (*) (
void* event))result;
252 long result = getXWindowProperty(PluginUIWindowID, XInternAtom(
LXVST_XDisplay,
"_XEventProc",
false));
257 vstfx->
eventProc = (void (*) (
void* event))result;
265 Window window =
event->xany.window;
266 Atom message_type =
event->xclient.message_type;
275 if (strcmp(message,
"LaunchEditor") == 0) {
276 if (event->xclient.data.l[0] == 0x0FEEDBAC) {
336 int LXVST_sched_timer_interval = 40;
338 uint64_t clock1, clock2;
340 clock1 = g_get_monotonic_time();
365 for (vstfx = vstfx_first; vstfx; vstfx = vstfx->
next)
367 pthread_mutex_lock(&vstfx->
lock);
371 pthread_mutex_unlock(&vstfx->
lock);
384 clock2 = g_get_monotonic_time();
385 const int64_t elapsed_time_ms = (clock2 - clock1) / 1000;
387 if((LXVST_sched_timer_interval != 0) && elapsed_time_ms >= LXVST_sched_timer_interval)
395 for (vstfx = vstfx_first; vstfx; vstfx = vstfx->
next)
397 pthread_mutex_lock (&vstfx->
lock);
414 pthread_mutex_unlock (&vstfx->
lock);
427 pthread_mutex_unlock (&vstfx->
lock);
461 pthread_mutex_unlock (&vstfx->
lock);
465 clock1 = g_get_monotonic_time();
481 int thread_create_result;
483 pthread_attr_t thread_attributes;
487 pthread_attr_init(&thread_attributes);
492 pthread_attr_setdetachstate(&thread_attributes, PTHREAD_CREATE_JOINABLE);
508 vstfx_error (
"** ERROR ** VSTFX: Failed opening connection to X");
519 if(thread_create_result!=0)
523 vstfx_error (
"** ERROR ** VSTFX: Failed starting GUI event thread");
553 if (vstfx_first == NULL) {
572 pthread_mutex_lock (&vstfx->
lock);
578 pthread_mutex_unlock (&vstfx->
lock);
593 Window parent_window;
609 parent_window = XCreateSimpleWindow (
626 SubstructureNotifyMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | ExposureMask);
630 vstfx->
xid = parent_window;
643 XClientMessageEvent event;
647 Atom WindowActiveAtom = XInternAtom(
LXVST_XDisplay,
"LaunchEditor",
false);
649 event.type = ClientMessage;
650 event.send_event =
true;
651 event.window = parent_window;
652 event.message_type = WindowActiveAtom;
655 event.data.l[0] = 0x0FEEDBAC;
659 XSendEvent(
LXVST_XDisplay, parent_window, FALSE, NoEventMask, (XEvent*)&event);
663 pthread_mutex_unlock (&vstfx->
lock);
681 Window parent_window;
711 Glib::usleep(100000);
720 vstfx->
width = x_size;
723 XResizeWindow(LXVST_XDisplay, parent_window, x_size, y_size);
725 XFlush (LXVST_XDisplay);
743 pthread_mutex_lock (&vstfx->
lock);
748 pthread_mutex_unlock (&vstfx->
lock);
765 for (p = vstfx_first, prev = NULL; p; prev = p, p = p->
next) {
778 if (vstfx_first == vstfx) {
779 vstfx_first = vstfx_first->
next;
static void dispatch_x_events(XEvent *event, VSTState *vstfx)
pthread_cond_t window_status_change
static pthread_mutex_t plugin_mutex
static void maybe_set_program(VSTState *vstfx)
LIBARDOUR_API void vstfx_error(const char *fmt,...)
static VSTState * vstfx_first
int want_resize
Set to signal the plugin resized its UI.
void * gui_event_loop(void *ptr)
intptr_t(* dispatcher)(struct _AEffect *, int, int, intptr_t, void *, float)
int linux_plugin_ui_window
The ID of the plugin UI window created by the plugin.
pthread_cond_t plugin_dispatcher_called
int vstfx_run_editor(VSTState *vstfx)
int vstfx_create_editor(VSTState *vstfx)
pthread_t LXVST_gui_event_thread
#define effFlagsHasEditor
void vstfx_destroy_editor(VSTState *vstfx)
int vstfx_init(void *ptr)
void vstfx_event_loop_remove_plugin(VSTState *vstfx)
int TempErrorHandler(Display *display, XErrorEvent *e)
void(* eventProc)(void *event)
unsigned char * wanted_chunk
int pthread_create(pthread_t *__restrict thread, __const pthread_attr_t *__restrict attr, void *(*start_routine)(void *), void *__restrict arg)
int vstfx_launch_editor(VSTState *vstfx)
int linux_window
The plugin's parent X11 XWindow.