void expand_table_cols(Workspace *workspace);
bool cell_exists(int col, int row);
void cleanup_table(xcb_connection_t *conn, Workspace *workspace);
+void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace);
+void dump_table(xcb_connection_t *conn, Workspace *workspace);
+
#endif
printf("i can do that\n");
/* We can move the client inside its current container */
+ /* TODO: needs wrapping */
CIRCLEQ_REMOVE(&(client->container->clients), client, clients);
if (direction == D_UP)
CIRCLEQ_INSERT_BEFORE(&(client->container->clients), other, client, clients);
/* delete all empty columns/rows */
cleanup_table(conn, container->workspace);
+
+ /* Fix colspan/rowspan if it’d overlap */
+ fix_colrowspan(conn, container->workspace);
+
render_layout(conn);
set_focus(conn, current_client);
switch (direction) {
case D_LEFT:
/* Snap to the left is actually a move to the left and then a snap right */
+ if (!cell_exists(container->col - 1, container->row) ||
+ CUR_TABLE[container->col-1][container->row]->currently_focused != NULL) {
+ printf("cannot snap to right - the cell is already used\n");
+ return;
+ }
+
move_current_window(conn, D_LEFT);
snap_current_container(conn, D_RIGHT);
return;
for (int cols = 0; cols < r_ws->cols; cols++)
for (int rows = 0; rows < r_ws->rows; rows++) {
Container *container = r_ws->table[cols][rows];
+ int single_width, single_height;
printf("\n========\ncontainer has %d colspan, %d rowspan\n",
container->colspan, container->rowspan);
printf("container at %d, %d\n", xoffset[rows], yoffset[cols]);
if (container->width_factor == 0)
container->width = (width / r_ws->cols);
else container->width = get_unoccupied_x(r_ws, rows) * container->width_factor;
+ single_width = container->width;
container->width *= container->colspan;
if (container->height_factor == 0)
container->height = (height / r_ws->rows);
else container->height = get_unoccupied_y(r_ws, cols) * container->height_factor;
+ single_height = container->height;
container->height *= container->rowspan;
/* Render the container if it is not empty */
render_container(conn, container);
- xoffset[rows] += container->width;
- yoffset[cols] += container->height;
+ xoffset[rows] += single_width;
+ yoffset[cols] += single_height;
printf("==========\n");
}
}
}
+void dump_table(xcb_connection_t *conn, Workspace *workspace) {
+ printf("dump_table()\n");
+ for (int cols = 0; cols < workspace->cols; cols++) {
+ for (int rows = 0; rows < workspace->rows; rows++) {
+ Container *con = workspace->table[cols][rows];
+ printf("----\n");
+ printf("at col=%d, row=%d\n", cols, rows);
+ printf("currently_focused = %p\n", con->currently_focused);
+ Client *loop;
+ CIRCLEQ_FOREACH(loop, &(con->clients), clients) {
+ printf("got client %08x / %s\n", loop->child, loop->name);
+ }
+ printf("----\n");
+ }
+ }
+ printf("done\n");
+}
+
/*
* Shrinks the table by "compacting" it, that is, removing completely empty rows/columns
*
if (CUR_CELL->currently_focused != NULL)
set_focus(conn, CUR_CELL->currently_focused);
}
+
+/*
+ * Fixes col/rowspan (makes sure there are no overlapping windows)
+ *
+ */
+void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace) {
+ printf("Fixing col/rowspan\n");
+
+ for (int cols = 0; cols < workspace->cols; cols++)
+ for (int rows = 0; rows < workspace->rows; rows++) {
+ Container *con = workspace->table[cols][rows];
+ if (con->colspan > 1) {
+ printf("gots one with colspan %d\n", con->colspan);
+ while (con->colspan > 1 &&
+ workspace->table[cols + (con->colspan - 1)][rows]->currently_focused != NULL)
+ con->colspan--;
+ printf("fixed it to %d\n", con->colspan);
+ }
+ if (con->rowspan > 1) {
+ printf("gots one with rowspan %d\n", con->rowspan);
+ while (con->rowspan > 1 &&
+ workspace->table[cols][rows + (con->rowspan - 1)]->currently_focused != NULL)
+ con->rowspan--;
+ printf("fixed it to %d\n", con->rowspan);
+ }
+ }
+}