X-Git-Url: http://pileus.org/git/?p=wmpus;a=blobdiff_plain;f=wm-wmii.c;h=ad114ebe49ccd5f218dcee3d30e9c2ff6d519cfd;hp=ea631242abfed36d5568910bce14734283f8ee1a;hb=c5d281c2e042c1153109dd46b74ef3d41fcacd93;hpb=43cb9b7de22dac5864d73321ec974bb937a217ff diff --git a/wm-wmii.c b/wm-wmii.c index ea63124..ad114eb 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -17,18 +17,16 @@ #include #include "util.h" +#include "conf.h" #include "sys.h" #include "wm.h" +/* Configuration */ #ifndef MODKEY #define MODKEY alt #endif -#ifndef MARGIN -#define MARGIN 0 -#endif -#ifndef STACK -#define STACK 25 -#endif +static int MARGIN = 0; +static int STACK = 25; /* Enums */ typedef enum { @@ -590,15 +588,14 @@ static void tag_switch(int name) printf("tag_switch: %d\n", name); tag_t *old = wm_tag; if ((wm_col == NULL || wm_row == NULL) && wm_flt == NULL) { - list_t *ltag = list_find(wm->tags, old); - wm->tags = list_remove(wm->tags, ltag, 1); while (old->dpys) { dpy_t *dpy = old->dpys->data; while (dpy->cols) dpy->cols = list_remove(dpy->cols, dpy->cols, 1); old->dpys = list_remove(old->dpys, old->dpys, 1); } - free(old); + list_t *ltag = list_find(wm->tags, old); + wm->tags = list_remove(wm->tags, ltag, 1); } wm_tag = tag_find(name); } @@ -721,7 +718,7 @@ int wm_handle_key(win_t *win, Key_t key, mod_t mod, ptr_t ptr) if (move_mode != none && mod.up) return set_move(win,ptr,none), 1; if (key == key_mouse1 && !mod.up && win->h == STACK) - return wm_update(), 0; + return set_focus(win), wm_update(), 0; return 0; } @@ -792,7 +789,7 @@ int wm_handle_key(win_t *win, Key_t key, mod_t mod, ptr_t ptr) } /* Focus change */ - if (key == key_enter) + if (key == key_enter && win->h != STACK) return set_focus(win), 1; if (key_mouse0 <= key && key <= key_mouse7) @@ -886,6 +883,10 @@ void wm_init(win_t *root) { printf("wm_init: %p\n", root); + /* Load configuration */ + MARGIN = conf_get_int("main.margin", MARGIN); + STACK = conf_get_int("main.stack", STACK); + /* Hack, fix screen order */ list_t *screens = sys_info(root); list_t *left = screens; @@ -916,3 +917,25 @@ void wm_init(win_t *root) for (int i = 0; i < countof(keys_s); i++) sys_watch(root, keys_s[i], MOD(.MODKEY=1,.shift=1)); } + +void wm_free(win_t *root) +{ + /* Re-show and free all windows */ + while ( wm->tags) { tag_t *tag = wm->tags->data; + while (tag->dpys) { dpy_t *dpy = tag->dpys->data; + while (dpy->cols) { col_t *col = dpy->cols->data; + while (col->rows) { row_t *row = col->rows->data; + sys_show(row->win, st_show); + free(row->win->wm); + col->rows = list_remove(col->rows, col->rows, 1); } + dpy->cols = list_remove(dpy->cols, dpy->cols, 1); } + while (dpy->flts) { flt_t *flt = dpy->flts->data; + sys_show(flt->win, st_show); + free(flt->win->wm); + dpy->flts = list_remove(dpy->flts, dpy->flts, 1); } + tag->dpys = list_remove(tag->dpys, tag->dpys, 1); } + wm->tags = list_remove( wm->tags, wm->tags, 1); } + + /* Free remaining data */ + free(wm); +}