@@ -208,6 +208,11 @@ class CarlaApplication(object): | |||||
self.fApp.setPalette(self.fPalBlue) | self.fApp.setPalette(self.fPalBlue) | ||||
def createApp(self, appName): | def createApp(self, appName): | ||||
QApplication.setAttribute(Qt.AA_X11InitThreads) | |||||
if MACOS: | |||||
QApplication.setAttribute(Qt.AA_DontShowIconsInMenus) | |||||
self.fApp = QApplication(sys.argv) | self.fApp = QApplication(sys.argv) | ||||
self.fApp.setApplicationName(appName) | self.fApp.setApplicationName(appName) | ||||
self.fApp.setApplicationVersion(VERSION) | self.fApp.setApplicationVersion(VERSION) | ||||
@@ -218,9 +223,6 @@ class CarlaApplication(object): | |||||
else: | else: | ||||
self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg")) | self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg")) | ||||
if MACOS: | |||||
self.fApp.setAttribute(Qt.AA_DontShowIconsInMenus) | |||||
print("Using \"%s\" theme" % self.fApp.style().objectName()) | print("Using \"%s\" theme" % self.fApp.style().objectName()) | ||||
def arguments(self): | def arguments(self): | ||||
@@ -298,14 +298,15 @@ public: | |||||
rootwin = new X_rootwin(display); | rootwin = new X_rootwin(display); | ||||
mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient, this); | mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient, this); | ||||
rootwin->handle_event(); | |||||
mainwin->x_set_title(getUiName()); | |||||
handler = new X_handler(display, mainwin, EV_X11); | |||||
mainwin->x_set_title(getUiName()); | |||||
if (const uintptr_t winId = getUiParentId()) | if (const uintptr_t winId = getUiParentId()) | ||||
XSetTransientForHint(display->dpy(), mainwin->win(), static_cast<Window>(winId)); | XSetTransientForHint(display->dpy(), mainwin->win(), static_cast<Window>(winId)); | ||||
rootwin->handle_event(); | |||||
handler = new X_handler(display, mainwin, EV_X11); | |||||
handler->next_event(); | handler->next_event(); | ||||
XFlush(display->dpy()); | XFlush(display->dpy()); | ||||
@@ -88,7 +88,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc | |||||
} | } | ||||
RotaryCtl::init (disp ()); | |||||
x = 270; | x = 270; | ||||
_rotary [R_TUNE] = new Rlinctl (this, this, R_TUNE, &r_tune_geom, x, 0, 400, 5, 400.0, 480.0, 440.0); | _rotary [R_TUNE] = new Rlinctl (this, this, R_TUNE, &r_tune_geom, x, 0, 400, 5, 400.0, 480.0, 440.0); | ||||
_rotary [R_BIAS] = new Rlinctl (this, this, R_BIAS, &r_bias_geom, x, 0, 270, 5, 0.0, 1.0, 0.5); | _rotary [R_BIAS] = new Rlinctl (this, this, R_BIAS, &r_bias_geom, x, 0, 270, 5, 0.0, 1.0, 0.5); | ||||
@@ -111,7 +110,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc | |||||
Mainwin::~Mainwin (void) | Mainwin::~Mainwin (void) | ||||
{ | { | ||||
RotaryCtl::fini (); | |||||
} | } | ||||
@@ -28,9 +28,6 @@ | |||||
namespace AT1 { | namespace AT1 { | ||||
cairo_t *RotaryCtl::_cairotype = 0; | |||||
cairo_surface_t *RotaryCtl::_cairosurf = 0; | |||||
int RotaryCtl::_wb_up = 4; | int RotaryCtl::_wb_up = 4; | ||||
int RotaryCtl::_wb_dn = 5; | int RotaryCtl::_wb_dn = 5; | ||||
@@ -62,6 +59,10 @@ RotaryCtl::RotaryCtl (X_window *parent, | |||||
{ | { | ||||
x_add_events ( ExposureMask | x_add_events ( ExposureMask | ||||
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | | Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | ||||
_cairo->initIfNeeded(parent->disp()); | |||||
_cairotype = _cairo->type; | |||||
_cairosurf = _cairo->surf; | |||||
} | } | ||||
@@ -70,19 +71,6 @@ RotaryCtl::~RotaryCtl (void) | |||||
} | } | ||||
void RotaryCtl::init (X_display *disp) | |||||
{ | |||||
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50); | |||||
_cairotype = cairo_create (_cairosurf); | |||||
} | |||||
void RotaryCtl::fini (void) | |||||
{ | |||||
cairo_destroy (_cairotype); | |||||
cairo_surface_destroy (_cairosurf); | |||||
} | |||||
void RotaryCtl::handle_event (XEvent *E) | void RotaryCtl::handle_event (XEvent *E) | ||||
{ | { | ||||
@@ -72,9 +72,6 @@ public: | |||||
virtual void set_value (double v) = 0; | virtual void set_value (double v) = 0; | ||||
virtual void get_string (char *p, int n) {} | virtual void get_string (char *p, int n) {} | ||||
static void init (X_display *disp); | |||||
static void fini (void); | |||||
static int _wb_up; | static int _wb_up; | ||||
static int _wb_dn; | static int _wb_dn; | ||||
@@ -109,8 +106,9 @@ private: | |||||
virtual int handle_motion (int dx, int dy) = 0; | virtual int handle_motion (int dx, int dy) = 0; | ||||
virtual int handle_mwheel (int dw) = 0; | virtual int handle_mwheel (int dw) = 0; | ||||
static cairo_t *_cairotype; | |||||
static cairo_surface_t *_cairosurf; | |||||
juce::SharedResourcePointer<x_cairo_t> _cairo; | |||||
cairo_t *_cairotype; | |||||
cairo_surface_t *_cairosurf; | |||||
}; | }; | ||||
@@ -56,7 +56,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc | |||||
H.rclas (xres->rclas ()); | H.rclas (xres->rclas ()); | ||||
x_apply (&H); | x_apply (&H); | ||||
RotaryCtl::init (disp ()); | |||||
_rotary [INPBAL] = new Rlinctl (this, this, &inpbal_img, 20, 0, 120, 4, -3.0f, 3.0f, 0.0f, INPBAL); | _rotary [INPBAL] = new Rlinctl (this, this, &inpbal_img, 20, 0, 120, 4, -3.0f, 3.0f, 0.0f, INPBAL); | ||||
_rotary [HPFILT] = new Rlogctl (this, this, &hpfilt_img, 20, 0, 120, 4, 10.0f, 320.0f, 40.0f, HPFILT); | _rotary [HPFILT] = new Rlogctl (this, this, &hpfilt_img, 20, 0, 120, 4, 10.0f, 320.0f, 40.0f, HPFILT); | ||||
_rotary [SHGAIN] = new Rlinctl (this, this, &shgain_img, 190, 0, 120, 5, 0.0f, 24.0f, 15.0f, SHGAIN); | _rotary [SHGAIN] = new Rlinctl (this, this, &shgain_img, 190, 0, 120, 5, 0.0f, 24.0f, 15.0f, SHGAIN); | ||||
@@ -79,7 +78,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc | |||||
Mainwin::~Mainwin (void) | Mainwin::~Mainwin (void) | ||||
{ | { | ||||
RotaryCtl::fini (); | |||||
} | } | ||||
@@ -134,8 +132,6 @@ void Mainwin::handle_time (void) | |||||
{ | { | ||||
if (--_timeout == 0) numdisp (-1); | if (--_timeout == 0) numdisp (-1); | ||||
} | } | ||||
inc_time (100000); | |||||
XFlush (dpy ()); | |||||
if (_touch && _jclient->shuffler ()->ready ()) | if (_touch && _jclient->shuffler ()->ready ()) | ||||
{ | { | ||||
@@ -145,6 +141,9 @@ void Mainwin::handle_time (void) | |||||
_valuecb->valueChangedCallback (SHFREQ, v2); | _valuecb->valueChangedCallback (SHFREQ, v2); | ||||
_touch = 0; | _touch = 0; | ||||
} | } | ||||
inc_time (50000); | |||||
XFlush (dpy ()); | |||||
} | } | ||||
@@ -28,8 +28,6 @@ | |||||
namespace BLS1 { | namespace BLS1 { | ||||
cairo_t *RotaryCtl::_cairotype = 0; | |||||
cairo_surface_t *RotaryCtl::_cairosurf = 0; | |||||
int RotaryCtl::_wb_up = 4; | int RotaryCtl::_wb_up = 4; | ||||
int RotaryCtl::_wb_dn = 5; | int RotaryCtl::_wb_dn = 5; | ||||
@@ -61,6 +59,10 @@ RotaryCtl::RotaryCtl (X_window *parent, | |||||
{ | { | ||||
x_add_events ( ExposureMask | x_add_events ( ExposureMask | ||||
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | | Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | ||||
_cairo->initIfNeeded(parent->disp()); | |||||
_cairotype = _cairo->type; | |||||
_cairosurf = _cairo->surf; | |||||
} | } | ||||
@@ -69,20 +71,6 @@ RotaryCtl::~RotaryCtl (void) | |||||
} | } | ||||
void RotaryCtl::init (X_display *disp) | |||||
{ | |||||
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50); | |||||
_cairotype = cairo_create (_cairosurf); | |||||
} | |||||
void RotaryCtl::fini (void) | |||||
{ | |||||
cairo_destroy (_cairotype); | |||||
cairo_surface_destroy (_cairosurf); | |||||
} | |||||
void RotaryCtl::handle_event (XEvent *E) | void RotaryCtl::handle_event (XEvent *E) | ||||
{ | { | ||||
switch (E->type) | switch (E->type) | ||||
@@ -73,9 +73,6 @@ public: | |||||
virtual void set_value (double v) = 0; | virtual void set_value (double v) = 0; | ||||
virtual void get_string (char *p, int n) {} | virtual void get_string (char *p, int n) {} | ||||
static void init (X_display *disp); | |||||
static void fini (void); | |||||
static int _wb_up; | static int _wb_up; | ||||
static int _wb_dn; | static int _wb_dn; | ||||
@@ -110,8 +107,9 @@ private: | |||||
virtual int handle_motion (int dx, int dy) = 0; | virtual int handle_motion (int dx, int dy) = 0; | ||||
virtual int handle_mwheel (int dw) = 0; | virtual int handle_mwheel (int dw) = 0; | ||||
static cairo_t *_cairotype; | |||||
static cairo_surface_t *_cairosurf; | |||||
juce::SharedResourcePointer<x_cairo_t> _cairo; | |||||
cairo_t *_cairotype; | |||||
cairo_surface_t *_cairosurf; | |||||
}; | }; | ||||
@@ -25,11 +25,40 @@ | |||||
#include <png.h> | #include <png.h> | ||||
#include <clxclient.h> | #include <clxclient.h> | ||||
#include <cairo/cairo.h> | |||||
#include <cairo/cairo-xlib.h> | |||||
#define EV_X11 16 | #define EV_X11 16 | ||||
#define EV_EXIT 31 | #define EV_EXIT 31 | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
struct x_cairo_t { | |||||
cairo_t * type; | |||||
cairo_surface_t* surf; | |||||
x_cairo_t() noexcept | |||||
: type(nullptr), | |||||
surf(nullptr) {} | |||||
~x_cairo_t() | |||||
{ | |||||
cairo_destroy(type); | |||||
cairo_surface_destroy(surf); | |||||
} | |||||
void initIfNeeded(X_display* const disp) | |||||
{ | |||||
if (surf != nullptr) | |||||
return; | |||||
surf = cairo_xlib_surface_create(disp->dpy(), 0, disp->dvi(), 50, 50); | |||||
type = cairo_create(surf); | |||||
} | |||||
}; | |||||
// ----------------------------------------------------------------------- | |||||
struct X_handler_Param { | struct X_handler_Param { | ||||
uint32_t index; | uint32_t index; | ||||
float value; | float value; | ||||
@@ -132,46 +161,41 @@ private: | |||||
{ | { | ||||
for (; ! shouldThreadExit();) | for (; ! shouldThreadExit();) | ||||
{ | { | ||||
int ev; | |||||
{ | |||||
const CarlaMutexLocker cml(fMutex); | |||||
CARLA_SAFE_ASSERT_RETURN(fMainwin != nullptr,); | |||||
{ | |||||
const CarlaMutexLocker cml(fParamMutex); | |||||
const CarlaMutexLocker cml(fMutex); | |||||
for (ParamList::Itenerator it = fParamChanges.begin(); it.valid(); it.next()) | |||||
{ | |||||
const X_handler_Param& param(it.getValue()); | |||||
fCallback->setParameterValueFromHandlerThread(param.index, param.value); | |||||
} | |||||
CARLA_SAFE_ASSERT_RETURN(fMainwin != nullptr,); | |||||
fParamChanges.clear(); | |||||
} | |||||
{ | |||||
const CarlaMutexLocker cml(fParamMutex); | |||||
for (; (ev = fMainwin->process()) == EV_X11;) | |||||
for (ParamList::Itenerator it = fParamChanges.begin(); it.valid(); it.next()) | |||||
{ | { | ||||
fRootwin->handle_event(); | |||||
fHandler->next_event(); | |||||
const X_handler_Param& param(it.getValue()); | |||||
fCallback->setParameterValueFromHandlerThread(param.index, param.value); | |||||
} | } | ||||
if (ev == Esync::EV_TIME) | |||||
{ | |||||
fRootwin->handle_event(); | |||||
} | |||||
else if (ev == EV_EXIT) | |||||
{ | |||||
fClosed = true; | |||||
fHandler = nullptr; | |||||
fMainwin = nullptr; | |||||
fRootwin = nullptr; | |||||
return; | |||||
} | |||||
fParamChanges.clear(); | |||||
} | } | ||||
carla_msleep(10); | |||||
switch (fMainwin->process()) | |||||
{ | |||||
case EV_X11: | |||||
fRootwin->handle_event(); | |||||
fHandler->next_event(); | |||||
break; | |||||
case EV_EXIT: | |||||
fClosed = true; | |||||
fHandler = nullptr; | |||||
fMainwin = nullptr; | |||||
fRootwin = nullptr; | |||||
return; | |||||
case Esync::EV_TIME: | |||||
fRootwin->handle_event(); | |||||
break; | |||||
default: | |||||
carla_stdout("custom X11 event for zita plugs"); | |||||
break; | |||||
} | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
@@ -56,7 +56,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc | |||||
x_apply (&H); | x_apply (&H); | ||||
_ambis = xres->getb (".ambisonic", false); | _ambis = xres->getb (".ambisonic", false); | ||||
RotaryCtl::init (disp ()); | |||||
x = 0; | x = 0; | ||||
_rotary [R_DELAY] = new Rlinctl (this, this, &r_delay_img, x, 0, 160, 5, 0.02, 0.100, 0.04, R_DELAY); | _rotary [R_DELAY] = new Rlinctl (this, this, &r_delay_img, x, 0, 160, 5, 0.02, 0.100, 0.04, R_DELAY); | ||||
_rotary [R_XOVER] = new Rlogctl (this, this, &r_xover_img, x, 0, 200, 5, 50.0, 1000.0, 200.0, R_XOVER); | _rotary [R_XOVER] = new Rlogctl (this, this, &r_xover_img, x, 0, 200, 5, 50.0, 1000.0, 200.0, R_XOVER); | ||||
@@ -79,13 +78,12 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc | |||||
x_add_events (ExposureMask); | x_add_events (ExposureMask); | ||||
x_map (); | x_map (); | ||||
set_time (0); | set_time (0); | ||||
inc_time (500000); | |||||
inc_time (250000); | |||||
} | } | ||||
Mainwin::~Mainwin (void) | Mainwin::~Mainwin (void) | ||||
{ | { | ||||
RotaryCtl::fini (); | |||||
} | } | ||||
@@ -137,7 +135,7 @@ void Mainwin::clmesg (XClientMessageEvent *E) | |||||
void Mainwin::handle_time (void) | void Mainwin::handle_time (void) | ||||
{ | { | ||||
inc_time (500000); | inc_time (500000); | ||||
// XFlush (dpy ()); | |||||
XFlush (dpy ()); | |||||
} | } | ||||
@@ -28,9 +28,6 @@ | |||||
namespace REV1 { | namespace REV1 { | ||||
cairo_t *RotaryCtl::_cairotype = 0; | |||||
cairo_surface_t *RotaryCtl::_cairosurf = 0; | |||||
int RotaryCtl::_wb_up = 4; | int RotaryCtl::_wb_up = 4; | ||||
int RotaryCtl::_wb_dn = 5; | int RotaryCtl::_wb_dn = 5; | ||||
int RotaryCtl::_keymod = 0; | int RotaryCtl::_keymod = 0; | ||||
@@ -61,6 +58,10 @@ RotaryCtl::RotaryCtl (X_window *parent, | |||||
{ | { | ||||
x_add_events ( ExposureMask | x_add_events ( ExposureMask | ||||
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | | Button1MotionMask | ButtonPressMask | ButtonReleaseMask); | ||||
_cairo->initIfNeeded(parent->disp()); | |||||
_cairotype = _cairo->type; | |||||
_cairosurf = _cairo->surf; | |||||
} | } | ||||
@@ -69,20 +70,6 @@ RotaryCtl::~RotaryCtl (void) | |||||
} | } | ||||
void RotaryCtl::init (X_display *disp) | |||||
{ | |||||
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50); | |||||
_cairotype = cairo_create (_cairosurf); | |||||
} | |||||
void RotaryCtl::fini (void) | |||||
{ | |||||
cairo_destroy (_cairotype); | |||||
cairo_surface_destroy (_cairosurf); | |||||
} | |||||
void RotaryCtl::handle_event (XEvent *E) | void RotaryCtl::handle_event (XEvent *E) | ||||
{ | { | ||||
switch (E->type) | switch (E->type) | ||||
@@ -72,9 +72,6 @@ public: | |||||
virtual void set_value (double v) = 0; | virtual void set_value (double v) = 0; | ||||
virtual void get_string (char *p, int n) {} | virtual void get_string (char *p, int n) {} | ||||
static void init (X_display *disp); | |||||
static void fini (void); | |||||
static int _wb_up; | static int _wb_up; | ||||
static int _wb_dn; | static int _wb_dn; | ||||
@@ -109,8 +106,9 @@ private: | |||||
virtual int handle_motion (int dx, int dy) = 0; | virtual int handle_motion (int dx, int dy) = 0; | ||||
virtual int handle_mwheel (int dw) = 0; | virtual int handle_mwheel (int dw) = 0; | ||||
static cairo_t *_cairotype; | |||||
static cairo_surface_t *_cairosurf; | |||||
juce::SharedResourcePointer<x_cairo_t> _cairo; | |||||
cairo_t *_cairotype; | |||||
cairo_surface_t *_cairosurf; | |||||
}; | }; | ||||