+ /* Sanity check: Are the coordinates on the appropriate output? If not, we
+ * need to change them */
+ Output *current_output = get_output_containing(nc->rect.x, nc->rect.y);
+ Con *correct_output = con_get_output(ws);
+ if (!current_output || current_output->con != correct_output) {
+ DLOG("This floating window is on the wrong output, fixing coordinates (currently (%d, %d))\n",
+ nc->rect.x, nc->rect.y);
+ /* Take the relative coordinates of the current output, then add them
+ * to the coordinate space of the correct output */
+ uint32_t rel_x = (nc->rect.x - (current_output ? current_output->con->rect.x : 0));
+ uint32_t rel_y = (nc->rect.y - (current_output ? current_output->con->rect.y : 0));
+ nc->rect.x = correct_output->rect.x + rel_x;
+ nc->rect.y = correct_output->rect.y + rel_y;
+ }
+
+ DLOG("Floating rect: (%d, %d) with %d x %d\n", nc->rect.x, nc->rect.y, nc->rect.width, nc->rect.height);
+ nc->orientation = NO_ORIENTATION;
+ nc->type = CT_FLOATING_CON;
+ TAILQ_INSERT_TAIL(&(ws->floating_head), nc, floating_windows);
+ TAILQ_INSERT_TAIL(&(ws->focus_head), nc, focused);
+
+ /* 3: attach the child to the new parent container */
+ con->parent = nc;
+ con->percent = 1.0;
+ con->floating = FLOATING_USER_ON;
+
+ /* 4: set the border style as specified with new_float */
+ if (automatic)
+ con->border_style = config.default_floating_border;
+