/** Update taglist geo *\param sc Screen number */ void infobar_update_taglist(int sc) { int i, j; for(i = 1, j = 0; i < conf.ntag[sc] + 1; ++i) { /* If the tag i does not exist yet (graphically) or need full update */ if(!infobar[sc].tags[i] || infobar[sc].need_update) { infobar[sc].tags[i] = barwin_create(infobar[sc].tags_board->win, j, 0, textw(tags[sc][i].name) + PAD, infobar[sc].geo.height, conf.colors.bar, conf.colors.text, False, False, conf.border.tag); barwin_map(infobar[sc].tags[i]); barwin_map_subwin(infobar[sc].tags[i]); j += textw(tags[sc][i].name) + PAD; barwin_resize(infobar[sc].tags_board, j, infobar[sc].geo.height); continue; } barwin_move(infobar[sc].tags[i], j, 0); j += textw(tags[sc][i].name) + PAD; barwin_resize(infobar[sc].tags[i], textw(tags[sc][i].name) + PAD, infobar[sc].geo.height); barwin_resize(infobar[sc].tags_board, j, infobar[sc].geo.height); } infobar[sc].need_update = False; 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; }
/** Init the Infobar */ void infobar_init(void) { int s, sc, i, j = 0; s = screen_count(); if(!infobar) infobar = xcalloc(s, sizeof(InfoBar)); for(sc = 0; sc < s; ++sc) { j = 0; infobar[sc].geo.height = INFOBARH; switch(tags[sc][seltag[sc]].barpos) { case IB_Hide: sgeo[sc].y = spgeo[sc].y + TBARH; sgeo[sc].height += INFOBARH; infobar[sc].geo.y = -(infobar[sc].geo.height) * 2; break; case IB_Bottom: sgeo[sc].y = TBARH; infobar[sc].geo.y = spgeo[sc].y + sgeo[sc].height + TBARH; break; default: case IB_Top: sgeo[sc].y = spgeo[sc].y + INFOBARH + TBARH; infobar[sc].geo.y = spgeo[sc].y; break; } /* Create infobar barwindow */ infobar[sc].bar = barwin_create(ROOT, sgeo[sc].x - BORDH, infobar[sc].geo.y, sgeo[sc].width, infobar[sc].geo.height, conf.colors.bar, conf.colors.text, False, False, conf.border.bar); infobar[sc].tags_board = barwin_create(infobar[sc].bar->win, ((conf.layout_placement) ? textw(tags[sc][seltag[sc]].layout.symbol) + PAD * 1.5: 0), 0, textw(tags[sc][0].name) + PAD, /* Base size, will change */ infobar[sc].geo.height, conf.colors.bar, conf.colors.text, False, False, False); /* Create tags window */ for(i = 1; i < conf.ntag[sc] + 1; ++i) { infobar[sc].tags[i] = barwin_create(infobar[sc].tags_board->win, j, 0, textw(tags[sc][i].name) + PAD, infobar[sc].geo.height, conf.colors.bar, conf.colors.text, False, False, conf.border.tag); j += textw(tags[sc][i].name) + PAD; barwin_resize(infobar[sc].tags_board, j, infobar[sc].geo.height); barwin_map_subwin(infobar[sc].tags[i]); } /* Create layout switch barwindow */ infobar[sc].layout_button = barwin_create(infobar[sc].bar->win, ((conf.layout_placement) ? 0 : (j + PAD / 2)), 0, ((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)), infobar[sc].geo.height, conf.colors.layout_bg, conf.colors.layout_fg, False, False, conf.border.layout); /* Selbar */ if(conf.bars.selbar) infobar[sc].selbar = barwin_create(infobar[sc].bar->win, ((conf.layout_placement) ? (j + PAD / 2) : 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.selbar.bg, conf.selbar.fg, False, False, False); /* Map/Refresh all */ barwin_map(infobar[sc].bar); barwin_map_subwin(infobar[sc].bar); barwin_map(infobar[sc].tags_board); barwin_map_subwin(infobar[sc].tags_board); if(conf.border.layout) barwin_map_subwin(infobar[sc].layout_button); if(conf.bars.selbar) barwin_map(infobar[sc].selbar); barwin_refresh_color(infobar[sc].bar); barwin_refresh(infobar[sc].bar); /* Default statustext is set here */ infobar[sc].statustext = xstrdup(WMFS_VERSION); infobar_draw(sc); } return; }