From b74adc8c8eea5b56ac1bf58f0095f8a3322ae138 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Fri, 22 Aug 2014 21:15:40 +0000 Subject: readd round selector flag --- spectrogram.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/spectrogram.c b/spectrogram.c index 294ce1f..31f2c25 100644 --- a/spectrogram.c +++ b/spectrogram.c @@ -135,9 +135,10 @@ void usage(void) { fprintf(stderr, "Usage: %s [-dh]\n", __progname); - fprintf(stderr, "\t-d\tdaemonize\n"); - fprintf(stderr, "\t-f\tfullscreen\n"); - fprintf(stderr, "\t-h\tthis help\n"); + fprintf(stderr, "\t-d\t\tdaemonize\n"); + fprintf(stderr, "\t-f\t\tfullscreen\n"); + fprintf(stderr, "\t-r \tsio round\n"); + fprintf(stderr, "\t-h\t\tthis help\n"); exit(0); } @@ -416,7 +417,7 @@ main(int argc, char **argv) unsigned long black, white; float factor = 0.75; int round = 1024; /* FFT is fastest with powers of two */ - while ((ch = getopt(argc, argv, "dfh")) != -1) + while ((ch = getopt(argc, argv, "dfr:h")) != -1) switch (ch) { case 'd': dflag = 1; @@ -424,6 +425,9 @@ main(int argc, char **argv) case 'f': fflag = 1; break; + case 'r': + round = atoi(optarg); + break; case 'h': default: usage(); @@ -441,14 +445,13 @@ main(int argc, char **argv) if (!dsp) errx(1, "Cannot connect to X11 server"); - if (fflag) { - XGetWindowAttributes(dsp, DefaultRootWindow(dsp), &wa); + XGetWindowAttributes(dsp, DefaultRootWindow(dsp), &wa); + width = round + HGAP; + height = factor * width; + if (fflag || width > wa.width || height > wa.height) { round = wa.width - HGAP; width = wa.width; height = wa.height; - } else { - width = round + HGAP; - height = factor * width; } sio = init_sio(round); -- cgit v1.2.3