Skip to content

Transferring window to receptable doesn't produce a node_remove event for the disappearing receptable #1531

@samaingw

Description

@samaingw

When subscribing the node_add and node_remove events, the standard workflow with receptacles (insert them somewhere, transfer a window to it) produces a node_add event but no node_remove event.
I use scripts which rely on having knowledge of leaf nodes currently in the tree. My scripts are messed up with undying receptacles ;)

Relevant pieces of code:

  • Adding a receptacle produces a node_add event

    bspwm/src/tree.c

    Lines 464 to 473 in af3bd8b

    void insert_receptacle(monitor_t *m, desktop_t *d, node_t *n)
    {
    node_t *r = make_node(XCB_NONE);
    insert_node(m, d, r, n);
    put_status(SBSC_MASK_NODE_ADD, "node_add 0x%08X 0x%08X 0x%08X 0x%08X\n", m->id, d->id, n != NULL ? n->id : 0, r->id);
    if (single_monocle && d->layout == LAYOUT_MONOCLE && tiled_count(d->root, true) > 1) {
    set_layout(m, d, d->user_layout, false);
    }
    }
  • Killing receptable produces the node_remove event

    bspwm/src/tree.c

    Lines 1423 to 1439 in af3bd8b

    void kill_node(monitor_t *m, desktop_t *d, node_t *n)
    {
    if (n == NULL) {
    return;
    }
    if (IS_RECEPTACLE(n)) {
    put_status(SBSC_MASK_NODE_REMOVE, "node_remove 0x%08X 0x%08X 0x%08X\n", m->id, d->id, n->id);
    remove_node(m, d, n);
    } else {
    for (node_t *f = first_extrema(n); f != NULL; f = next_leaf(f, n)) {
    if (f->client != NULL) {
    xcb_kill_client(dpy, f->id);
    }
    }
    }
    }
  • Replacing a receptacle by a window doesn't produce node_remove events (no put_status in the quoted piece of code)

    bspwm/src/tree.c

    Lines 311 to 324 in af3bd8b

    } else if (IS_RECEPTACLE(f) && f->presel == NULL) {
    node_t *p = f->parent;
    if (p != NULL) {
    if (is_first_child(f)) {
    p->first_child = n;
    } else {
    p->second_child = n;
    }
    } else {
    d->root = n;
    }
    n->parent = p;
    free(f);
    f = NULL;

To make node_add and node_remove consistent, two options:

  1. receptacles don't report node_add event (the same way as non-leaf nodes) nor node_remove
  2. receptacles report both node_add and node_remove, as if they were windows

Even though for my own use case I'd rather go with option 1, I think for the community that option 2 is the most logical/unsurprising one.

Thoughts on that ?
I can definitely make the PR, I just need to know which PR I should make.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions