From 4861329972e15806715f7dc24040c2c8451a4aec Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sun, 26 Oct 2008 16:45:05 +0100 Subject: [PATCH] barbutton: Remove barbutton feature provisionally (leak check) --- src/bar.c | 67 ---------------------------------------------------- src/config.c | 42 +------------------------------- src/draw.c | 4 +++- src/event.c | 11 +-------- src/wmfs.c | 1 - src/wmfs.h | 1 - wmfsrc | 47 +++--------------------------------- 7 files changed, 8 insertions(+), 165 deletions(-) diff --git a/src/bar.c b/src/bar.c index b301009..426f48b 100644 --- a/src/bar.c +++ b/src/bar.c @@ -135,72 +135,6 @@ updatebar(void) /* Refresh the bar */ bar_refresh(bar); - /* Update Bar Buttons */ - updatebutton(True); - - return; -} - -/* BARBUTTON MANAGE FUNCTION - * if c is False, you can execute this function for the first time - * else the button is just updated *TestingButWorking* */ -void -updatebutton(Bool c) -{ - int i, j, x, pm = 0, buttonw = 0; - int y = 0, hi = 0; - - /* Calcul the position of the first button with the layout image size */ - j = taglen[conf.ntag] + textw(tags[seltag].layout.symbol) + PAD/2; - - if(!conf.bartop) - y = bary + 2; - if(conf.tagbordwidth) - hi = -1; - - for(i = 0; i < conf.nbutton; ++i) - { - - /* CALCUL POSITION */ - { - buttonw = textw(conf.barbutton[i].content) + BPAD; - - if(!(x = conf.barbutton[i].x)) - { - if(i) - pm += textw(conf.barbutton[i-1].content) + BPAD; - - buttonw = textw(conf.barbutton[i].content) + BPAD; - x = (!i) ? j : j + pm; - } - } - - /* FIRST TIME */ - { - if(!c) - { - conf.barbutton[i].bw = bar_create(x, y, buttonw, barheight + hi, 0, - conf.barbutton[i].bg_color, False); - XMapRaised(dpy, conf.barbutton[i].bw->win); - } - } - - /* REFRESH TEXT */ - { - if(!conf.barbutton[i].bw) - return; - - bar_refresh_color(conf.barbutton[i].bw); - bar_moveresize(conf.barbutton[i].bw, x, y, buttonw, barheight + hi); - draw_text(conf.barbutton[i].bw->dr, BPAD/2, fonth - 1, conf.barbutton[i].fg_color, - conf.barbutton[i].bg_color, PAD, conf.barbutton[i].content); - - /* Refresh button */ - bar_refresh(conf.barbutton[i].bw); - } - } - XSync(dpy, False); - return; } @@ -223,7 +157,6 @@ uicb_togglebarpos(uicb_t cmd) updatebar(); for(i = 0; i < conf.nbutton; ++i) XUnmapWindow(dpy, conf.barbutton[i].bw->win); - updatebutton(False); for(i = 0; i < conf.nbutton; ++i) XMapWindow(dpy, conf.barbutton[i].bw->win); diff --git a/src/config.c b/src/config.c index fd3d5f6..71262ce 100644 --- a/src/config.c +++ b/src/config.c @@ -261,22 +261,6 @@ init_conf(void) CFG_END() }; - static cfg_opt_t button_opts[] = - { - CFG_STR("content", "", CFGF_NONE), - CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI), - CFG_STR("fg_color", "#000000", CFGF_NONE), - CFG_STR("bg_color", "#FFFFFF", CFGF_NONE), - CFG_INT("x", 0, CFGF_NONE), - CFG_END() - }; - - static cfg_opt_t buttons_opts[] = - { - CFG_SEC("button", button_opts, CFGF_MULTI), - CFG_END() - }; - static cfg_opt_t variable_opts[] = { CFG_STR("content", "", CFGF_NONE), @@ -299,7 +283,6 @@ init_conf(void) CFG_SEC("layouts", layouts_opts, CFGF_NONE), CFG_SEC("tags", tags_opts, CFGF_NONE), CFG_SEC("keys", keys_opts, CFGF_NONE), - CFG_SEC("buttons", buttons_opts, CFGF_NONE), CFG_END() }; @@ -312,8 +295,7 @@ init_conf(void) cfg_t *cfg_layouts; cfg_t *cfg_tags; cfg_t *cfg_keys; - cfg_t *cfg_buttons; - cfg_t *cfgtmp, *cfgtmp2, *cfgtmp3; + cfg_t *cfgtmp; char final_path[128]; char sfinal_path[128]; char buf[256] = {0}; @@ -343,7 +325,6 @@ init_conf(void) cfg_layouts = cfg_getsec(cfg, "layouts"); cfg_tags = cfg_getsec(cfg, "tags"); cfg_keys = cfg_getsec(cfg, "keys"); - cfg_buttons = cfg_getsec(cfg, "buttons"); if((cfg_size(cfg_variables, "var")) > 256) { @@ -518,27 +499,6 @@ init_conf(void) ? NULL : strdup(var_to_str(cfg_getstr(cfgtmp, "cmd")))); } - /* button */ - conf.nbutton = cfg_size(cfg_buttons, "button"); - conf.barbutton = emalloc(conf.nbutton, sizeof(BarButton)); - - for(i = 0; i < conf.nbutton; ++i) - { - cfgtmp2 = cfg_getnsec(cfg_buttons, "button", i); - for(j = 0; j < cfg_size(cfgtmp2, "mouse"); ++j) - { - cfgtmp3 = cfg_getnsec(cfgtmp2, "mouse", j); - conf.barbutton[i].mouse[j].func = name_to_func(cfg_getstr(cfgtmp3, "func"), func_list); - conf.barbutton[i].mouse[j].cmd = strdup(var_to_str(cfg_getstr(cfgtmp3, "cmd"))); - conf.barbutton[i].mouse[j].button = char_to_button(cfg_getstr(cfgtmp3, "button")); - } - conf.barbutton[i].nmousesec = cfg_size(cfgtmp2, "mouse"); - conf.barbutton[i].content = strdup(var_to_str(cfg_getstr(cfgtmp2, "content"))); - conf.barbutton[i].fg_color = strdup(var_to_str(cfg_getstr(cfgtmp2, "fg_color"))); - conf.barbutton[i].bg_color = getcolor(strdup(var_to_str(cfg_getstr(cfgtmp2, "bg_color")))); - conf.barbutton[i].x = cfg_getint(cfgtmp2, "x"); - } - cfg_free(cfg); return; diff --git a/src/draw.c b/src/draw.c index 1eeae1c..85ab9c8 100644 --- a/src/draw.c +++ b/src/draw.c @@ -51,8 +51,10 @@ draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str) /* Draw the text */ XftDrawStringUtf8(xftd, &xftcolor, xftfont, x, y, (FcChar8 *)str, strlen(str)); - /* Free the text color */ + /* Free the text color and XftDraw */ XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), &xftcolor); + XftDrawDestroy(xftd); + return; } diff --git a/src/event.c b/src/event.c index 6e80cd3..71f296d 100644 --- a/src/event.c +++ b/src/event.c @@ -37,7 +37,7 @@ void buttonpress(XEvent ev) { Client *c; - int i, j; + int i; char s[6]; /* Titlebar */ @@ -55,14 +55,6 @@ buttonpress(XEvent ev) if(conf.client.mouse[i].func) conf.client.mouse[i].func(conf.client.mouse[i].cmd); - /* Bar Buttons */ - for(i = 0; i < conf.nbutton ; ++i) - for(j = 0; j < conf.barbutton[i].nmousesec; ++j) - if(ev.xbutton.window == conf.barbutton[i].bw->win - && ev.xbutton.button == conf.barbutton[i].mouse[j].button) - if(conf.barbutton[i].mouse[j].func) - conf.barbutton[i].mouse[j].func(conf.barbutton[i].mouse[j].cmd); - /* Root */ if(ev.xbutton.window == root) { @@ -113,7 +105,6 @@ buttonpress(XEvent ev) } } } - efree(c); return; } diff --git a/src/wmfs.c b/src/wmfs.c index 5e96924..50faae5 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -173,7 +173,6 @@ init(void) bar = bar_create(0, bary, mw, barheight, 0, conf.colors.bar, False); XMapRaised(dpy, bar->win); strcpy(bartext, "WMFS-" WMFS_VERSION); - updatebutton(False); updatebar(); /* INIT WORKABLE SPACE GEOMETRY */ diff --git a/src/wmfs.h b/src/wmfs.h index 0c68dc7..67b0fb8 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -69,7 +69,6 @@ void bar_moveresize(BarWindow *bw, int x, int y, uint w, uint h); void bar_refresh_color(BarWindow *bw); void bar_refresh(BarWindow *bw); void updatebar(void); -void updatebutton(Bool c); void uicb_togglebarpos(uicb_t); /* draw.c */ diff --git a/wmfsrc b/wmfsrc index b518aa2..3289d26 100644 --- a/wmfsrc +++ b/wmfsrc @@ -77,50 +77,6 @@ titlebar mouse { button = "3" func = "mouse_resize" } } -buttons -{ - # MWFACT BUTTON {{{ - button - { - content = "[-]" - mouse { button = "1" func = "set_mwfact" cmd = "-0.01" } - fg_color = "#FFFFFF" - bg_color = "#191919" - } - button - { - content = "Mwfact" fg_color = "#FFFFFF" bg_color = "#3E3E3E" - mouse { button = "4" func = "set_mwfact" cmd = "+0.01" } - mouse { button = "5" func = "set_mwfact" cmd = "-0.01" } - } - button - { - content = "[+] " - mouse { button = "1" func = "set_mwfact" cmd = "+0.01" } - fg_color = "#FFFFFF" - bg_color = "#191919" - } - # }}} - - # NMASTER BUTTON {{{ - button - { - content = "[-]" - mouse { button = "1" func = "set_nmaster" cmd = "-1" } - fg_color = "#FFFFFF" - bg_color = "#191919" - } - button { content = "Nmaster" fg_color = "#FFFFFF" bg_color = "#3E3E3E" } - button - { - content = "[+] " - mouse { button = "1" func = "set_nmaster" cmd = "+1" } - fg_color = "#FFFFFF" - bg_color = "#191919" - } - # }}} -} - keys { # general keybind @@ -137,6 +93,9 @@ keys key { mod = {"Control"} key = "Down" func = "layout_prev" } key { mod = {"Alt"} key = "l" func = "set_mwfact" cmd = "+0.025" } key { mod = {"Alt"} key = "h" func = "set_mwfact" cmd = "-0.025" } + key { mod = {"Alt", "Shift"} key = "l" func = "set_nmaster" cmd = "+1" } + key { mod = {"Alt", "Shift"} key = "h" func = "set_nmaster" cmd = "-1" } + # tag manipulation keybind key { mod = {"Alt"} key = "F1" func = "tag" cmd = "1" }