示例#1
0
文件: tag.c 项目: wavebeem/wmfs
/** Rename the selected tag
  *\param cmd uicb_t type
*/
void
uicb_tag_rename(uicb_t cmd)
{
     screen_get_sel();
     char *str;
     size_t len;

     if(!cmd || !strlen(cmd))
          return;

     str = tags[selscreen][seltag[selscreen]].name;
     len = strlen(str);

     /* TODO: if strlen(cmd) > len, the tag name
      * will be truncated...
      * We can't do a realloc because if the pointer change
      * free() on paser will segfault.on free_conf()...
      */
     strncpy(str, cmd, len);

     infobar_update_taglist(selscreen);
     infobar_draw(selscreen);

     return;
}
示例#2
0
文件: layout.c 项目: wavebeem/wmfs
/** Layout switching function
 * \param b Bool True : next False : previous
*/
void
layoutswitch(Bool b)
{
     int i;
     Client *c;

     screen_get_sel();

     if(tags[selscreen][seltag[selscreen]].layout.func == freelayout)
          for(c = clients; c && (c->tag != (uint)seltag[selscreen] && c->screen != selscreen); c = c->next)
          {
               c->ogeo = c->geo;
               c->free_geo = c->geo;
          }

     for(i = 0; i < conf.nlayout; ++i)
     {
          if(tags[selscreen][seltag[selscreen]].layout.func == conf.layout[i].func
             && tags[selscreen][seltag[selscreen]].layout.symbol == conf.layout[i].symbol)
          {
               if(b)
                    tags[selscreen][seltag[selscreen]].layout = conf.layout[(i + 1) % conf.nlayout];
               else
                    tags[selscreen][seltag[selscreen]].layout = conf.layout[(i + conf.nlayout - 1) % conf.nlayout];
               break;
          }
     }

     ewmh_update_current_tag_prop();
     tags[selscreen][seltag[selscreen]].layout.func(selscreen);
     infobar_draw(selscreen);

     return;
}
示例#3
0
文件: infobar.c 项目: 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;
}
示例#4
0
文件: infobar.c 项目: n4cht/nnwm
/* Set the infobar position
 * \param pos Position of the bar
 */
void
infobar_set_position(int pos)
{
     screen_get_sel();

     switch(pos)
     {
     case IB_Hide:
          sgeo[selscreen].y = spgeo[selscreen].y + TBARH;
          sgeo[selscreen].height = spgeo[selscreen].height - TBARH;
          infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2;
          break;
     case IB_Bottom:
          sgeo[selscreen].y = spgeo[selscreen].y + TBARH;
          sgeo[selscreen].height = spgeo[selscreen].height - INFOBARH - TBARH;
          infobar[selscreen].geo.y = spgeo[selscreen].y + sgeo[selscreen].height + TBARH;
          break;
     default:
     case IB_Top:
          sgeo[selscreen].y = spgeo[selscreen].y + INFOBARH + TBARH;
          sgeo[selscreen].height = spgeo[selscreen].height - INFOBARH - TBARH;
          infobar[selscreen].geo.y = spgeo[selscreen].y;
          break;
     }

     tags[selscreen][seltag[selscreen]].barpos = pos;

     barwin_move(infobar[selscreen].bar, sgeo[selscreen].x - BORDH, infobar[selscreen].geo.y);
     infobar_draw(selscreen);
     arrange(selscreen, True);

     return;
}
示例#5
0
文件: tag.c 项目: wavebeem/wmfs
/** Adding a tag
  *\param s Screen number
  *\param name New tag name
*/
static void
tag_new(int s, char *name)
{
     char * displayedName;
     int goToTag;

     if(conf.ntag[s] + 1 > MAXTAG)
     {
          warnx("Too many tag: Can't create new tag");

          return;
     }

     ++conf.ntag[s];

     /* TODO: memleak here */
     if(!name || strlen(name) == 0)
     {
         if(conf.tagnamecount)
         {
             /* displayedName = zmalloc(2); */
             xasprintf(&displayedName, "[%d]", conf.ntag[s]);
         }
         else
             displayedName = conf.default_tag.name;
     }
     else
         displayedName = xstrdup(name);


     Tag t = { displayedName, NULL, 0, 0,
               conf.default_tag.mwfact, conf.default_tag.nmaster,
               False, conf.default_tag.resizehint, False, False,
               conf.default_tag.barpos, conf.default_tag.barpos, conf.default_tag.layout,
               0, NULL, 0, False };

     tags[s][conf.ntag[s]] = t;

     /* For stay_last_tag */
     if(tags[s][conf.ntag[s]-1].stay_last)
     {
          tag_swap(s, conf.ntag[s], conf.ntag[s]-1);
          goToTag = conf.ntag[s]-1;
     }
     else
          goToTag = conf.ntag[s];

     infobar_update_taglist(s);
     infobar_draw(s);
     tag_set(goToTag);

     return;
}
示例#6
0
文件: tag.c 项目: wavebeem/wmfs
/** Delete a tag
  *\param s Screen number
  *\param tag Tag number
*/
static void
tag_delete(int s, int tag)
{
     Tag t;
     Client *c;
     size_t i;

     memset(&t, 0, sizeof(t));

     if(tag < 0 || tag > conf.ntag[s] || conf.ntag[s] == 1)
          return;

     for(c = clients; c; c = c->next)
          if(c->screen == s && c->tag == (uint)tag)
          {
               warnx("Client(s) present in this tag, can't delete it");

               return;
          }

     --conf.ntag[s];

     tags[s][tag] = t;
     infobar[s].tags[tag] = NULL;

     for(i = tag; i < (size_t)conf.ntag[s] + 1; ++i)
     {
          /* Set clients tag because of shift */
          for(c = clients; c; c = c->next)
               if(c->screen == s && c->tag == i + 1)
                    c->tag = i;

          /* shift */
          tags[s][i] = tags[s][i + 1];
     }

     infobar[s].need_update = True;
     infobar_update_taglist(s);
     infobar_draw(s);

     if(tag == seltag[s])
          tag_set(tag <= conf.ntag[s] ? tag : conf.ntag[s]);

     return;
}
示例#7
0
文件: layout.c 项目: wavebeem/wmfs
/** Arrange All
*/
void
arrange(int screen, Bool update_layout)
{
     Client *c;

     if(screen < 0 || screen > screen_count() - 1)
          screen = screen_get_sel();

     for(c = clients; c; c = c->next)
          if(c->screen == screen)
          {
               if(!ishide(c, screen))
                    client_unhide(c);
               else
                    client_hide(c);
          }

     if(update_layout)
          tags[screen][seltag[screen]].layout.func(screen);

     infobar_draw(screen);

     return;
}
示例#8
0
文件: infobar.c 项目: 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;
}