Implement slog() and the LOG() macro, convert printf() to LOG()
This commit is contained in:
38
src/table.c
38
src/table.c
@ -108,7 +108,7 @@ bool cell_exists(int col, int row) {
|
||||
}
|
||||
|
||||
static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int cols) {
|
||||
printf("firstly freeing \n");
|
||||
LOG("firstly freeing \n");
|
||||
|
||||
/* Clean up the column to be freed */
|
||||
for (int rows = 0; rows < workspace->rows; rows++) {
|
||||
@ -122,10 +122,10 @@ static void move_columns_from(xcb_connection_t *conn, Workspace *workspace, int
|
||||
|
||||
for (; cols < workspace->cols; cols++)
|
||||
for (int rows = 0; rows < workspace->rows; rows++) {
|
||||
printf("at col = %d, row = %d\n", cols, rows);
|
||||
LOG("at col = %d, row = %d\n", cols, rows);
|
||||
Container *new_container = workspace->table[cols][rows];
|
||||
|
||||
printf("moving cols = %d to cols -1 = %d\n", cols, cols-1);
|
||||
LOG("moving cols = %d to cols -1 = %d\n", cols, cols-1);
|
||||
workspace->table[cols-1][rows] = new_container;
|
||||
|
||||
new_container->row = rows;
|
||||
@ -146,7 +146,7 @@ static void move_rows_from(xcb_connection_t *conn, Workspace *workspace, int row
|
||||
for (int cols = 0; cols < workspace->cols; cols++) {
|
||||
Container *new_container = workspace->table[cols][rows];
|
||||
|
||||
printf("moving rows = %d to rows -1 = %d\n", rows, rows - 1);
|
||||
LOG("moving rows = %d to rows -1 = %d\n", rows, rows - 1);
|
||||
workspace->table[cols][rows-1] = new_container;
|
||||
|
||||
new_container->row = rows-1;
|
||||
@ -155,21 +155,21 @@ static void move_rows_from(xcb_connection_t *conn, Workspace *workspace, int row
|
||||
}
|
||||
|
||||
void dump_table(xcb_connection_t *conn, Workspace *workspace) {
|
||||
printf("dump_table()\n");
|
||||
LOG("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);
|
||||
LOG("----\n");
|
||||
LOG("at col=%d, row=%d\n", cols, rows);
|
||||
LOG("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);
|
||||
LOG("got client %08x / %s\n", loop->child, loop->name);
|
||||
}
|
||||
printf("----\n");
|
||||
LOG("----\n");
|
||||
}
|
||||
}
|
||||
printf("done\n");
|
||||
LOG("done\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -177,7 +177,7 @@ void dump_table(xcb_connection_t *conn, Workspace *workspace) {
|
||||
*
|
||||
*/
|
||||
void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
|
||||
printf("cleanup_table()\n");
|
||||
LOG("cleanup_table()\n");
|
||||
|
||||
/* Check for empty columns if we got more than one column */
|
||||
for (int cols = 0; (workspace->cols > 1) && (cols < workspace->cols);) {
|
||||
@ -188,7 +188,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
|
||||
break;
|
||||
}
|
||||
if (completely_empty) {
|
||||
printf("Removing completely empty column %d\n", cols);
|
||||
LOG("Removing completely empty column %d\n", cols);
|
||||
if (cols < (workspace->cols - 1))
|
||||
move_columns_from(conn, workspace, cols+1);
|
||||
shrink_table_cols(workspace);
|
||||
@ -207,7 +207,7 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
|
||||
break;
|
||||
}
|
||||
if (completely_empty) {
|
||||
printf("Removing completely empty row %d\n", rows);
|
||||
LOG("Removing completely empty row %d\n", rows);
|
||||
if (rows < (workspace->rows - 1))
|
||||
move_rows_from(conn, workspace, rows+1);
|
||||
shrink_table_rows(workspace);
|
||||
@ -233,24 +233,24 @@ void cleanup_table(xcb_connection_t *conn, Workspace *workspace) {
|
||||
*
|
||||
*/
|
||||
void fix_colrowspan(xcb_connection_t *conn, Workspace *workspace) {
|
||||
printf("Fixing col/rowspan\n");
|
||||
LOG("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);
|
||||
LOG("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);
|
||||
LOG("fixed it to %d\n", con->colspan);
|
||||
}
|
||||
if (con->rowspan > 1) {
|
||||
printf("gots one with rowspan %d\n", con->rowspan);
|
||||
LOG("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);
|
||||
LOG("fixed it to %d\n", con->rowspan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user