This commit is contained in:
Michael Stapelberg 2009-02-15 02:30:18 +01:00
parent 658c302031
commit 26944bea99
5 changed files with 14 additions and 23 deletions

View File

@ -1,6 +1,7 @@
UNAME=$(shell uname) UNAME=$(shell uname)
DEBUG=1 DEBUG=1
CFLAGS += -std=c99
CFLAGS += -Wall CFLAGS += -Wall
CFLAGS += -Iinclude CFLAGS += -Iinclude
CFLAGS += -I/usr/local/include CFLAGS += -I/usr/local/include

View File

@ -182,7 +182,6 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
printf("snapping container to direction %d\n", direction); printf("snapping container to direction %d\n", direction);
Container *container = CUR_CELL; Container *container = CUR_CELL;
int i;
assert(container != NULL); assert(container != NULL);
@ -202,7 +201,7 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
/* Check if there are other cells with rowspan, which are in our way. /* Check if there are other cells with rowspan, which are in our way.
* If so, reduce their rowspan. */ * If so, reduce their rowspan. */
for (i = container->row-1; i >= 0; i--) { for (int i = container->row-1; i >= 0; i--) {
printf("we got cell %d, %d with rowspan %d\n", printf("we got cell %d, %d with rowspan %d\n",
container->col+1, i, CUR_TABLE[container->col+1][i]->rowspan); container->col+1, i, CUR_TABLE[container->col+1][i]->rowspan);
while ((CUR_TABLE[container->col+1][i]->rowspan-1) >= (container->row - i)) while ((CUR_TABLE[container->col+1][i]->rowspan-1) >= (container->row - i))
@ -224,7 +223,7 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
return; return;
} }
for (i = container->col-1; i >= 0; i--) { for (int i = container->col-1; i >= 0; i--) {
printf("we got cell %d, %d with colspan %d\n", printf("we got cell %d, %d with colspan %d\n",
i, container->row+1, CUR_TABLE[i][container->row+1]->colspan); i, container->row+1, CUR_TABLE[i][container->row+1]->colspan);
while ((CUR_TABLE[i][container->row+1]->colspan-1) >= (container->col - i)) while ((CUR_TABLE[i][container->row+1]->colspan-1) >= (container->col - i))
@ -241,7 +240,6 @@ static void snap_current_container(xcb_connection_t *connection, direction_t dir
} }
static void show_workspace(xcb_connection_t *conn, int workspace) { static void show_workspace(xcb_connection_t *conn, int workspace) {
int cols, rows;
Client *client; Client *client;
xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root;
/* t_ws (to workspace) is just a convenience pointer to the workspace were switching to */ /* t_ws (to workspace) is just a convenience pointer to the workspace were switching to */
@ -286,11 +284,10 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
//xcb_grab_server(conn); //xcb_grab_server(conn);
/* Unmap all clients of the current workspace */ /* Unmap all clients of the current workspace */
for (cols = 0; cols < c_ws->cols; cols++) for (int cols = 0; cols < c_ws->cols; cols++)
for (rows = 0; rows < c_ws->rows; rows++) { for (int rows = 0; rows < c_ws->rows; rows++)
CIRCLEQ_FOREACH(client, &(c_ws->table[cols][rows]->clients), clients) CIRCLEQ_FOREACH(client, &(c_ws->table[cols][rows]->clients), clients)
xcb_unmap_window(conn, client->frame); xcb_unmap_window(conn, client->frame);
}
c_ws = &workspaces[workspace-1]; c_ws = &workspaces[workspace-1];
current_row = c_ws->current_row; current_row = c_ws->current_row;
@ -298,11 +295,10 @@ static void show_workspace(xcb_connection_t *conn, int workspace) {
printf("new current row = %d, current col = %d\n", current_row, current_col); printf("new current row = %d, current col = %d\n", current_row, current_col);
/* Map all clients on the new workspace */ /* Map all clients on the new workspace */
for (cols = 0; cols < c_ws->cols; cols++) for (int cols = 0; cols < c_ws->cols; cols++)
for (rows = 0; rows < c_ws->rows; rows++) { for (int rows = 0; rows < c_ws->rows; rows++)
CIRCLEQ_FOREACH(client, &(c_ws->table[cols][rows]->clients), clients) CIRCLEQ_FOREACH(client, &(c_ws->table[cols][rows]->clients), clients)
xcb_map_window(conn, client->frame); xcb_map_window(conn, client->frame);
}
/* Restore focus on the new workspace */ /* Restore focus on the new workspace */
if (CUR_CELL->currently_focused != NULL) if (CUR_CELL->currently_focused != NULL)

View File

@ -159,8 +159,8 @@ static void render_container(xcb_connection_t *connection, Container *container)
} }
void render_layout(xcb_connection_t *connection) { void render_layout(xcb_connection_t *connection) {
int cols, rows;
i3Screen *screen; i3Screen *screen;
TAILQ_FOREACH(screen, &virtual_screens, screens) { TAILQ_FOREACH(screen, &virtual_screens, screens) {
/* r_ws (rendering workspace) is just a shortcut to the Workspace being currently rendered */ /* r_ws (rendering workspace) is just a shortcut to the Workspace being currently rendered */
Workspace *r_ws = &(workspaces[screen->current_workspace]); Workspace *r_ws = &(workspaces[screen->current_workspace]);
@ -177,8 +177,8 @@ void render_layout(xcb_connection_t *connection) {
width / r_ws->cols, height / r_ws->rows); width / r_ws->cols, height / r_ws->rows);
/* Go through the whole table and render whats necessary */ /* Go through the whole table and render whats necessary */
for (cols = 0; cols < r_ws->cols; cols++) for (int cols = 0; cols < r_ws->cols; cols++)
for (rows = 0; rows < r_ws->rows; rows++) { for (int rows = 0; rows < r_ws->rows; rows++) {
Container *container = r_ws->table[cols][rows]; Container *container = r_ws->table[cols][rows];
printf("container has %d colspan, %d rowspan\n", printf("container has %d colspan, %d rowspan\n",
container->colspan, container->rowspan); container->colspan, container->rowspan);

View File

@ -36,10 +36,9 @@ int current_row = 0;
* *
*/ */
void init_table() { void init_table() {
int i;
memset(workspaces, 0, sizeof(workspaces)); memset(workspaces, 0, sizeof(workspaces));
for (i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
workspaces[i].screen = NULL; workspaces[i].screen = NULL;
expand_table_cols(&(workspaces[i])); expand_table_cols(&(workspaces[i]));
expand_table_rows(&(workspaces[i])); expand_table_rows(&(workspaces[i]));
@ -60,11 +59,9 @@ static void new_container(Workspace *workspace, Container **container) {
* *
*/ */
void expand_table_rows(Workspace *workspace) { void expand_table_rows(Workspace *workspace) {
int c;
workspace->rows++; workspace->rows++;
for (c = 0; c < workspace->cols; c++) { for (int c = 0; c < workspace->cols; c++) {
workspace->table[c] = realloc(workspace->table[c], sizeof(Container*) * workspace->rows); workspace->table[c] = realloc(workspace->table[c], sizeof(Container*) * workspace->rows);
new_container(workspace, &(workspace->table[c][workspace->rows-1])); new_container(workspace, &(workspace->table[c][workspace->rows-1]));
} }
@ -75,13 +72,11 @@ void expand_table_rows(Workspace *workspace) {
* *
*/ */
void expand_table_cols(Workspace *workspace) { void expand_table_cols(Workspace *workspace) {
int c;
workspace->cols++; workspace->cols++;
workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols); workspace->table = realloc(workspace->table, sizeof(Container**) * workspace->cols);
workspace->table[workspace->cols-1] = calloc(sizeof(Container*) * workspace->rows, 1); workspace->table[workspace->cols-1] = calloc(sizeof(Container*) * workspace->rows, 1);
for (c = 0; c < workspace->rows; c++) for (int c = 0; c < workspace->rows; c++)
new_container(workspace, &(workspace->table[workspace->cols-1][c])); new_container(workspace, &(workspace->table[workspace->cols-1][c]));
} }

View File

@ -78,7 +78,6 @@ static void disable_xinerama(xcb_connection_t *connection) {
void initialize_xinerama(xcb_connection_t *conn) { void initialize_xinerama(xcb_connection_t *conn) {
xcb_xinerama_query_screens_reply_t *reply; xcb_xinerama_query_screens_reply_t *reply;
xcb_xinerama_screen_info_t *screen_info; xcb_xinerama_screen_info_t *screen_info;
int screen;
if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) { if (!xcb_get_extension_data(conn, &xcb_xinerama_id)->present) {
printf("Xinerama extension not found, disabling.\n"); printf("Xinerama extension not found, disabling.\n");
@ -101,7 +100,7 @@ void initialize_xinerama(xcb_connection_t *conn) {
num_screens = xcb_xinerama_query_screens_screen_info_length(reply); num_screens = xcb_xinerama_query_screens_screen_info_length(reply);
/* Just go through each workspace and associate as many screens as we can. */ /* Just go through each workspace and associate as many screens as we can. */
for (screen = 0; screen < num_screens; screen++) { for (int screen = 0; screen < num_screens; screen++) {
i3Screen *s = get_screen_at(screen_info[screen].x_org, screen_info[screen].y_org); i3Screen *s = get_screen_at(screen_info[screen].x_org, screen_info[screen].y_org);
if (s!= NULL) { if (s!= NULL) {
/* This screen already exists. We use the littlest screen so that the user /* This screen already exists. We use the littlest screen so that the user