diff options
author | Ian C <ianc@noddybox.co.uk> | 2011-06-06 08:31:49 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2011-06-06 08:31:49 +0000 |
commit | 53c4aa545e3c0d4cb836dda3f8efdbf39f5658ab (patch) | |
tree | bdaa8c3dfcf74c4a342a114396f34d28976dc592 /xd.c | |
parent | 3ce8734c49de6a2ddab6ed41cfa323a4f2f21cc8 (diff) |
Changed switch handling and added width/height switches.
Diffstat (limited to 'xd.c')
-rw-r--r-- | xd.c | 53 |
1 files changed, 36 insertions, 17 deletions
@@ -260,8 +260,8 @@ static Pixmap saved=None; static GC gc=None; static Display *disp=NULL; static XFontStruct *font=NULL; -static int width; -static int height; +static int width = 640; +static int height = 480; static int centre_x; static int centre_y; @@ -346,23 +346,45 @@ int main(int argc, char *argv[]) XEvent ev; int f; - for(f=1;f<argc;f++) + f = 1; + + while(argv[f] && argv[f][0] == '-') { - if (!strcmp(argv[f],"-r")) - { - use_root=TRUE; - } - else if (!strcmp(argv[f],"-c")) - { - cycle=TRUE; - } - else + switch(argv[f++][1]) { - demo=atoi(argv[f]); - demo=MAX(0,MIN(demo,NO_DEMOS-1)); + case 'r': + use_root = TRUE; + break; + + case 'c': + cycle = TRUE; + break; + + case 'w': + if (argv[f]) + { + width = atoi(argv[f++]); + } + break; + + case 'h': + if (argv[f]) + { + height = atoi(argv[f++]); + } + break; + + default: + break; } } + if (argv[f]) + { + demo=atoi(argv[f]); + demo=MAX(0,MIN(demo,NO_DEMOS-1)); + } + OpenX(); XMapWindow(disp,win); @@ -524,9 +546,6 @@ static void OpenX(void) Error("Couldn't load font fixed"); } - width=640; - height=480; - if (!use_root) { win=XCreateWindow |