diff --git a/src/config.c b/src/config.c index 58d9f65..82e0a19 100644 --- a/src/config.c +++ b/src/config.c @@ -79,7 +79,10 @@ func_name_list_t tmp_func_list[] = {"menu", uicb_menu }, {"set_client_layer", uicb_set_client_layer }, {"set_layer", uicb_set_layer }, - {"ignore_next_client_rules", uicb_ignore_next_client_rules } + {"ignore_next_client_rules", uicb_ignore_next_client_rules }, + {"check_max", uicb_checkmax }, + {"check_free", uicb_checkfree }, + {"check_layout", uicb_checklayout } }; key_name_list_t key_list[] = @@ -378,6 +381,8 @@ conf_layout_section(char *src) conf.layout[i].symbol = get_opt(tmp, "TILE (default)", "symbol").str; conf.layout[i].func = name_to_func(p, layout_list); + conf.layout[i].type = p; + menulayout.item[i].check = name_to_func("check_layout", func_list); } cfg_set_sauv(src); @@ -558,6 +563,7 @@ conf_menu_section(char *src) conf.menu[i].item[j].name = get_opt(tmp2, "item_wname", "name").str; conf.menu[i].item[j].func = name_to_func(get_opt(tmp2, "", "func").str, func_list); conf.menu[i].item[j].cmd = (!get_opt(tmp2, "", "cmd").str) ? NULL : get_opt(tmp2, "", "cmd").str; + conf.menu[i].item[j].check = name_to_func(get_opt(tmp2, "", "check").str, func_list); cfg_set_sauv(tmp); } diff --git a/src/layout.c b/src/layout.c index 6c8b792..43f992a 100644 --- a/src/layout.c +++ b/src/layout.c @@ -916,3 +916,48 @@ layout_set_client_master(Client *c) return; } + +/** Check the selected client is max + * \param cmd uicb_t type unused +*/ +Bool +uicb_checkmax(uicb_t cmd) +{ + if(!sel) + return False; + + if(sel->flags & MaxFlag) + return True; + + return False; +} + +/** Check the selected client is free + * \param cmd uicb_t type unused +*/ +Bool +uicb_checkfree(uicb_t cmd) +{ + if(!sel) + return False; + + if(sel->flags & FreeFlag) + return True; + + return False; +} + +/** Check layout type + * \param cmd uicb_t type layout type +*/ +Bool +uicb_checklayout(uicb_t cmd) +{ + screen_get_sel(); + + if(!strcmp(cmd, tags[selscreen][seltag[selscreen]].layout.type)) + return True; + + return False; +} + diff --git a/src/menu.c b/src/menu.c index b19a34c..c952edf 100644 --- a/src/menu.c +++ b/src/menu.c @@ -68,7 +68,7 @@ menu_draw(Menu menu, int x, int y) BarWindow *item[menu.nitem]; BarWindow *frame; - width = menu_get_longer_string(menu.item, menu.nitem) + PAD; + width = menu_get_longer_string(menu.item, menu.nitem) + PAD * 3; height = menu.nitem * (INFOBARH - SHADH); /* Frame barwin */ @@ -231,18 +231,22 @@ menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[]) switch(menu->align) { case MA_Left: - x = PAD / 2; + x = PAD * 3 / 2; break; case MA_Right: - x = width - textw(menu->item[item].name) + PAD / 2; + x = width - textw(menu->item[item].name) + PAD * 3 / 2; break; default: case MA_Center: - x = width / 2 - textw(menu->item[item].name) / 2 + PAD / 2; + x = width / 2 - textw(menu->item[item].name) / 2 + PAD * 3 / 2; break; } barwin_draw_text(winitem[item], x, FHINFOBAR, menu->item[item].name); + if(menu->item[item].check) + if(menu->item[item].check(menu->item[item].cmd)) + barwin_draw_text(winitem[item], PAD / 3, FHINFOBAR, "*"); + return; } diff --git a/src/structs.h b/src/structs.h index 66dc845..7006e4d 100644 --- a/src/structs.h +++ b/src/structs.h @@ -245,6 +245,7 @@ typedef struct typedef struct { char *symbol; + char *type; void (*func)(int screen); } Layout; @@ -274,6 +275,7 @@ typedef struct char *name; void (*func)(uicb_t); uicb_t cmd; + Bool (*check)(uicb_t); } MenuItem; /* Menu Struct */ diff --git a/src/wmfs.h b/src/wmfs.h index 64f0068..dba4f61 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -339,6 +339,9 @@ void uicb_toggle_abovefc(uicb_t cmd); void uicb_set_layer(uicb_t cmd); void uicb_set_client_layer(uicb_t cmd); void layout_set_client_master(Client *c); +Bool uicb_checkmax(uicb_t); +Bool uicb_checkfree(uicb_t); +Bool uicb_checklayout(uicb_t); /* init.c */ void init(void); diff --git a/wmfsrc.in b/wmfsrc.in index 819134e..89d6185 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -163,9 +163,10 @@ fg_focus = "#D4D4D4" bg_focus = "#003366" fg_normal = "#D4D4D4" bg_normal = "#191919" - [item] name = "Close" func = "client_kill" [/item] - [item] name = "Maximize" func = "toggle_max" [/item] - [item] name = "Free" func = "toggle_free" [/item] + # Check items: possible 'check_max' or 'check_free'. + [item] name = "Close" func = "client_kill" [/item] + [item] name = "Maximize" func = "toggle_max" check = "check_max" [/item] + [item] name = "Free" func = "toggle_free" check = "check_free" [/item] [/set_menu] [/menu]