- /* M_ACTIVE are assignments */
- if (match != NULL && match->insert_where == M_ACTIVE) {
- /* We need to go down the focus stack starting from nc */
- while (TAILQ_FIRST(&(nc->focus_head)) != TAILQ_END(&(nc->focus_head))) {
- DLOG("walking down one step...\n");
- nc = TAILQ_FIRST(&(nc->focus_head));
+ /* TODO: two matches for one container */
+
+ /* See if any container swallows this new window */
+ nc = con_for_window(search_at, cwindow, &match);
+ if (nc == NULL) {
+ if (focused->type == CT_CON && con_accepts_window(focused)) {
+ LOG("using current container, focused = %p, focused->name = %s\n",
+ focused, focused->name);
+ nc = focused;
+ } else nc = tree_open_con(NULL);
+ } else {
+ /* M_BELOW inserts the new window as a child of the one which was
+ * matched (e.g. dock areas) */
+ if (match != NULL && match->insert_where == M_BELOW) {
+ nc = tree_open_con(nc);