// TODO: don’t influence focus handling when Con was not focused before.
if (set_focus)
con_focus(con);
+
+ floating_maybe_reassign_ws(nc);
}
void floating_disable(Con *con, bool automatic) {
TAILQ_INSERT_TAIL(&(con->parent->floating_head), con, floating_windows);
}
-DRAGGING_CB(drag_window_callback) {
- struct xcb_button_press_event_t *event = extra;
-
- /* Reposition the client correctly while moving */
- con->rect.x = old_rect->x + (new_x - event->root_x);
- con->rect.y = old_rect->y + (new_y - event->root_y);
-
- render_con(con, false);
- x_push_node(con, true);
- xcb_flush(conn);
-
- /* Check if we cross workspace boundaries while moving */
+/*
+ * Checks if con’s coordinates are within its workspace and re-assigns it to
+ * the actual workspace if not.
+ *
+ */
+bool floating_maybe_reassign_ws(Con *con) {
Output *output = get_output_containing(
con->rect.x + (con->rect.width / 2),
con->rect.y + (con->rect.height / 2));
if (!output) {
ELOG("No output found at destination coordinates?\n");
- return;
+ return false;
}
if (con_get_output(con) == output->con) {
DLOG("still the same ws\n");
- return;
+ return false;
}
DLOG("Need to re-assign!\n");
DLOG("Moving con %p / %s to workspace %p / %s\n", con, con->name, ws, ws->name);
con_move_to_workspace(con, ws);
con_focus(con_descend_focused(con));
+ return true;
+}
+
+DRAGGING_CB(drag_window_callback) {
+ struct xcb_button_press_event_t *event = extra;
+
+ /* Reposition the client correctly while moving */
+ con->rect.x = old_rect->x + (new_x - event->root_x);
+ con->rect.y = old_rect->y + (new_y - event->root_y);
+
+ render_con(con, false);
+ x_push_node(con, true);
+ xcb_flush(conn);
+
+ /* Check if we cross workspace boundaries while moving */
+ if (!floating_maybe_reassign_ws(con))
+ return;
tree_render();
}