diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-22 15:07:48 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-22 15:28:02 +0100 |
commit | 7c52a3cf5243b42b632fd73789d1b484e81b9b0c (patch) | |
tree | 7d303d347fd1d3201801486d676bbae246fab35f /overlay/overlay.c | |
parent | 184786988e5d78ae230139d76691b9ce7f97dca6 (diff) |
overlay: Rudiments of config files and option parsing
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay/overlay.c')
-rw-r--r-- | overlay/overlay.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/overlay/overlay.c b/overlay/overlay.c index e783a6f4..ce3b6453 100644 --- a/overlay/overlay.c +++ b/overlay/overlay.c @@ -33,9 +33,11 @@ #include <fcntl.h> #include <errno.h> #include <signal.h> +#include <getopt.h> #include "overlay.h" #include "chart.h" +#include "config.h" #include "cpu-top.h" #include "debugfs.h" #include "gem-objects.h" @@ -710,24 +712,49 @@ static void signal_snapshot(int sig) int main(int argc, char **argv) { + static struct option long_options[] = { + {"config", 1, 0, 'c'}, + {"geometry", 1, 0, 'G'}, + {"position", 1, 0, 'P'}, + {NULL, 0, 0, 0,} + }; struct overlay_context ctx; - int i = 0; + struct config config; + int index; + int i; + + config_init(&config); + + opterr = 0; + while ((i = getopt_long(argc, argv, "c:", long_options, &index)) != -1) { + switch (i) { + case 'c': + config_parse_string(&config, optarg); + break; + case 'G': + config_set_value(&config, "window", "geometry", optarg); + break; + case 'P': + config_set_value(&config, "window", "position", optarg); + break; + } + } - if (argc > 1) { + if (argc > optind) { x11_overlay_stop(); return 0; } - signal(SIGUSR1, signal_snapshot); - ctx.width = 640; ctx.height = 236; - ctx.surface = x11_overlay_create(POS_TOP_RIGHT, &ctx.width, &ctx.height); + ctx.surface = x11_overlay_create(&config, &ctx.width, &ctx.height); if (ctx.surface == NULL) - ctx.surface = x11_window_create(POS_TOP_RIGHT, &ctx.width, &ctx.height); + ctx.surface = x11_window_create(&config, &ctx.width, &ctx.height); if (ctx.surface == NULL) return ENOMEM; + signal(SIGUSR1, signal_snapshot); + debugfs_init(); init_gpu_top(&ctx, &ctx.gpu_top); @@ -735,6 +762,7 @@ int main(int argc, char **argv) init_gpu_freq(&ctx, &ctx.gpu_freq); init_gem_objects(&ctx, &ctx.gem_objects); + i = 0; while (1) { usleep(500*1000); |