/** Destroy the InfoBar */ void infobar_destroy(void) { int sc, i; for(sc = 0; sc < screen_count(); ++sc) { barwin_delete(infobar[sc].layout_button); barwin_delete_subwin(infobar[sc].layout_button); for(i = 1; i < conf.ntag[sc] + 1; ++i) { barwin_delete_subwin(infobar[sc].tags[i]); barwin_delete(infobar[sc].tags[i]); } barwin_delete_subwin(infobar[sc].tags_board); barwin_delete(infobar[sc].tags_board); barwin_delete(infobar[sc].selbar); barwin_delete_subwin(infobar[sc].bar); barwin_delete(infobar[sc].bar); } return; }
void menu_draw(Menu menu, int x, int y) { int i, width, height, out; XEvent ev; BarWindow *item[menu.nitem]; BarWindow *frame; int chcklen = 0; if(menu_get_checkstring_needed(menu.item, menu.nitem)) chcklen = textw(conf.selected_layout_symbol) + PAD / 3; width = menu_get_longer_string(menu.item, menu.nitem) + chcklen + textw(">") + PAD * 3; height = menu.nitem * (INFOBARH - SHADH); /* Frame barwin */ screen_get_sel(); if((out = x + width - MAXW) > 0) x -= out; if((out = y + height - MAXH) > 0) y -= out; frame = barwin_create(ROOT, x, y, width + SHADH, height + SHADH * 3, menu.colors.normal.bg, menu.colors.normal.fg, False, False, True); barwin_map(frame); barwin_map_subwin(frame); barwin_refresh_color(frame); for(i = 0; i < menu.nitem; ++i) { item[i] = barwin_create(frame->win, SHADH, (i * (INFOBARH - SHADH) + SHADH), width - SHADH, INFOBARH, menu.colors.normal.bg, menu.colors.normal.fg, True, False, False); barwin_map(item[i]); barwin_refresh_color(item[i]); menu_draw_item_name(&menu, i, item, chcklen); barwin_refresh(item[i]); } /* Select the first item */ menu_focus_item(&menu, 0, item); XGrabKeyboard(dpy, ROOT, True, GrabModeAsync, GrabModeAsync, CurrentTime); while(!menu_manage_event(&ev, &menu, item)); XUngrabKeyboard(dpy, CurrentTime); for(i = 0; i < menu.nitem; ++i) barwin_delete(item[i]); barwin_delete(frame); return; }