Exemplo n.º 1
0
Arquivo: infobar.c Projeto: n4cht/nnwm
/** Toggle the tag_autohide mode
 * \param cmd uicb_t type unused
*/
void
uicb_toggle_tagautohide(uicb_t cmd)
{
     int i, x;
     (void)cmd;

     screen_get_sel();
     conf.tagautohide = !conf.tagautohide;

     if(!conf.tagautohide)
     {
          for(i = 1, x = 0; i < conf.ntag[selscreen] + 1; ++i)
          {
               if(!infobar[selscreen].tags[i]->mapped)
                    barwin_map(infobar[selscreen].tags[i]);

               barwin_move(infobar[selscreen].tags[i], x, 0);
               x += infobar[selscreen].tags[i]->geo.width;
          }

          barwin_resize(infobar[selscreen].tags_board, x, infobar[selscreen].geo.height);
     }

     infobar_draw(selscreen);

     return;
}
Exemplo n.º 2
0
Arquivo: infobar.c Projeto: n4cht/nnwm
/** 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;
}
Exemplo n.º 3
0
Arquivo: infobar.c Projeto: n4cht/nnwm
/** Draw Selbar (selected client title bar in infobar
 *\param sc Screen Number
 */
void
infobar_draw_selbar(int sc)
{
     char *str = NULL;

     if(!conf.bars.selbar)
          return;

     if(!sel || (sel && sel->screen != sc))
     {
          barwin_unmap(infobar[sc].selbar);

          return;
     }
     else if(sel && !infobar[sc].selbar->mapped)
          barwin_map(infobar[sc].selbar);

     if(conf.selbar.maxlength >= 0 && sel)
     {
          str = xcalloc(conf.selbar.maxlength + 4, sizeof(char));
          strncpy(str, sel->title, conf.selbar.maxlength);

          if(strlen(sel->title) > (size_t)conf.selbar.maxlength)
               strcat(str, "...");
     }

     barwin_resize(infobar[sc].selbar, textw(str ? str : sel->title) + PAD, infobar[sc].geo.height - 2);

     barwin_move(infobar[sc].selbar,
               ((conf.layout_placement)
                ? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + PAD / 2)
                : (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2)), 1);

     barwin_refresh_color(infobar[sc].selbar);
     barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, ((str) ? str : sel->title));

     barwin_refresh(infobar[sc].selbar);

     free(str);

     return;
}
Exemplo n.º 4
0
Arquivo: menu.c Projeto: wavebeem/wmfs
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;
}
Exemplo n.º 5
0
Arquivo: infobar.c Projeto: n4cht/nnwm
/** 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;
}
Exemplo n.º 6
0
Arquivo: infobar.c Projeto: n4cht/nnwm
/** Draw the taglist in the InfoBar
 *\param sc Screen number
*/
void
infobar_draw_taglist(int sc)
{
     int i, x;
     Client *c = NULL;
     Bool is_occupied[MAXTAG + 1];

     if(conf.layout_placement)
          barwin_move(infobar[sc].tags_board, ((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)) + PAD / 2, 0);

     for(i = 0; i < MAXTAG; i++)
          is_occupied[i] = False;

     for(c = clients; c; c = c->next)
          if(c->screen == sc && c->tag != MAXTAG + 1)
               is_occupied[c->tag] = True;

     for(i = 1, x = 0; i < conf.ntag[sc] + 1; ++i)
     {
          /* Autohide tag feature */
          if(conf.tagautohide)
          {
               if(!is_occupied[i] && i != seltag[sc])
               {
                    barwin_unmap(infobar[sc].tags[i]);

                    continue;
               }

               if(!infobar[sc].tags[i]->mapped)
                    barwin_map(infobar[sc].tags[i]);

               barwin_move(infobar[sc].tags[i], x, 0);

               x += infobar[sc].tags[i]->geo.width;

               barwin_resize(infobar[sc].tags_board, x, infobar[sc].geo.height);
          }

          infobar[sc].tags[i]->bg = tags[sc][i].urgent
               ? conf.colors.tagurbg
               : ((i == seltag[sc] || tags[sc][seltag[sc]].tagad & TagFlag(i))
                    ? conf.colors.tagselbg
                    : (is_occupied[i]
                         ? conf.colors.tag_occupied_bg
                         : conf.colors.bar));

          infobar[sc].tags[i]->fg = tags[sc][i].urgent
               ? conf.colors.tagurfg
               : ((i == seltag[sc] || tags[sc][seltag[sc]].tagad & TagFlag(i))
                    ? conf.colors.tagselfg
                    : (is_occupied[i]
                         ? conf.colors.tag_occupied_fg
                         : conf.colors.text));

          barwin_color_set(infobar[sc].tags[i], infobar[sc].tags[i]->bg, infobar[sc].tags[i]->fg);
          barwin_refresh_color(infobar[sc].tags[i]);

          if(tags[sc][i].name)
               barwin_draw_text(infobar[sc].tags[i], PAD / 2, FHINFOBAR, tags[sc][i].name);
     }

     return;
}