2 * This file provides functions for easier accessing of _the_ table
17 int current_workspace = 0;
18 Workspace workspaces[10];
19 /* Convenience pointer to the current workspace */
20 Workspace *c_ws = &workspaces[0];
30 memset(workspaces, 0, sizeof(workspaces));
32 for (i = 0; i < 10; i++) {
33 expand_table_cols(&(workspaces[i]));
34 expand_table_rows(&(workspaces[i]));
38 static void new_container(Container **container) {
40 new = *container = calloc(sizeof(Container), 1);
41 CIRCLEQ_INIT(&(new->clients));
47 * Add one row to the table
50 void expand_table_rows(Workspace *workspace) {
55 for (c = 0; c < workspace->cols; c++) {
56 workspace->table[c] = realloc(workspace->table[c], sizeof(Container*) * workspace->rows);
57 new_container(&(workspace->table[c][workspace->rows-1]));
62 * Add one column to the table
65 void expand_table_cols(Workspace *workspace) {
70 workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols);
71 workspace->table[workspace->cols-1] = calloc(sizeof(Container*) * workspace->rows, 1);
72 for (c = 0; c < workspace->rows; c++)
73 new_container(&(workspace->table[workspace->cols-1][c]));
77 * Performs simple bounds checking for the given column/row
80 bool cell_exists(int col, int row) {
81 return (col >= 0 && col < c_ws->rows) &&
82 (row >= 0 && row < c_ws->cols);