The order in which monitors are defined in monrules[] actually matters.
Monotors that aren't configured in monrules[], it will always be the leftmost.
JRXMQ2GKMY3ZPLMON4D7OPHU62B4A7PV5FXLYBQMJRNCLVKTUALQC
7QPBYBLDDSHGGIU7CWCX5PKUUECVBDTH4H6X2TLLH3HMXXCYVAEAC
VPJKNRN7WO5UAJYYVW3LEAIH55EQ47WBY54FZEX523JCBX273MSAC
GBK2UGQ4CNOPJKFXFXUTHK5AHJ4XG6LFMBWDD62PSTAPUGKKYTLQC
65GPTMYLVOQPVAKNBCN5RHHZEL7USZYSJ4VJQO7LYBCS7BZM7BYAC
7L3TU7JVWPBPHN7WF4TJ263BZ6BC3AYRRW6PULFUP5JZUGWWNUSAC
7B74AT3BXYB7PVW4F6SGQNPMHOU5TEV5TZ54CG6VSQI46XSEKWXQC
LQPHYO7IIMLXHUD5IK657BO4BE3SGT5HYDRJDU5OFDF5YUXKIRTAC
RS7FD3UJQ7HVHZ6I5TW476LSXRHSQS4BZMN6MJDMDQ42JH2MOE6QC
7JQD43QS55Q2YI6OQ6BGVAHSHKQHI3TKD6PXIKYKJZXOVOWFHMWAC
7HUMD4TAMWWBQDOZYCMWQXR66G3IU5WU3IVKTPCSMETSB6VREWTAC
E7UO6NRGXFDMBU3BSJYRDNOA3Y7VHD7NWPHI5PHCPHQF6ZNOPZLQC
D425ND7AT3F7QJ3CCSESMVDOC3J5C5P32M5SJDBHECZJXLHNQ2FAC
VCNLR5X75OAXVKPZQHF5RUZ7BONBUC6RPGO2NZEUD3FZ7TEVL66AC
4STIHURYLRLYMGSU325GCLA4C6SURA4TXRNBWBTWST2C6R2H6U2AC
wl_list_insert(&mons, &m->link);
Monitor *moni, *insertmon = NULL;
int x = 0;
wl_list_for_each(moni, &mons, link)
if (m->position > moni->position)
insertmon = moni;
if (insertmon) {
x = insertmon->w.x + insertmon->w.width;
wl_list_insert(&insertmon->link, &m->link);
fprintf(stderr, "%s inserted in pos %d\n", m->wlr_output->name, m->position);
} else {
wl_list_insert(&mons, &m->link);
fprintf(stderr, "%s defaulting\n", m->wlr_output->name);
}
wlr_output_layout_add_auto(output_layout, wlr_output);
wlr_output_layout_add(output_layout, wlr_output, x, 0);
wl_list_for_each_reverse(moni, &mons, link) {
/* all monitors that on the right of the new one must be moved */
if (moni == m)
break;
wlr_output_layout_move(output_layout, moni->wlr_output, moni->w.x + m->wlr_output->width, 0);
fprintf(stderr, "moved %s to %d", moni->wlr_output->name, moni->w.x + m->wlr_output->width);
}
sgeom = *wlr_output_layout_get_box(output_layout, NULL);