From b0a5ae05707561d06ccf161861b1875ad5a8cff6 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Tue, 6 Dec 2011 13:48:57 +0200 Subject: setup default values on definition --- dminiwm.c | 78 +++++++++++++++++---------------------------------------------- 1 file changed, 21 insertions(+), 57 deletions(-) diff --git a/dminiwm.c b/dminiwm.c index ce28652..150a15d 100644 --- a/dminiwm.c +++ b/dminiwm.c @@ -140,23 +140,23 @@ static void update_current(void); /* variables */ static Display *dis; -static Bool running; -static int current_desktop; -static int previous_desktop; -static int growth; +static Bool running = True; +static int current_desktop = 0; +static int previous_desktop = 0; +static int growth = 0; +static int mode = DEFAULT_MODE; static int master_size; -static int mode; static int sh; static int sw; static int screen; +static Window root; static int xerror(Display *dis, XErrorEvent *ee); static int (*xerrorxlib)(Display *, XErrorEvent *); static unsigned int win_focus; static unsigned int win_unfocus; -static unsigned int numlockmask; /* dynamic key lock mask */ -static Window root; -static client *head; -static client *current; +static unsigned int numlockmask = 0; /* dynamic key lock mask */ +static client *head = NULL; +static client *current = NULL; /* events array */ static void (*events[LASTEvent])(XEvent *e) = { @@ -843,75 +843,39 @@ void quit(const Arg arg) { } void setup(void) { - // Install a signal sigchld(0); - // Screen and root window screen = DefaultScreen(dis); root = RootWindow(dis,screen); - // Screen width and height - sw = XDisplayWidth(dis,screen) - BORDER_WIDTH; - sh = (XDisplayHeight(dis,screen) - PANEL_HEIGHT) - BORDER_WIDTH; + sw = XDisplayWidth(dis,screen) - BORDER_WIDTH; + sh = XDisplayHeight(dis,screen) - PANEL_HEIGHT - BORDER_WIDTH; + + master_size = ((mode == BSTACK) ? sh : sw) * MASTER_SIZE; + for(int i=0; i < DESKTOPS; i++) + save_desktop(i); + change_desktop((Arg){.i = 0}); - // Colors win_focus = getcolor(FOCUS); win_unfocus = getcolor(UNFOCUS); - // numlock workaround - int j, k; XModifierKeymap *modmap; - numlockmask = 0; modmap = XGetModifierMapping(dis); - for (k = 0; k < 8; k++) { - for (j = 0; j < modmap->max_keypermod; j++) { + for (int k = 0; k < 8; k++) { + for (int j = 0; j < modmap->max_keypermod; j++) { if(modmap->modifiermap[k * modmap->max_keypermod + j] == XKeysymToKeycode(dis, XK_Num_Lock)) numlockmask = (1 << k); } } XFreeModifiermap(modmap); - // Shortcuts - grabkeys(); - - /* FIXME: move defaults to declerations */ - // Default stack - mode = DEFAULT_MODE; - growth = 0; - - // For exiting - running = True; - - // List of client - head = NULL; - current = NULL; - - // Master size - if(mode == BSTACK) - master_size = sh*MASTER_SIZE; - else - master_size = sw*MASTER_SIZE; - - // Set up all desktop - int i; - for(i=0;i