4 * i3 - an improved dynamic tiling window manager
6 * (c) 2009 Michael Stapelberg and contributors
8 * See file LICENSE for license information.
12 * This file provides functions for easier accessing of _the_ table
19 #include <sys/types.h>
27 int current_workspace = 0;
28 Workspace workspaces[10];
29 /* Convenience pointer to the current workspace */
30 Workspace *c_ws = &workspaces[0];
40 memset(workspaces, 0, sizeof(workspaces));
42 for (i = 0; i < 10; i++) {
43 expand_table_cols(&(workspaces[i]));
44 expand_table_rows(&(workspaces[i]));
48 static void new_container(Container **container) {
50 new = *container = calloc(sizeof(Container), 1);
51 CIRCLEQ_INIT(&(new->clients));
57 * Add one row to the table
60 void expand_table_rows(Workspace *workspace) {
65 for (c = 0; c < workspace->cols; c++) {
66 workspace->table[c] = realloc(workspace->table[c], sizeof(Container*) * workspace->rows);
67 new_container(&(workspace->table[c][workspace->rows-1]));
72 * Add one column to the table
75 void expand_table_cols(Workspace *workspace) {
80 workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols);
81 workspace->table[workspace->cols-1] = calloc(sizeof(Container*) * workspace->rows, 1);
82 for (c = 0; c < workspace->rows; c++)
83 new_container(&(workspace->table[workspace->cols-1][c]));
87 * Performs simple bounds checking for the given column/row
90 bool cell_exists(int col, int row) {
91 return (col >= 0 && col < c_ws->rows) &&
92 (row >= 0 && row < c_ws->cols);