From 1ddc714196a20a7d31722f7614c0a4597ac0a421 Mon Sep 17 00:00:00 2001 From: OldMan Date: Tue, 13 Apr 2010 10:15:40 +0600 Subject: [PATCH 1/2] Conf: section 'selbar' in section 'bar' --- src/config.c | 20 +++++++++++++++++++- src/event.c | 9 +++++++++ src/infobar.c | 2 +- src/structs.h | 7 +++++++ src/wmfs.c | 1 + wmfsrc.in | 12 +++++++++++- 6 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 94cfab1..1edcfe7 100644 --- a/src/config.c +++ b/src/config.c @@ -176,13 +176,14 @@ conf_misc_section(char *src) void conf_bar_section(char *src) { + char *tmp; + cfg_set_sauv(src); conf.border.bar = get_opt(src, "false", "border").bool; conf.bars.height = get_opt(src, "-1", "height").num; conf.colors.bar = getcolor(get_opt(src, "#000000", "bg").str); conf.colors.text = get_opt(src, "#ffffff", "fg").str; - conf.bars.selbar = get_opt(src, "false", "selbar").bool; if((conf.bars.nmouse = get_size_sec(src, "mouse"))) { @@ -190,6 +191,23 @@ conf_bar_section(char *src) mouse_section(conf.bars.mouse, src, conf.bars.nmouse); } + /* Selbar part {{ */ + tmp = get_sec(src, "selbar"); + cfg_set_sauv(tmp); + + conf.bars.selbar = tmp ? True : False; + + conf.selbar.bg = getcolor(get_opt(tmp, "#000000", "bg").str); + conf.selbar.fg = get_opt(tmp, "#ffffff", "fg").str; + + /* Multi mouse section */ + if((conf.selbar.nmouse = get_size_sec(tmp, "mouse"))) + { + conf.selbar.mouse = emalloc(conf.selbar.nmouse, sizeof(MouseBinding)); + mouse_section(conf.selbar.mouse, tmp, conf.selbar.nmouse); + } + /* }} */ + return; } diff --git a/src/event.c b/src/event.c index df48a42..076a7ac 100644 --- a/src/event.c +++ b/src/event.c @@ -96,6 +96,15 @@ buttonpress(XButtonEvent *ev) if(conf.bars.mouse[j].func) conf.bars.mouse[j].func(conf.bars.mouse[j].cmd); + /* Selbar */ + if(ev->window == infobar[selscreen].selbar->win) + for(i = 0; i < conf.selbar.nmouse; ++i) + if(conf.selbar.mouse[i].tag == seltag[conf.selbar.mouse[i].screen] + || conf.selbar.mouse[i].tag < 0) + if(ev->button == conf.selbar.mouse[i].button) + if(conf.selbar.mouse[i].func) + conf.selbar.mouse[i].func(conf.selbar.mouse[i].cmd); + /* Tags */ for(i = 1; i < conf.ntag[selscreen] + 1; ++i) if(ev->window == infobar[selscreen].tags[i]->win) diff --git a/src/infobar.c b/src/infobar.c index e7af54f..2e7d187 100644 --- a/src/infobar.c +++ b/src/infobar.c @@ -108,7 +108,7 @@ infobar_init(void) : infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2), 1, (sel) ? textw(sel->title) + PAD : 1, infobar[sc].geo.height - 2, - conf.colors.bar, conf.colors.text, False, False, False); + conf.selbar.bg, conf.selbar.fg, False, False, False); /* Map/Refresh all */ barwin_map(infobar[sc].bar); diff --git a/src/structs.h b/src/structs.h index 50ebdcc..8be90b2 100644 --- a/src/structs.h +++ b/src/structs.h @@ -373,6 +373,13 @@ typedef struct Bool selbar; } bars; struct + { + char *fg; + uint bg; + MouseBinding *mouse; + int nmouse; + } selbar; + struct { char *background_command; MouseBinding *mouse; diff --git a/src/wmfs.c b/src/wmfs.c index 7140a31..95016ba 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -125,6 +125,7 @@ quit(void) } IFREE(conf.bars.mouse); + IFREE(conf.selbar.mouse); IFREE(conf.titlebar.button); IFREE(conf.client.mouse); IFREE(conf.root.mouse); diff --git a/wmfsrc.in b/wmfsrc.in index aa9b454..446fbed 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -18,7 +18,17 @@ bg = "#191919" fg = "#D4D4D4" border = true - selbar = false + # selbar = false #not worked now, see section [selbar] + + # Remove this section to disable the selbar. + [selbar] + bg = "#191919" + fg = "#D4D4ff" + + [mouse] button = "4" func = "client_next" [/mouse] + [mouse] button = "5" func = "client_prev" [/mouse] + [/selbar] + [/bar] [layouts] From 5363a7a8a9035bb1559835f2a6cbced2e2f01123 Mon Sep 17 00:00:00 2001 From: OldMan Date: Wed, 14 Apr 2010 19:59:53 +0600 Subject: [PATCH 2/2] Menu as Clientlist --- src/client.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/config.c | 4 ++- src/menu.c | 11 ++++++++ src/wmfs.h | 13 ++++++++- wmfsrc.in | 1 + 5 files changed, 105 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index fa21ffb..ba2a393 100644 --- a/src/client.c +++ b/src/client.c @@ -1176,4 +1176,82 @@ uicb_ignore_next_client_rules(uicb_t cmd) return; } +/** Show clientlist menu + *\param cmd uicb_t type + */ +void +uicb_clientlist(uicb_t cmd) +{ + int i, d, u, x, y; + int n = 0; + Window w; + Client *c = NULL; + Bool is_sel; + + for(c = clients; c; c = c->next) + if(c->tag == seltag[selscreen] && c->screen == selscreen) + ++n; + + if(n > 0) + { + if(clientlist.nitem) + menu_clear(&clientlist); + + menu_init(&clientlist, "clientlist", n, + /* Colors */ + conf.menu[0].colors.focus.bg, + conf.menu[0].colors.focus.fg, + conf.menu[0].colors.normal.bg, + conf.menu[0].colors.normal.fg); + + for(i = 0, c = clients; c; c = c->next) + if(c->tag == seltag[selscreen] && c->screen == selscreen) + { + sprintf(clist_index[i].key, "%d", i); + clist_index[i].client = c; + + menu_new_item(&clientlist.item[i], c->title, + uicb_client_select, clist_index[i].key); + + if(c == sel) + clientlist.item[i].check = name_to_func("check_clist", func_list); + + i++; + } + + clist_index[i].client = NULL; + + XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&u); + menu_draw(clientlist, x, y); + } + + return; +} + +/** Select client + *\param cmd uicb_t type clientlist index + */ +void +uicb_client_select(uicb_t cmd) +{ + int i; + + for(i = 0; i < MAXCLIST && clist_index[i].client; ++i) + if(!strcmp(cmd, clist_index[i].key)) + { + client_focus(clist_index[i].client); + client_raise(clist_index[i].client); + } + + return; +} + +/** Check clientlist menu fake function + * \param cmd uicb_t type unused +*/ +Bool +uicb_checkclist(uicb_t cmd) +{ + return True; +} diff --git a/src/config.c b/src/config.c index 0a979f7..c62c629 100644 --- a/src/config.c +++ b/src/config.c @@ -82,7 +82,9 @@ func_name_list_t tmp_func_list[] = {"ignore_next_client_rules", uicb_ignore_next_client_rules }, {"check_max", uicb_checkmax }, {"check_free", uicb_checkfree }, - {"check_layout", uicb_checklayout } + {"check_layout", uicb_checklayout }, + {"clientlist", uicb_clientlist }, + {"check_clist", uicb_checkclist } }; key_name_list_t key_list[] = diff --git a/src/menu.c b/src/menu.c index f1d2153..bde9cd6 100644 --- a/src/menu.c +++ b/src/menu.c @@ -315,3 +315,14 @@ uicb_menu(uicb_t cmd) return; } + +void +menu_clear(Menu *menu) +{ + /*menu->item = emalloc(sizeof(MenuItem), nitem);*/ + IFREE(menu->item); + menu->nitem = 0; + + return; +} + diff --git a/src/wmfs.h b/src/wmfs.h index 2124235..d36bfe4 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -107,6 +107,7 @@ #define CHECK(x) if(!(x)) return #define IFREE(x) if(x) free(x) #define LEN(x) (sizeof(x) / sizeof((x)[0])) +#define MAXCLIST (64) /* barwin.c */ BarWindow *barwin_create(Window parent, @@ -191,7 +192,9 @@ void uicb_client_screen_prev(uicb_t); void uicb_client_move(uicb_t cmd); void uicb_client_resize(uicb_t cmd); void uicb_ignore_next_client_rules(uicb_t cmd); - +void uicb_clientlist(uicb_t cmd); +void uicb_client_select(uicb_t cmd); +Bool uicb_checkclist(uicb_t); /* ewmh.c */ void ewmh_init_hints(void); @@ -240,6 +243,7 @@ void menu_focus_item(Menu *menu, int item, BarWindow *winitem[]); void menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[]); int menu_get_longer_string(MenuItem *mi, int nitem); void uicb_menu(uicb_t cmd); +void menu_clear(Menu *menu); /* launcher.c */ void launcher_execute(Launcher *launcher); @@ -410,6 +414,13 @@ int *seltag; int *prevseltag; Menu menulayout; +/* ClientList */ +Menu clientlist; +struct clndx { + char key[4]; + Client *client; +} clist_index[MAXCLIST]; + /* Important Client */ Client *clients; Client *sel; diff --git a/wmfsrc.in b/wmfsrc.in index 446fbed..4ceee76 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -25,6 +25,7 @@ bg = "#191919" fg = "#D4D4ff" + [mouse] button = "3" func = "clientlist" [/mouse] [mouse] button = "4" func = "client_next" [/mouse] [mouse] button = "5" func = "client_prev" [/mouse] [/selbar]