added -g commandline option to set window position on startup

This commit is contained in:
niels
2011-06-12 15:36:21 +02:00
parent 92d605ce6c
commit 3d24bf351f
3 changed files with 36 additions and 2 deletions

View File

@@ -48,6 +48,7 @@ static int ph = 144;
static int preview = 0; // off
static int use_threads = 0;
static char midi_file[1024];
static int geom_[2] = { -1 , -1};
static struct
{
char *file;
@@ -74,6 +75,7 @@ static void usage(char *progname)
printf( "-l\t\tChoose layout (0=large screen, 1=small screens)\n");
printf( "-V\t\tShow version, data directory and exit.\n");
printf( "-m <file>\tMIDI configuration file.\n");
printf( "-g\t\t<X,Y>\tWindow position on screen.\n");
printf( "\n\n");
exit(-1);
}
@@ -130,6 +132,15 @@ static int set_option( const char *name, char *value )
strcpy(midi_file, optarg);
load_midi = 1;
}
else if (strcmp(name,"g") == 0 ) {
if(sscanf( optarg, "%d,%d",&geom_[0],&geom_[1]) != 2 ) {
fprintf(stderr, "invalid screen coordinates:%s\n",optarg);
} else {
fprintf(stdout, "Place window at %d,%d", geom_[0],geom_[1]);
vj_gui_set_geom(geom_[0],geom_[1]);
}
}
else if (strcmp(name, "P" ) == 0 || strcmp(name, "preview" ) == 0 )
{
preview = atoi(optarg);
@@ -204,7 +215,7 @@ int main(int argc, char *argv[]) {
// default host to connect to
sprintf(hostname, "127.0.0.1");
while( ( n = getopt( argc, argv, "s:h:p:tnvHf:X:P:Vl:T:m:")) != EOF )
while( ( n = getopt( argc, argv, "s:h:p:tnvHf:X:P:Vl:T:m:g:")) != EOF )
{
sprintf(option, "%c", n );
err += set_option( option, optarg);

View File

@@ -293,7 +293,7 @@ static int vims_verbosity = 0;
#define livido_port_t vevo_port_t
static int cali_stream_id = 0;
static int cali_onoff = 0;
static int geo_pos_[2] = { -1,-1 };
static vevo_port_t *fx_list_ = NULL;
typedef struct
@@ -6805,6 +6805,12 @@ static void debug_spinboxes()
}
}
void vj_gui_set_geom( int x, int y )
{
geo_pos_[0] = x;
geo_pos_[1] = y;
}
void vj_gui_init(char *glade_file, int launcher, char *hostname, int port_num, int use_threads, int load_midi , char *midi_file)
{
int i;
@@ -7026,6 +7032,15 @@ void vj_gui_init(char *glade_file, int launcher, char *hostname, int port_num,
if( load_midi )
vj_midi_load(info->midi,midi_file);
GtkWidget *lw = glade_xml_get_widget_( info->main_window, "veejay_connection");
if( geo_pos_[0] >= 0 && geo_pos_[1] >= 0 )
gtk_window_move( lw, geo_pos_[0], geo_pos_[1] );
}
void vj_gui_preview(void)
@@ -7139,6 +7154,9 @@ int vj_gui_reconnect(char *hostname,char *group_name, int port_num)
GtkWidget *w = glade_xml_get_widget_(info->main_window, "gveejay_window" );
gtk_widget_show( w );
if( geo_pos_[0] >= 0 && geo_pos_[1] >= 0 )
gtk_window_move( w, geo_pos_[0], geo_pos_[1] );
/* int speed = info->status_tokens[SAMPLE_SPEED];
if( speed < 0 )
@@ -7177,6 +7195,10 @@ static void veejay_stop_connecting(vj_gui_t *gui)
GtkWidget *mw = glade_xml_get_widget_(info->main_window,"gveejay_window" );
gtk_widget_show( mw );
if( geo_pos_[0] >= 0 && geo_pos_[1] >= 0 )
gtk_window_move( mw, geo_pos_[0], geo_pos_[1] );
}
void reloaded_launcher(char *hostname, int port_num)

View File

@@ -21,6 +21,7 @@
#define VJAPI_H
int veejay_tick();
void *get_ui_info();
void vj_gui_set_geom(int x, int y);
void vj_gui_init(char *glade_file, int launcher, char *hostname, int port_num, int threads,int load_midi, char *midi_file);
int vj_gui_reconnect( char *host, char *group, int port);
void vj_gui_free();