Mixer: Add --no-ui commandline option and non-mixer-noui executable symlink to permit running an instance of non-mixer without connecting to an X display.

This commit is contained in:
Jonathan Moore Liles 2012-07-28 15:22:31 -07:00
parent 3a999ecc86
commit ee8764495f
2 changed files with 94 additions and 50 deletions

View File

@ -28,6 +28,7 @@ clean:
install: all install: all
@ echo -n "Installing..." @ echo -n "Installing..."
@ install -Dm755 src/mixer "$(DESTDIR)$(prefix)"/bin/non-mixer @ install -Dm755 src/mixer "$(DESTDIR)$(prefix)"/bin/non-mixer
@ ln -s "$(DESTDIR)$(prefix)"/bin/non-mixer "$(DESTDIR)$(prefix)"/bin/non-mixer-noui
@ install -d "$(DESTDIR)$(SYSTEM_PATH)"/non-mixer @ install -d "$(DESTDIR)$(SYSTEM_PATH)"/non-mixer
@ $(MAKE) -s -C doc install @ $(MAKE) -s -C doc install
@ install -d "$(DESTDIR)$(PIXMAP_PATH)/non-mixer" @ install -d "$(DESTDIR)$(PIXMAP_PATH)/non-mixer"

View File

@ -57,6 +57,7 @@
#include "NSM.H" #include "NSM.H"
#include <signal.h> #include <signal.h>
#include <unistd.h>
#ifdef HAVE_XPM #ifdef HAVE_XPM
#include "FL/Fl.H" #include "FL/Fl.H"
@ -107,7 +108,7 @@ check_nsm ( void * v )
Fl::repeat_timeout( NSM_CHECK_INTERVAL, check_nsm, v ); Fl::repeat_timeout( NSM_CHECK_INTERVAL, check_nsm, v );
} }
static int got_sigterm = 0; static volatile int got_sigterm = 0;
void void
sigterm_handler ( int ) sigterm_handler ( int )
@ -129,21 +130,10 @@ check_sigterm ( void * )
int int
main ( int argc, char **argv ) main ( int argc, char **argv )
{ {
bool no_ui = false;
printf( "%s %s %s -- %s\n", APP_TITLE, VERSION, "", COPYRIGHT ); printf( "%s %s %s -- %s\n", APP_TITLE, VERSION, "", COPYRIGHT );
if ( ! Fl::visual( FL_DOUBLE | FL_RGB ) )
{
WARNING( "Xdbe not supported, FLTK will fake double buffering." );
}
#ifdef HAVE_XPM
fl_open_display();
Pixmap p, mask;
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
(char**)icon_16x16, &p, &mask, NULL);
#endif
Thread::init(); Thread::init();
Thread thread( "UI" ); Thread thread( "UI" );
@ -160,9 +150,6 @@ main ( int argc, char **argv )
Fl_Tooltip::size( 14 ); Fl_Tooltip::size( 14 );
Fl_Tooltip::hoverdelay( 0.1f ); Fl_Tooltip::hoverdelay( 0.1f );
Fl::visible_focus( 0 );
fl_register_images();
LOG_REGISTER_CREATE( Mixer_Strip ); LOG_REGISTER_CREATE( Mixer_Strip );
LOG_REGISTER_CREATE( Chain ); LOG_REGISTER_CREATE( Chain );
@ -176,36 +163,6 @@ main ( int argc, char **argv )
signal( SIGPIPE, SIG_IGN ); signal( SIGPIPE, SIG_IGN );
Fl::lock();
Fl_Double_Window *main_window;
{
Fl_Double_Window *o = main_window = new Fl_Double_Window( 800, 600, "Non-DAW : Mixer" );
{
main_window->xclass( APP_NAME );
{
Fl_Widget *o = mixer = new Mixer( 0, 0, main_window->w(), main_window->h(), NULL );
Fl_Group::current()->resizable(o);
}
}
o->end();
o->size_range( main_window->w(), mixer->min_h(), 0, 0 );
o->callback( (Fl_Callback*)cb_main, main_window );
#ifdef HAVE_XPM
o->icon((char *)p);
#endif
o->show( 0, 0 );
}
fl_register_themes();
Fl_Theme::set();
const char *osc_port = NULL; const char *osc_port = NULL;
@ -219,6 +176,7 @@ main ( int argc, char **argv )
{ "help", no_argument, 0, '?' }, { "help", no_argument, 0, '?' },
{ "instance", required_argument, 0, 'i' }, { "instance", required_argument, 0, 'i' },
{ "osc-port", required_argument, 0, 'p' }, { "osc-port", required_argument, 0, 'p' },
{ "no-ui", no_argument, 0, 'u' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
@ -240,6 +198,10 @@ main ( int argc, char **argv )
instance_name = strdup( optarg ); instance_name = strdup( optarg );
instance_override = true; instance_override = true;
break; break;
case 'u':
DMESSAGE( "Disabling user interface" );
no_ui = true;
break;
case '?': case '?':
printf( "\nUsage: %s [--instance instance_name] [--osc-port portnum] [path_to_project]\n\n", argv[0] ); printf( "\nUsage: %s [--instance instance_name] [--osc-port portnum] [path_to_project]\n\n", argv[0] );
exit(0); exit(0);
@ -247,6 +209,70 @@ main ( int argc, char **argv )
} }
} }
{
char *name = strdup( argv[0] );
char *n = basename( name );
if ( ! strcmp( n, "non-mixer-noui" ) )
no_ui = true;
free( name );
}
Pixmap p, mask;
if ( ! no_ui )
{
Fl::visual( FL_DOUBLE | FL_RGB );
#ifdef HAVE_XPM
fl_open_display();
XpmCreatePixmapFromData(fl_display, DefaultRootWindow(fl_display),
(char**)icon_16x16, &p, &mask, NULL);
#endif
Fl::visible_focus( 0 );
fl_register_images();
}
Fl::lock();
Fl_Double_Window *main_window;
{
Fl_Double_Window *o = main_window = new Fl_Double_Window( 800, 600, "Non-DAW : Mixer" );
{
main_window->xclass( APP_NAME );
{
Fl_Widget *o = mixer = new Mixer( 0, 0, main_window->w(), main_window->h(), NULL );
Fl_Group::current()->resizable(o);
}
}
o->end();
o->size_range( main_window->w(), mixer->min_h(), 0, 0 );
o->callback( (Fl_Callback*)cb_main, main_window );
if ( ! no_ui )
{
#ifdef HAVE_XPM
o->icon((char *)p);
#endif
o->show( 0, 0 );
}
}
if ( ! no_ui )
{
fl_register_themes();
Fl_Theme::set();
}
Plugin_Module::spawn_discover_thread(); Plugin_Module::spawn_discover_thread();
mixer->init_osc( osc_port ); mixer->init_osc( osc_port );
@ -265,8 +291,11 @@ main ( int argc, char **argv )
nsm->announce( APP_NAME, ":switch:dirty:", argv[0] ); nsm->announce( APP_NAME, ":switch:dirty:", argv[0] );
// poll so we can keep OSC handlers running in the GUI thread and avoid extra sync /* if ( ! no_ui ) */
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL ); /* { */
// poll so we can keep OSC handlers running in the GUI thread and avoid extra sync
Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL );
/* } */
} }
} }
else else
@ -288,8 +317,22 @@ main ( int argc, char **argv )
mixer->say_hello(); mixer->say_hello();
Fl::add_check( check_sigterm ); Fl::add_check( check_sigterm );
if ( ! no_ui )
{
DMESSAGE( "Running UI..." );
Fl::run(); Fl::run();
}
else
{
DMESSAGE( "Not Running UI..." );
while ( ! got_sigterm )
{
Fl::check();
usleep( 200 * 1000 );
}
}
delete main_window; delete main_window;
main_window = NULL; main_window = NULL;