示例#1
0
文件: tree.c 项目: ThomasAdam/bspwm
void list(desktop_t *d, node_t *n, char *rsp, unsigned int depth)
{
    if (n == NULL)
        return;

    char line[MAXLEN];

    for (unsigned int i = 0; i < depth; i++)
        strncat(rsp, "  ", REMLEN(rsp));

    if (is_leaf(n)) {
        client_t *c = n->client;
        snprintf(line, sizeof(line), "%c %s %X %u %u %ux%u%+i%+i %c%c%c%c%c", (c->born_as == MODE_AUTOMATIC ? 'a' : 'm'), c->class_name, c->window, c->uid, c->border_width, c->floating_rectangle.width, c->floating_rectangle.height, c->floating_rectangle.x, c->floating_rectangle.y, (c->floating ? 'f' : '-'), (c->transient ? 't' : '-'), (c->fullscreen ? 'F' : '-'), (c->urgent ? 'u' : '-'), (c->locked ? 'l' : '-'));
    } else {
        snprintf(line, sizeof(line), "%c %.2f", (n->split_type == TYPE_HORIZONTAL ? 'H' : 'V'), n->split_ratio);
    }

    strncat(rsp, line, REMLEN(rsp));

    if (n == d->focus)
        strncat(rsp, " *\n", REMLEN(rsp));
    else if (n == d->last_focus)
        strncat(rsp, " ~\n", REMLEN(rsp));
    else
        strncat(rsp, "\n", REMLEN(rsp));

    list(d, n->first_child, rsp, depth + 1);
    list(d, n->second_child, rsp, depth + 1);
}
示例#2
0
文件: tree.c 项目: ThomasAdam/bspwm
void list_monitors(list_option_t opt, char *rsp)
{
    char line[MAXLEN];
    for (monitor_t *m = mon_head; m != NULL; m = m->next) {
        snprintf(line, sizeof(line), "%s %ux%u%+i%+i", m->name, m->rectangle.width, m->rectangle.height, m->rectangle.x, m->rectangle.y);
        strncat(rsp, line, REMLEN(rsp));
        if (m == mon)
            strncat(rsp, " #\n", REMLEN(rsp));
        else if (m == last_mon)
            strncat(rsp, " ~\n", REMLEN(rsp));
        else
            strncat(rsp, "\n", REMLEN(rsp));
        if (opt == LIST_OPTION_VERBOSE)
            list_desktops(m, opt, 1, rsp);
    }
}
示例#3
0
文件: tag.c 项目: mztriz/bspwm
void list_tags(char *rsp)
{
    char line[MAXLEN];
    for (int i = 0; i < num_tags; i++) {
        snprintf(line, sizeof(line), "%s %u\n", tags[i]->name, tags[i]->mask);
        strncat(rsp, line, REMLEN(rsp));
    }
}
示例#4
0
文件: tree.c 项目: ThomasAdam/bspwm
void list_desktops(monitor_t *m, list_option_t opt, unsigned int depth, char *rsp)
{
    char line[MAXLEN];
    for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
        for (unsigned int i = 0; i < depth; i++)
            strncat(rsp, "  ", REMLEN(rsp));
        snprintf(line, sizeof(line), "%s %c", d->name, (d->layout == LAYOUT_TILED ? 'T' : 'M'));
        strncat(rsp, line, REMLEN(rsp));
        if (d == m->desk)
            strncat(rsp, " @\n", REMLEN(rsp));
        else if (d == m->last_desk)
            strncat(rsp, " ~\n", REMLEN(rsp));
        else
            strncat(rsp, "\n", REMLEN(rsp));
        if (opt == LIST_OPTION_VERBOSE)
            list(d, d->root, rsp, depth + 1);
    }
}